diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-06 19:43:21 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-10 10:27:22 +0100 |
| commit | 1ac3f4d8e8ee7461f047d34e196df40499e89557 (patch) | |
| tree | 803e663c2da154d0d48a4f284185b37c53e0b2f2 /src/modconflicticondelegate.cpp | |
| parent | 76796796bec37a1670cfc4e0b1e42e7b1096b237 (diff) | |
Display children contents in collapsed separator.
Diffstat (limited to 'src/modconflicticondelegate.cpp')
| -rw-r--r-- | src/modconflicticondelegate.cpp | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/modconflicticondelegate.cpp b/src/modconflicticondelegate.cpp index 73c47a03..fc0ee48a 100644 --- a/src/modconflicticondelegate.cpp +++ b/src/modconflicticondelegate.cpp @@ -7,21 +7,10 @@ using namespace MOBase; ModConflictIconDelegate::ModConflictIconDelegate(ModListView* view, int logicalIndex, int compactSize) - : IconDelegate(view) - , m_View(view) - , m_LogicalIndex(logicalIndex) - , m_CompactSize(compactSize) - , m_Compact(false) + : IconDelegate(view, logicalIndex, compactSize), m_view(view) { } -void ModConflictIconDelegate::columnResized(int logicalIndex, int, int newSize) -{ - if (logicalIndex == m_LogicalIndex) { - m_Compact = newSize < m_CompactSize; - } -} - QList<QString> ModConflictIconDelegate::getIconsForFlags( std::vector<ModInfo::EConflictFlag> flags, bool compact) { @@ -94,8 +83,8 @@ QList<QString> ModConflictIconDelegate::getIcons(const QModelIndex &index) const } bool compact; - auto flags = m_View->conflictFlags(index, &compact); - return getIconsForFlags(flags, compact || m_Compact); + auto flags = m_view->conflictFlags(index, &compact); + return getIconsForFlags(flags, compact || this->compact()); } QString ModConflictIconDelegate::getFlagIcon(ModInfo::EConflictFlag flag) @@ -119,19 +108,13 @@ QString ModConflictIconDelegate::getFlagIcon(ModInfo::EConflictFlag flag) size_t ModConflictIconDelegate::getNumIcons(const QModelIndex &index) const { - unsigned int modIdx = index.data(ModList::IndexRole).toInt(); - if (modIdx < ModInfo::getNumMods()) { - ModInfo::Ptr info = ModInfo::getByIndex(modIdx); - std::vector<ModInfo::EConflictFlag> flags = info->getConflictFlags(); - size_t count = flags.size(); - if (std::find_first_of(flags.begin(), flags.end(), - s_ConflictFlags.begin(), s_ConflictFlags.end()) == flags.end()) { - ++count; - } - return count; - } else { + QVariant modIndex = index.data(ModList::IndexRole); + + if (!modIndex.isValid()) { return 0; } + + return m_view->conflictFlags(index, nullptr).size(); } QSize ModConflictIconDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &modelIndex) const |
