summaryrefslogtreecommitdiff
path: root/src/modlist.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-05-04 14:50:01 +0200
committerTannin <devnull@localhost>2014-05-04 14:50:01 +0200
commit6fb36d6c028d4fe88043c764e42b54df9b06f48b (patch)
tree8c23cfc17447d217d91eb170cffa5a6372f003b1 /src/modlist.cpp
parentea1f959ad592c1f10c5c60908e01c220aed206a5 (diff)
- main window now has a small view displaying log messages
- mod list will now be highlighted when grouping is active is active - download tooltip now supports bbcode markup in the description - bbcode translator will now translate some named colors - algorithm for detection of mod order problems is now more sophisticated - exposed more functionality to python plugins - updated to qt 4.8.6 dlls - bugfix: plugin list wasn't - bugfix: state changes in mod list wasn't always reported - bugfix: loot client will now create necessary directory - bugfix: NCC sometimes used wrong source path for extracting - bugfix: removed noisy debug message
Diffstat (limited to 'src/modlist.cpp')
-rw-r--r--src/modlist.cpp61
1 files changed, 41 insertions, 20 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp
index 836406e4..25b0eb52 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -375,20 +375,23 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role)
int modID = index.row();
+ ModInfo::Ptr info = ModInfo::getByIndex(modID);
+ IModList::ModStates oldState = state(modID);
+
+ bool result = false;
+
if (role == Qt::CheckStateRole) {
bool enabled = value.toInt() == Qt::Checked;
if (m_Profile->modEnabled(modID) != enabled) {
m_Profile->setModEnabled(modID, enabled);
m_Modified = true;
-
emit modlist_changed(index, role);
}
- return true;
+ result = true;
} else if (role == Qt::EditRole) {
- bool res = false;
switch (index.column()) {
case COL_NAME: {
- res = renameMod(modID, value.toString());
+ result = renameMod(modID, value.toString());
} break;
case COL_PRIORITY: {
bool ok = false;
@@ -397,47 +400,55 @@ bool ModList::setData(const QModelIndex &index, const QVariant &value, int role)
m_Profile->setModPriority(modID, newPriority);
emit modlist_changed(index, role);
- res = true;
+ result = true;
} else {
- res = false;
+ result = false;
}
} break;
case COL_MODID: {
- ModInfo::Ptr info = ModInfo::getByIndex(modID);
bool ok = false;
int newID = value.toInt(&ok);
if (ok) {
info->setNexusID(newID);
emit modlist_changed(index, role);
- res = true;
+ result = true;
} else {
- res = false;
+ result = false;
}
} break;
case COL_VERSION: {
- ModInfo::Ptr info = ModInfo::getByIndex(modID);
VersionInfo::VersionScheme scheme = info->getVersion().scheme();
VersionInfo version(value.toString(), scheme);
if (version.isValid()) {
info->setVersion(version);
- res = true;
+ result = true;
} else {
- res = false;
+ result = false;
}
} break;
default: {
qWarning("edit on column \"%s\" not supported",
getColumnName(index.column()).toUtf8().constData());
- res = false;
+ result = false;
} break;
}
- if (res) {
+ if (result) {
emit dataChanged(index, index);
}
- return res;
- } else {
- return false;
}
+
+ IModList::ModStates newState = state(modID);
+ if (oldState != newState) {
+ try {
+ m_ModStateChanged(info->name(), newState);
+ } catch (const std::exception &e) {
+ qCritical("failed to invoke state changed notification: %s", e.what());
+ } catch (...) {
+ qCritical("failed to invoke state changed notification: unknown exception");
+ }
+ }
+
+ return result;
}
@@ -578,10 +589,9 @@ void ModList::modInfoChanged(ModInfo::Ptr info)
}
}
-IModList::ModStates ModList::state(const QString &name) const
+IModList::ModStates ModList::state(unsigned int modIndex) const
{
- ModStates result;
- unsigned int modIndex = ModInfo::getIndex(name);
+ IModList::ModStates result;
if (modIndex != UINT_MAX) {
result |= IModList::STATE_EXISTS;
ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex);
@@ -605,6 +615,13 @@ IModList::ModStates ModList::state(const QString &name) const
return result;
}
+IModList::ModStates ModList::state(const QString &name) const
+{
+ unsigned int modIndex = ModInfo::getIndex(name);
+
+ return state(modIndex);
+}
+
int ModList::priority(const QString &name) const
{
unsigned int modIndex = ModInfo::getIndex(name);
@@ -744,6 +761,8 @@ void ModList::removeRowForce(int row)
}
if (m_Profile == NULL) return;
+ m_Profile->setModEnabled(row, false);
+
ModInfo::Ptr modInfo = ModInfo::getByIndex(row);
bool wasEnabled = m_Profile->modEnabled(row);
@@ -770,6 +789,8 @@ void ModList::removeRow(int row, const QModelIndex&)
}
if (m_Profile == NULL) return;
+ m_Profile->setModEnabled(row, false);
+
ModInfo::Ptr modInfo = ModInfo::getByIndex(row);
if (!modInfo->isRegular()) return;