mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 00:07:34 +00:00
GModelSelection: Add contains_row(int) and toggle(GModelIndex)
This commit is contained in:
parent
94b599e344
commit
b0f42ee672
2 changed files with 19 additions and 0 deletions
|
@ -20,6 +20,16 @@ void GModelSelection::add(const GModelIndex& index)
|
||||||
m_view.notify_selection_changed({});
|
m_view.notify_selection_changed({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GModelSelection::toggle(const GModelIndex& index)
|
||||||
|
{
|
||||||
|
ASSERT(index.is_valid());
|
||||||
|
if (m_indexes.contains(index))
|
||||||
|
m_indexes.remove(index);
|
||||||
|
else
|
||||||
|
m_indexes.set(index);
|
||||||
|
m_view.notify_selection_changed({});
|
||||||
|
}
|
||||||
|
|
||||||
bool GModelSelection::remove(const GModelIndex& index)
|
bool GModelSelection::remove(const GModelIndex& index)
|
||||||
{
|
{
|
||||||
ASSERT(index.is_valid());
|
ASSERT(index.is_valid());
|
||||||
|
|
|
@ -14,9 +14,18 @@ public:
|
||||||
|
|
||||||
bool is_empty() const { return m_indexes.is_empty(); }
|
bool is_empty() const { return m_indexes.is_empty(); }
|
||||||
bool contains(const GModelIndex& index) const { return m_indexes.contains(index); }
|
bool contains(const GModelIndex& index) const { return m_indexes.contains(index); }
|
||||||
|
bool contains_row(int row) const
|
||||||
|
{
|
||||||
|
for (auto& index : m_indexes) {
|
||||||
|
if (index.row() == row)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void set(const GModelIndex&);
|
void set(const GModelIndex&);
|
||||||
void add(const GModelIndex&);
|
void add(const GModelIndex&);
|
||||||
|
void toggle(const GModelIndex&);
|
||||||
bool remove(const GModelIndex&);
|
bool remove(const GModelIndex&);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue