diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-09-27 15:20:02 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-09-27 15:20:02 -0400 |
| commit | 51d664d76ce6b611e7a7585b209bad9d68fe65d7 (patch) | |
| tree | bfb235aab1f5c7b5cd6a8622739a166ad5f1c4fa /src/modflagicondelegate.cpp | |
| parent | 5d74bd3789515a3e04e54267f1cdfe8f5397f6df (diff) | |
moved color stuff to ColorTable, now shows sample text and icons
Diffstat (limited to 'src/modflagicondelegate.cpp')
| -rw-r--r-- | src/modflagicondelegate.cpp | 112 |
1 files changed, 61 insertions, 51 deletions
diff --git a/src/modflagicondelegate.cpp b/src/modflagicondelegate.cpp index 7110a590..a5e9aa22 100644 --- a/src/modflagicondelegate.cpp +++ b/src/modflagicondelegate.cpp @@ -31,72 +31,82 @@ void ModFlagIconDelegate::columnResized(int logicalIndex, int, int newSize) }
}
-QList<QString> ModFlagIconDelegate::getIcons(const QModelIndex &index) const {
+QList<QString> ModFlagIconDelegate::getIconsForFlags(
+ std::vector<ModInfo::EFlag> flags, bool compact)
+{
QList<QString> result;
- QVariant modid = index.data(Qt::UserRole + 1);
- if (modid.isValid()) {
- ModInfo::Ptr info = ModInfo::getByIndex(modid.toInt());
- std::vector<ModInfo::EFlag> flags = info->getFlags();
- // Don't do flags for overwrite
- if (std::find(flags.begin(), flags.end(),ModInfo::FLAG_OVERWRITE) != flags.end())
- return result;
+ // Don't do flags for overwrite
+ if (std::find(flags.begin(), flags.end(),ModInfo::FLAG_OVERWRITE) != 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(),
- m_ConflictFlags, m_ConflictFlags + 4);
- if (iter != flags.end()) {
- result.append(getFlagIcon(*iter));
- flags.erase(iter);
- } else if (!m_Compact) {
- result.append(QString());
- }
+ // insert conflict icons to provide nicer alignment
+ { // insert loose file conflicts first
+ 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 if (!compact) {
+ result.append(QString());
}
+ }
- { // insert loose vs archive overwrite second
- auto iter = std::find(flags.begin(), flags.end(),
- ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE);
- if (iter != flags.end()) {
- result.append(getFlagIcon(*iter));
- flags.erase(iter);
- } else if (!m_Compact) {
- result.append(QString());
- }
+ { // insert loose vs archive overwrite second
+ auto iter = std::find(flags.begin(), flags.end(),
+ ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE);
+ if (iter != flags.end()) {
+ result.append(getFlagIcon(*iter));
+ flags.erase(iter);
+ } else if (!compact) {
+ result.append(QString());
}
+ }
- { // insert loose vs archive overwritten third
- auto iter = std::find_first_of(flags.begin(), flags.end(),
- m_ArchiveLooseConflictFlags + 1, m_ArchiveLooseConflictFlags + 2);
- if (iter != flags.end()) {
- result.append(getFlagIcon(*iter));
- flags.erase(iter);
- } else if (!m_Compact) {
- result.append(QString());
- }
+ { // insert loose vs archive overwritten third
+ auto iter = std::find_first_of(flags.begin(), flags.end(),
+ m_ArchiveLooseConflictFlags + 1, m_ArchiveLooseConflictFlags + 2);
+ if (iter != flags.end()) {
+ result.append(getFlagIcon(*iter));
+ flags.erase(iter);
+ } else if (!compact) {
+ result.append(QString());
}
+ }
- { // insert archive conflicts last
- auto iter = std::find_first_of(flags.begin(), flags.end(),
- m_ArchiveConflictFlags, m_ArchiveConflictFlags + 3);
- if (iter != flags.end()) {
- result.append(getFlagIcon(*iter));
- flags.erase(iter);
- } else if (!m_Compact) {
- result.append(QString());
- }
+ { // insert archive conflicts last
+ auto iter = std::find_first_of(flags.begin(), flags.end(),
+ m_ArchiveConflictFlags, m_ArchiveConflictFlags + 3);
+ if (iter != flags.end()) {
+ result.append(getFlagIcon(*iter));
+ flags.erase(iter);
+ } else if (!compact) {
+ result.append(QString());
}
+ }
- for (auto iter = flags.begin(); iter != flags.end(); ++iter) {
- auto iconPath = getFlagIcon(*iter);
- if (!iconPath.isEmpty())
- result.append(iconPath);
- }
+ for (auto iter = flags.begin(); iter != flags.end(); ++iter) {
+ auto iconPath = getFlagIcon(*iter);
+ if (!iconPath.isEmpty())
+ result.append(iconPath);
}
+
return result;
}
-QString ModFlagIconDelegate::getFlagIcon(ModInfo::EFlag flag) const
+QList<QString> ModFlagIconDelegate::getIcons(const QModelIndex &index) const
+{
+ QVariant modid = index.data(Qt::UserRole + 1);
+
+ if (modid.isValid()) {
+ ModInfo::Ptr info = ModInfo::getByIndex(modid.toInt());
+ return getIconsForFlags(info->getFlags(), m_Compact);
+ }
+
+ return {};
+}
+
+QString ModFlagIconDelegate::getFlagIcon(ModInfo::EFlag flag)
{
switch (flag) {
case ModInfo::FLAG_BACKUP: return QStringLiteral(":/MO/gui/emblem_backup");
|
