diff options
Diffstat (limited to 'src/modlist.cpp')
| -rw-r--r-- | src/modlist.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp index 66bc66b4..3f46b85f 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -166,25 +166,29 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return QVariant(); } } else if (column == COL_CATEGORY) { - int category = modInfo->getPrimaryCategory(); - if (category != -1) { - CategoryFactory &categoryFactory = CategoryFactory::instance(); - if (categoryFactory.categoryExists(category)) { - try { - int categoryIdx = categoryFactory.getCategoryIndex(category); - return categoryFactory.getCategoryName(categoryIdx); - } catch (const std::exception &e) { - qCritical("failed to retrieve category name: %s", e.what()); + if (modInfo->hasFlag(ModInfo::FLAG_FOREIGN)) { + return tr("Non-MO"); + } else { + int category = modInfo->getPrimaryCategory(); + if (category != -1) { + CategoryFactory &categoryFactory = CategoryFactory::instance(); + if (categoryFactory.categoryExists(category)) { + try { + int categoryIdx = categoryFactory.getCategoryIndex(category); + return categoryFactory.getCategoryName(categoryIdx); + } catch (const std::exception &e) { + qCritical("failed to retrieve category name: %s", e.what()); + return QString(); + } + } else { + qWarning("category %d doesn't exist (may have been removed)", category); + modInfo->setCategory(category, false); return QString(); } } else { - qWarning("category %d doesn't exist (may have been removed)", category); - modInfo->setCategory(category, false); - return QString(); + //return tr("None"); + return QVariant(); } - } else { - //return tr("None"); - return QVariant(); } } else if (column == COL_INSTALLTIME) { // display installation time for mods that can be updated @@ -253,6 +257,8 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const if (modInfo->getHighlight() & ModInfo::HIGHLIGHT_INVALID) { result.setItalic(true); } + } else if ((column == COL_CATEGORY) && (modInfo->hasFlag(ModInfo::FLAG_FOREIGN))) { + result.setItalic(true); } else if (column == COL_VERSION) { if (modInfo->updateAvailable() || modInfo->downgradeAvailable()) { result.setWeight(QFont::Bold); @@ -547,7 +553,9 @@ void ModList::changeModPriority(std::vector<int> sourceIndices, int newPriority) for (std::vector<int>::const_iterator iter = sourceIndices.begin(); iter != sourceIndices.end(); ++iter) { + int oldPriority = m_Profile->getModPriority(*iter); m_Profile->setModPriority(*iter, newPriority); + m_ModMoved(ModInfo::getByIndex(*iter)->name(), oldPriority, newPriority); } emit layoutChanged(); @@ -648,13 +656,18 @@ bool ModList::setPriority(const QString &name, int newPriority) } } - bool ModList::onModStateChanged(const std::function<void (const QString &, IModList::ModStates)> &func) { auto conn = m_ModStateChanged.connect(func); return conn.connected(); } +bool ModList::onModMoved(const std::function<void (const QString &, int, int)> &func) +{ + auto conn = m_ModMoved.connect(func); + return conn.connected(); +} + bool ModList::dropURLs(const QMimeData *mimeData, int row, const QModelIndex &parent) { QStringList source; |
