summaryrefslogtreecommitdiff
path: root/src/modconflicticondelegate.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2022-05-17 11:47:01 +0200
committerMikaël Capelle <capelle.mikael@gmail.com>2023-07-09 17:20:40 +0200
commitd13f6bb870cdda71257f665367be8ef9fca86255 (patch)
tree52e214718478f1e52856572f5aa1a2ac58537f9f /src/modconflicticondelegate.cpp
parent86bb01ba9eac879d3685c439ac9da0028bc4bc80 (diff)
Apply clang-format.
Diffstat (limited to 'src/modconflicticondelegate.cpp')
-rw-r--r--src/modconflicticondelegate.cpp84
1 files changed, 49 insertions, 35 deletions
diff --git a/src/modconflicticondelegate.cpp b/src/modconflicticondelegate.cpp
index fc0ee48a..c0b4d46d 100644
--- a/src/modconflicticondelegate.cpp
+++ b/src/modconflicticondelegate.cpp
@@ -1,29 +1,31 @@
#include "modconflicticondelegate.h"
#include "modlist.h"
#include "modlistview.h"
-#include <log.h>
#include <QList>
+#include <log.h>
using namespace MOBase;
-ModConflictIconDelegate::ModConflictIconDelegate(ModListView* view, int logicalIndex, int compactSize)
- : IconDelegate(view, logicalIndex, compactSize), m_view(view)
-{
-}
+ModConflictIconDelegate::ModConflictIconDelegate(ModListView* view, int logicalIndex,
+ int compactSize)
+ : IconDelegate(view, logicalIndex, compactSize), m_view(view)
+{}
-QList<QString> ModConflictIconDelegate::getIconsForFlags(
- std::vector<ModInfo::EConflictFlag> flags, bool compact)
+QList<QString>
+ModConflictIconDelegate::getIconsForFlags(std::vector<ModInfo::EConflictFlag> flags,
+ bool compact)
{
QList<QString> result;
// Don't do flags for overwrite
- if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE_CONFLICT) != flags.end())
+ if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE_CONFLICT) !=
+ flags.end())
return result;
// insert conflict icons to provide nicer alignment
- { // insert loose file conflicts first
- auto iter = std::find_first_of(flags.begin(), flags.end(),
- s_ConflictFlags.begin(), s_ConflictFlags.end());
+ { // insert loose file conflicts first
+ auto iter = std::find_first_of(flags.begin(), flags.end(), s_ConflictFlags.begin(),
+ s_ConflictFlags.end());
if (iter != flags.end()) {
result.append(getFlagIcon(*iter));
flags.erase(iter);
@@ -32,9 +34,9 @@ QList<QString> ModConflictIconDelegate::getIconsForFlags(
}
}
- { // insert loose vs archive overwrite second
+ { // insert loose vs archive overwrite second
auto iter = std::find(flags.begin(), flags.end(),
- ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE);
+ ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE);
if (iter != flags.end()) {
result.append(getFlagIcon(*iter));
flags.erase(iter);
@@ -43,9 +45,9 @@ QList<QString> ModConflictIconDelegate::getIconsForFlags(
}
}
- { // insert loose vs archive overwritten third
+ { // insert loose vs archive overwritten third
auto iter = std::find(flags.begin(), flags.end(),
- ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN);
+ ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN);
if (iter != flags.end()) {
result.append(getFlagIcon(*iter));
flags.erase(iter);
@@ -54,9 +56,10 @@ QList<QString> ModConflictIconDelegate::getIconsForFlags(
}
}
- { // insert archive conflicts last
- auto iter = std::find_first_of(flags.begin(), flags.end(),
- s_ArchiveConflictFlags.begin(), s_ArchiveConflictFlags.end());
+ { // insert archive conflicts last
+ auto iter =
+ std::find_first_of(flags.begin(), flags.end(), s_ArchiveConflictFlags.begin(),
+ s_ArchiveConflictFlags.end());
if (iter != flags.end()) {
result.append(getFlagIcon(*iter));
flags.erase(iter);
@@ -74,7 +77,7 @@ QList<QString> ModConflictIconDelegate::getIconsForFlags(
return result;
}
-QList<QString> ModConflictIconDelegate::getIcons(const QModelIndex &index) const
+QList<QString> ModConflictIconDelegate::getIcons(const QModelIndex& index) const
{
QVariant modIndex = index.data(ModList::IndexRole);
@@ -90,23 +93,33 @@ QList<QString> ModConflictIconDelegate::getIcons(const QModelIndex &index) const
QString ModConflictIconDelegate::getFlagIcon(ModInfo::EConflictFlag flag)
{
switch (flag) {
- case ModInfo::FLAG_CONFLICT_MIXED: return QStringLiteral(":/MO/gui/emblem_conflict_mixed");
- case ModInfo::FLAG_CONFLICT_OVERWRITE: return QStringLiteral(":/MO/gui/emblem_conflict_overwrite");
- case ModInfo::FLAG_CONFLICT_OVERWRITTEN: return QStringLiteral(":/MO/gui/emblem_conflict_overwritten");
- case ModInfo::FLAG_CONFLICT_REDUNDANT: return QStringLiteral(":/MO/gui/emblem_conflict_redundant");
- case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE: return QStringLiteral(":/MO/gui/archive_loose_conflict_overwrite");
- case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN: return QStringLiteral(":/MO/gui/archive_loose_conflict_overwritten");
- case ModInfo::FLAG_ARCHIVE_CONFLICT_MIXED: return QStringLiteral(":/MO/gui/archive_conflict_mixed");
- case ModInfo::FLAG_ARCHIVE_CONFLICT_OVERWRITE: return QStringLiteral(":/MO/gui/archive_conflict_winner");
- case ModInfo::FLAG_ARCHIVE_CONFLICT_OVERWRITTEN: return QStringLiteral(":/MO/gui/archive_conflict_loser");
- case ModInfo::FLAG_OVERWRITE_CONFLICT: return QString();
- default:
- log::warn("ModInfo flag {} has no defined icon", flag);
- return QString();
+ case ModInfo::FLAG_CONFLICT_MIXED:
+ return QStringLiteral(":/MO/gui/emblem_conflict_mixed");
+ case ModInfo::FLAG_CONFLICT_OVERWRITE:
+ return QStringLiteral(":/MO/gui/emblem_conflict_overwrite");
+ case ModInfo::FLAG_CONFLICT_OVERWRITTEN:
+ return QStringLiteral(":/MO/gui/emblem_conflict_overwritten");
+ case ModInfo::FLAG_CONFLICT_REDUNDANT:
+ return QStringLiteral(":/MO/gui/emblem_conflict_redundant");
+ case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE:
+ return QStringLiteral(":/MO/gui/archive_loose_conflict_overwrite");
+ case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN:
+ return QStringLiteral(":/MO/gui/archive_loose_conflict_overwritten");
+ case ModInfo::FLAG_ARCHIVE_CONFLICT_MIXED:
+ return QStringLiteral(":/MO/gui/archive_conflict_mixed");
+ case ModInfo::FLAG_ARCHIVE_CONFLICT_OVERWRITE:
+ return QStringLiteral(":/MO/gui/archive_conflict_winner");
+ case ModInfo::FLAG_ARCHIVE_CONFLICT_OVERWRITTEN:
+ return QStringLiteral(":/MO/gui/archive_conflict_loser");
+ case ModInfo::FLAG_OVERWRITE_CONFLICT:
+ return QString();
+ default:
+ log::warn("ModInfo flag {} has no defined icon", flag);
+ return QString();
}
}
-size_t ModConflictIconDelegate::getNumIcons(const QModelIndex &index) const
+size_t ModConflictIconDelegate::getNumIcons(const QModelIndex& index) const
{
QVariant modIndex = index.data(ModList::IndexRole);
@@ -117,9 +130,10 @@ size_t ModConflictIconDelegate::getNumIcons(const QModelIndex &index) const
return m_view->conflictFlags(index, nullptr).size();
}
-QSize ModConflictIconDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &modelIndex) const
+QSize ModConflictIconDelegate::sizeHint(const QStyleOptionViewItem& option,
+ const QModelIndex& modelIndex) const
{
- size_t count = getNumIcons(modelIndex);
+ size_t count = getNumIcons(modelIndex);
unsigned int index = modelIndex.data(ModList::IndexRole).toInt();
QSize result;
if (index < ModInfo::getNumMods()) {