Skip to content

Commit

Permalink
Provide getter/setter for visible appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
gpospelov committed Jan 21, 2021
1 parent cfc2f98 commit 7faf53c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/libmvvm_model/mvvm/model/sessionitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ SessionItem* SessionItem::setEnabled(bool value)
return this;
}

bool SessionItem::isVisible() const
{
return appearance(*this) & Appearance::VISIBLE;
}

SessionItem* SessionItem::setVisible(bool value)
{
setAppearanceFlag(Appearance::VISIBLE, value);
return this;
}

//! Returns item tooltip, if exists.

std::string SessionItem::toolTip() const
Expand Down
3 changes: 3 additions & 0 deletions source/libmvvm_model/mvvm/model/sessionitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class MVVM_MODEL_EXPORT SessionItem {
bool isEnabled() const;
SessionItem* setEnabled(bool value);

bool isVisible() const;
SessionItem* setVisible(bool value);

std::string toolTip() const;
SessionItem* setToolTip(const std::string& tooltip);

Expand Down
9 changes: 9 additions & 0 deletions tests/testmodel/sessionitem.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,13 @@ TEST_F(SessionItemTest, appearance)
// default status
EXPECT_TRUE(item.isEnabled());
EXPECT_TRUE(item.isEditable());
EXPECT_TRUE(item.isVisible());

// disabling item
item.setEnabled(false);
EXPECT_FALSE(item.isEnabled());
EXPECT_TRUE(item.isEditable());
EXPECT_TRUE(item.isVisible());

// data should be there now
variant = item.data<QVariant>(ItemDataRole::APPEARANCE);
Expand All @@ -661,6 +663,13 @@ TEST_F(SessionItemTest, appearance)
item.setEditable(false);
EXPECT_FALSE(item.isEnabled());
EXPECT_FALSE(item.isEditable());
EXPECT_TRUE(item.isVisible());

// making it hidden
item.setVisible(false);
EXPECT_FALSE(item.isEnabled());
EXPECT_FALSE(item.isEditable());
EXPECT_FALSE(item.isVisible());
}

//! Checks item tooltip.
Expand Down

0 comments on commit 7faf53c

Please sign in to comment.