From 183440d6949578c2c626022d42ee412919a19552 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 7 Jan 2021 19:47:13 +0100 Subject: Display mod flags on collapsed separators. --- src/modlistview.cpp | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 63999ce9..7c67c599 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -217,10 +217,8 @@ std::optional ModListView::nextMod(unsigned int modIndex) const ModInfo::Ptr mod = ModInfo::getByIndex(modIndex); - // skip overwrite and backups and separators - if (mod->hasFlag(ModInfo::FLAG_OVERWRITE) || - mod->hasFlag(ModInfo::FLAG_BACKUP) || - mod->hasFlag(ModInfo::FLAG_SEPARATOR)) { + // skip overwrite, backups and separators + if (mod->isOverwrite() || mod->isBackup() || mod->isSeparator()) { continue; } @@ -246,12 +244,9 @@ std::optional ModListView::prevMod(unsigned int modIndex) const modIndex = index.data(ModList::IndexRole).toInt(); - // skip overwrite and backups and separators + // skip overwrite, backups and separators ModInfo::Ptr mod = ModInfo::getByIndex(modIndex); - - if (mod->hasFlag(ModInfo::FLAG_OVERWRITE) || - mod->hasFlag(ModInfo::FLAG_BACKUP) || - mod->hasFlag(ModInfo::FLAG_SEPARATOR)) { + if (mod->isOverwrite() || mod->isBackup() || mod->isSeparator()) { continue; } @@ -1080,6 +1075,37 @@ QColor ModListView::markerColor(const QModelIndex& index) const return QColor(); } +std::vector ModListView::modFlags(const QModelIndex& index, bool* forceCompact) const +{ + ModInfo::Ptr info = ModInfo::getByIndex(index.data(ModList::IndexRole).toInt()); + + auto flags = info->getFlags(); + bool compact = false; + if (info->isSeparator() + && hasCollapsibleSeparators() + && m_core->settings().interface().collapsibleSeparatorsConflicts() + && !isExpanded(index.sibling(index.row(), 0))) { + + // combine the child conflicts + std::set eFlags(flags.begin(), flags.end()); + for (int i = 0; i < model()->rowCount(index); ++i) { + auto cIndex = model()->index(i, index.column(), index).data(ModList::IndexRole).toInt(); + auto cFlags = ModInfo::getByIndex(cIndex)->getFlags(); + eFlags.insert(cFlags.begin(), cFlags.end()); + } + flags = { eFlags.begin(), eFlags.end() }; + + // force compact because there can be a lots of flags here + compact = true; + } + + if (forceCompact) { + *forceCompact = true; + } + + return flags; +} + std::vector ModListView::conflictFlags(const QModelIndex& index, bool* forceCompact) const { ModInfo::Ptr info = ModInfo::getByIndex(index.data(ModList::IndexRole).toInt()); -- cgit v1.3.1