diff options
| author | Silarn <jrim@rimpo.org> | 2019-12-06 23:12:18 -0600 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2019-12-06 23:12:18 -0600 |
| commit | b3331ef2c0b50ab2cea4c328e78f6ab58bca099d (patch) | |
| tree | e0be0d00f40733baa4692120d0266ae797ab3785 /src/colortable.cpp | |
| parent | d42bca5bc0043337f8de72ea72544ebabc505f8b (diff) | |
Separate conflict flags and render them in separate columns
Diffstat (limited to 'src/colortable.cpp')
| -rw-r--r-- | src/colortable.cpp | 61 |
1 files changed, 50 insertions, 11 deletions
diff --git a/src/colortable.cpp b/src/colortable.cpp index 61c5ee5f..b1e4ef6c 100644 --- a/src/colortable.cpp +++ b/src/colortable.cpp @@ -1,5 +1,6 @@ #include "colortable.h" #include "modflagicondelegate.h" +#include "modconflicticondelegate.h" #include "settings.h" class ColorItem; @@ -52,21 +53,17 @@ public: } void paint( - QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const override + QPainter* painter, const QStyleOptionViewItem& option, + const QModelIndex& index) const override { paintBackground(m_table, painter, option, index); ModFlagIconDelegate::paintIcons(painter, option, index, getIcons(index)); } protected: - QList<QString> getIcons(const QModelIndex &index) const override + QList<QString> getIcons(const QModelIndex& index) const override { const auto flags = { - ModInfo::FLAG_CONFLICT_MIXED, - ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE, - ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN, - ModInfo::FLAG_ARCHIVE_CONFLICT_MIXED, ModInfo::FLAG_BACKUP, ModInfo::FLAG_NOTENDORSED, ModInfo::FLAG_NOTES, @@ -76,7 +73,48 @@ protected: return getIconsForFlags(flags, false); } - size_t getNumIcons(const QModelIndex &index) const override + size_t getNumIcons(const QModelIndex& index) const override + { + return getIcons(index).size(); + } + +private: + QTableWidget* m_table; +}; + + +// delegate for the icons column; paints the background and icons +// +class FakeModConflictIconDelegate : public ModConflictIconDelegate +{ +public: + explicit FakeModConflictIconDelegate(QTableWidget* table) + : m_table(table) + { + } + + void paint( + QPainter* painter, const QStyleOptionViewItem& option, + const QModelIndex& index) const override + { + paintBackground(m_table, painter, option, index); + ModFlagIconDelegate::paintIcons(painter, option, index, getIcons(index)); + } + +protected: + QList<QString> getIcons(const QModelIndex& index) const override + { + const auto flags = { + ModInfo::FLAG_CONFLICT_MIXED, + ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE, + ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN, + ModInfo::FLAG_ARCHIVE_CONFLICT_MIXED + }; + + return getIconsForFlags(flags, false); + } + + size_t getNumIcons(const QModelIndex& index) const override { return getIcons(index).size(); } @@ -183,11 +221,12 @@ void paintBackground( ColorTable::ColorTable(QWidget* parent) : QTableWidget(parent), m_settings(nullptr) { - setColumnCount(3); - setHorizontalHeaderLabels({"", "", ""}); + setColumnCount(4); + setHorizontalHeaderLabels({"", "", "", ""}); setItemDelegateForColumn(1, new ColoredBackgroundDelegate(this)); - setItemDelegateForColumn(2, new FakeModFlagIconDelegate(this)); + setItemDelegateForColumn(2, new FakeModConflictIconDelegate(this)); + setItemDelegateForColumn(3, new FakeModFlagIconDelegate(this)); connect( this, &QTableWidget::cellActivated, |
