diff options
| author | Tannin <devnull@localhost> | 2014-02-23 17:18:20 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-02-23 17:18:20 +0100 |
| commit | 00f4e1799fb34e070773f3ec170be2dd86ec9c0d (patch) | |
| tree | 6fe354b5ac432a23e79793cbf7e2b7c069066d71 /src/modflagicondelegate.cpp | |
| parent | 35fcf1c25b19b612771a2bc874df7631695e1457 (diff) | |
- slightly overworked display of icon delegates
- updated installer
Diffstat (limited to 'src/modflagicondelegate.cpp')
| -rw-r--r-- | src/modflagicondelegate.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/modflagicondelegate.cpp b/src/modflagicondelegate.cpp index db69eb52..914503a1 100644 --- a/src/modflagicondelegate.cpp +++ b/src/modflagicondelegate.cpp @@ -2,6 +2,11 @@ #include <QList>
+ModInfo::EFlag ModFlagIconDelegate::m_ConflictFlags[4] = { ModInfo::FLAG_CONFLICT_MIXED
+ , ModInfo::FLAG_CONFLICT_OVERWRITE
+ , ModInfo::FLAG_CONFLICT_OVERWRITTEN
+ , ModInfo::FLAG_CONFLICT_REDUNDANT };
+
ModFlagIconDelegate::ModFlagIconDelegate(QObject *parent)
: IconDelegate(parent)
{
@@ -15,6 +20,16 @@ QList<QIcon> ModFlagIconDelegate::getIcons(const QModelIndex &index) const ModInfo::Ptr info = ModInfo::getByIndex(modid.toInt());
std::vector<ModInfo::EFlag> flags = info->getFlags();
+ { // insert conflict icon first to provide nicer alignment
+ auto iter = std::find_first_of(flags.begin(), flags.end(), m_ConflictFlags, m_ConflictFlags + 4);
+ if (iter != flags.end()) {
+ result.append(getFlagIcon(*iter));
+ flags.erase(iter);
+ } else {
+ result.append(QIcon());
+ }
+ }
+
for (auto iter = flags.begin(); iter != flags.end(); ++iter) {
result.append(getFlagIcon(*iter));
}
@@ -42,7 +57,12 @@ size_t ModFlagIconDelegate::getNumIcons(const QModelIndex &index) const unsigned int modIdx = index.data(Qt::UserRole + 1).toInt();
if (modIdx < ModInfo::getNumMods()) {
ModInfo::Ptr info = ModInfo::getByIndex(modIdx);
- return info->getFlags().size();
+ std::vector<ModInfo::EFlag> flags = info->getFlags();
+ int count = flags.size();
+ if (std::find_first_of(flags.begin(), flags.end(), m_ConflictFlags, m_ConflictFlags + 4) == flags.end()) {
+ ++count;
+ }
+ return count;
} else {
return 0;
}
|
