From 1ac3f4d8e8ee7461f047d34e196df40499e89557 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Wed, 6 Jan 2021 19:43:21 +0100 Subject: Display children contents in collapsed separator. --- src/modconflicticondelegate.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src/modconflicticondelegate.cpp') 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 ModConflictIconDelegate::getIconsForFlags( std::vector flags, bool compact) { @@ -94,8 +83,8 @@ QList 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 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 -- cgit v1.3.1