diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-09-27 15:26:00 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-09-27 15:26:00 -0400 |
| commit | ec48a6d79665915b07f11f93a834fbec7fc09c45 (patch) | |
| tree | 795ced35cc9c45b651ac49f0aa98be566b4dd32b /src/colortable.cpp | |
| parent | 51d664d76ce6b611e7a7585b209bad9d68fe65d7 (diff) | |
a few comments for ColorTable
Diffstat (limited to 'src/colortable.cpp')
| -rw-r--r-- | src/colortable.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/colortable.cpp b/src/colortable.cpp index 7546abe5..61c5ee5f 100644 --- a/src/colortable.cpp +++ b/src/colortable.cpp @@ -10,6 +10,8 @@ void paintBackground( const QModelIndex& index); +// delegate for the sample text column; paints the background color +// class ColoredBackgroundDelegate : public QStyledItemDelegate { public: @@ -26,6 +28,9 @@ public: QStyleOptionViewItem itemOption(option); initStyleOption(&itemOption, index); + + // paint the default stuff like text, but override the state to avoid + // destroying the background for selected items, etc. itemOption.state = QStyle::State_Enabled; QStyledItemDelegate::paint(p, itemOption, index); @@ -36,6 +41,8 @@ private: }; +// delegate for the icons column; paints the background and icons +// class FakeModFlagIconDelegate : public ModFlagIconDelegate { public: @@ -79,6 +86,8 @@ private: }; +// item used in the first column of the table +// class ColorItem : public QTableWidgetItem { public: @@ -93,16 +102,22 @@ public: set(get()); } + // color caption + // const QString& caption() const { return m_caption; } + // the current color + // QColor get() const { return m_temp; } + // sets the current color, commit() must be called to save it + // bool set(const QColor& c) { if (m_temp != c) { @@ -113,14 +128,18 @@ public: return false; } - void commit() + // resets the current color, commit() must be called to save it + // + bool reset() { - m_commit(m_temp); + return set(m_default); } - bool reset() + // saves the current color + // + void commit() { - return set(m_default); + m_commit(m_temp); } private: @@ -246,9 +265,7 @@ void ColorTable::addColor( const auto r = rowCount(); setRowCount(r + 1); - auto* item = new ColorItem(text, defaultColor, get, commit); - - setItem(r, 0, item); + setItem(r, 0, new ColorItem(text, defaultColor, get, commit)); setItem(r, 1, new QTableWidgetItem("Text")); setItem(r, 2, new QTableWidgetItem); |
