mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibGUI: Expand GModelIndex a bit, adding internal data and model pointers.
This will be useful for implementing more complicated models.
This commit is contained in:
parent
12ec55ee74
commit
d02238af48
10 changed files with 94 additions and 34 deletions
|
@ -1,21 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
class GModel;
|
||||
|
||||
class GModelIndex {
|
||||
friend class GModel;
|
||||
public:
|
||||
GModelIndex() { }
|
||||
GModelIndex(int row, int column)
|
||||
: m_row(row)
|
||||
, m_column(column)
|
||||
{
|
||||
}
|
||||
|
||||
bool is_valid() const { return m_row != -1 && m_column != -1; }
|
||||
int row() const { return m_row; }
|
||||
int column() const { return m_column; }
|
||||
|
||||
void* internal_data() const { return m_internal_data; }
|
||||
|
||||
bool operator==(const GModelIndex& other) const { return m_row == other.m_row && m_column == other.m_column; }
|
||||
|
||||
private:
|
||||
GModelIndex(const GModel& model, int row, int column, void* internal_data)
|
||||
: m_model(&model)
|
||||
, m_row(row)
|
||||
, m_column(column)
|
||||
, m_internal_data(internal_data)
|
||||
{
|
||||
}
|
||||
|
||||
const GModel* m_model { nullptr };
|
||||
int m_row { -1 };
|
||||
int m_column { -1 };
|
||||
void* m_internal_data { nullptr };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue