ladybird/LibGUI/GModelIndex.h
Robin Burchell 0dc9af5f7e Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
2019-05-28 17:31:20 +02:00

43 lines
997 B
C++

#pragma once
class GModel;
class GModelIndex {
friend class GModel;
public:
GModelIndex() {}
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; }
GModelIndex parent() const;
bool operator==(const GModelIndex& other) const
{
return m_model == other.m_model && m_row == other.m_row && m_column == other.m_column && m_internal_data == other.m_internal_data;
}
bool operator!=(const GModelIndex& other) const
{
return !(*this == other);
}
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 };
};