summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modflagicondelegate.cpp10
-rw-r--r--src/modflagicondelegate.h7
-rw-r--r--src/modlistview.cpp44
-rw-r--r--src/modlistview.h6
4 files changed, 53 insertions, 14 deletions
diff --git a/src/modflagicondelegate.cpp b/src/modflagicondelegate.cpp
index c709f30d..30a3c376 100644
--- a/src/modflagicondelegate.cpp
+++ b/src/modflagicondelegate.cpp
@@ -1,12 +1,13 @@
#include "modflagicondelegate.h"
#include "modlist.h"
+#include "modlistview.h"
#include <log.h>
#include <QList>
using namespace MOBase;
-ModFlagIconDelegate::ModFlagIconDelegate(QTreeView* view, int column, int compactSize)
- : IconDelegate(view, column, compactSize)
+ModFlagIconDelegate::ModFlagIconDelegate(ModListView* view, int column, int compactSize)
+ : IconDelegate(view, column, compactSize), m_view(view)
{
}
@@ -33,8 +34,9 @@ QList<QString> ModFlagIconDelegate::getIcons(const QModelIndex &index) const
QVariant modid = index.data(ModList::IndexRole);
if (modid.isValid()) {
- ModInfo::Ptr info = ModInfo::getByIndex(modid.toInt());
- return getIconsForFlags(info->getFlags(), compact());
+ bool compact;
+ auto flags = m_view->modFlags(index, &compact);
+ return getIconsForFlags(flags, compact || this->compact());
}
return {};
diff --git a/src/modflagicondelegate.h b/src/modflagicondelegate.h
index 63ab8978..24dd4a0e 100644
--- a/src/modflagicondelegate.h
+++ b/src/modflagicondelegate.h
@@ -6,12 +6,14 @@
#include "icondelegate.h"
#include "modinfo.h"
+class ModListView;
+
class ModFlagIconDelegate : public IconDelegate
{
Q_OBJECT;
public:
- explicit ModFlagIconDelegate(QTreeView* view, int column = -1, int compactSize = 120);
+ explicit ModFlagIconDelegate(ModListView* view, int column = -1, int compactSize = 120);
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
protected:
@@ -25,6 +27,9 @@ protected:
//
ModFlagIconDelegate() : ModFlagIconDelegate(nullptr) { }
+private:
+ ModListView* m_view;
+
};
#endif // MODFLAGICONDELEGATE_H
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<unsigned int> 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<unsigned int> 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<ModInfo::EFlag> 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<ModInfo::EConflictFlag> ModListView::conflictFlags(const QModelIndex& index, bool* forceCompact) const
{
ModInfo::Ptr info = ModInfo::getByIndex(index.data(ModList::IndexRole).toInt());
diff --git a/src/modlistview.h b/src/modlistview.h
index 48e003bd..af4e83c0 100644
--- a/src/modlistview.h
+++ b/src/modlistview.h
@@ -173,6 +173,7 @@ protected slots:
private:
friend class ModConflictIconDelegate;
+ friend class ModFlagIconDelegate;
friend class ModContentIconDelegate;
friend class ModListStyledItemDelegated;
friend class ModListViewMarkingScrollBar;
@@ -195,6 +196,11 @@ private:
//
QColor markerColor(const QModelIndex& index) const;
+ // retrieve the mod flags for the given index
+ //
+ std::vector<ModInfo::EFlag> modFlags(
+ const QModelIndex& index, bool* forceCompact = nullptr) const;
+
// retrieve the conflicts flags for the given index
//
std::vector<ModInfo::EConflictFlag> conflictFlags(