From e0eb97922d5ef4a1448e76f13374ebfda7fda403 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 27 Mar 2013 20:48:33 +0100 Subject: - added hooks for getFileVersion* functions - automatic donwload retry - support for storing multiple download urls - improved "query info" functionality - some cleanup to download manager code - external fomod installer dialog are now brought to front - added shell... functions to have windows handle problematic situations - added visual clue when filters are active - esps are now automatically activated when installing a mod - added option to never endorse a mod - added "previous" and "next" buttons to mod info dialog - improved the way messagedialog text is shortened - coloring in mod info dialog now visible in other color schemes - plugin list is now saved automatically - vanilla bsas are now enabled even if they are not listed in the ini file - bugfix: setting mod to maximum now doesn't try to place the mod below overwrite --- src/pluginlist.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 25dc69bd..93f511a4 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -73,9 +73,11 @@ bool ByDate(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { } PluginList::PluginList(QObject *parent) - : QAbstractTableModel(parent), m_Modified(false), - m_FontMetrics(QFont()) + : QAbstractTableModel(parent), + m_FontMetrics(QFont()), m_SaveTimer(this) { + m_SaveTimer.setSingleShot(true); + connect(&m_SaveTimer, SIGNAL(timeout()), this, SIGNAL(saveTimer())); } @@ -192,7 +194,7 @@ void PluginList::enableESP(const QString &name) if (iter != m_ESPsByName.end()) { m_ESPs[iter->second].m_Enabled = true; - m_Modified = true; + startSaveTime(); } else { reportError(tr("esp not found: %1").arg(name)); } @@ -204,8 +206,7 @@ void PluginList::enableAll() for (std::vector::iterator iter = m_ESPs.begin(); iter != m_ESPs.end(); ++iter) { iter->m_Enabled = true; } - m_Modified = true; - emit esplist_changed(); + startSaveTime(); } @@ -216,8 +217,7 @@ void PluginList::disableAll() iter->m_Enabled = false; } } - m_Modified = true; - emit esplist_changed(); + startSaveTime(); } @@ -308,7 +308,7 @@ void PluginList::readEnabledFrom(const QString &fileName) m_ESPs[iter->second].m_Enabled = true; } else { qWarning("plugin %s not found", modName.toUtf8().constData()); - m_Modified = true; + startSaveTime(); } } } @@ -417,10 +417,6 @@ void PluginList::writeLockedOrder(const QString &fileName) const void PluginList::saveTo(const QString &pluginFileName, const QString &loadOrderFileName, const QString &lockedOrderFileName, const QString& deleterFileName, bool hideUnchecked) const { - if (!m_Modified) { - return; - } - writePlugins(pluginFileName, false); writePlugins(loadOrderFileName, true); writeLockedOrder(lockedOrderFileName); @@ -442,7 +438,7 @@ void PluginList::saveTo(const QString &pluginFileName, const QString &loadOrderF qDebug("%s saved", QDir::toNativeSeparators(deleterFileName).toUtf8().constData()); } - m_Modified = false; + m_SaveTimer.stop(); } @@ -508,8 +504,7 @@ void PluginList::lockESPIndex(int index, bool lock) m_LockedOrder.erase(iter); } } - m_Modified = true; - emit esplist_changed(); + startSaveTime(); } @@ -544,7 +539,7 @@ void PluginList::refreshLoadOrder() // locked esp exists // find the location to insert at - while ((targetPrio < static_cast(m_ESPs.size())) && + while ((targetPrio < static_cast(m_ESPs.size() - 1)) && (m_ESPs[m_ESPsByPriority[targetPrio]].m_LoadOrder < iter->first)) { if (QString::compare(m_ESPs[m_ESPsByPriority[targetPrio]].m_Name, iter->second) != 0) { ++targetPrio; @@ -555,7 +550,7 @@ void PluginList::refreshLoadOrder() setPluginPriority(nameIter->second, temp); m_ESPs[nameIter->second].m_LoadOrder = iter->first; syncLoadOrder(); - m_Modified = true; + startSaveTime(); } } } @@ -653,8 +648,7 @@ bool PluginList::setData(const QModelIndex &index, const QVariant &value, int ro emit layoutAboutToBeChanged(); refreshLoadOrder(); - m_Modified = true; - emit esplist_changed(); + startSaveTime(); emit layoutChanged(); return true; @@ -768,14 +762,20 @@ void PluginList::changePluginPriority(std::vector rows, int newPriority) } refreshLoadOrder(); - emit esplist_changed(); - - m_Modified = true; + startSaveTime(); emit layoutChanged(); } +void PluginList::startSaveTime() +{ + if (!m_SaveTimer.isActive()) { + m_SaveTimer.start(2000); + } +} + + bool PluginList::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int, const QModelIndex &parent) { if (action == Qt::IgnoreAction) { -- cgit v1.3.1