diff options
| author | Tannin <devnull@localhost> | 2013-05-25 12:24:48 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-05-25 12:24:48 +0200 |
| commit | 16bda49e0667f77f4ebe1d8fa2682abf57aa6765 (patch) | |
| tree | 457f8dea0e452b194dca9bd0e30a6891700376ad /src | |
| parent | daf8bab1367334bb7f2332d4256f31c9db5ecec8 (diff) | |
- bugfix: mod priority ordering could become incorrect
- bugfix: when grouping is enabled, newly installed mods broke grouping
- bugfix: syncing overwrite didn't clean up emptied directory
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 39 | ||||
| -rw-r--r-- | src/overwriteinfodialog.ui | 7 | ||||
| -rw-r--r-- | src/qtgroupingproxy.cpp | 7 | ||||
| -rw-r--r-- | src/qtgroupingproxy.h | 1 | ||||
| -rw-r--r-- | src/shared/directoryentry.cpp | 6 | ||||
| -rw-r--r-- | src/syncoverwritedialog.cpp | 24 | ||||
| -rw-r--r-- | src/syncoverwritedialog.h | 2 |
7 files changed, 61 insertions, 25 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cf7ed487..9c0559c7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2191,9 +2191,6 @@ void MainWindow::modStatusChanged(unsigned int index) ModInfo::Ptr modInfo = ModInfo::getByIndex(index); if (m_CurrentProfile->modEnabled(index)) { DirectoryRefresher::addModToStructure(m_DirectoryStructure, modInfo->name(), m_CurrentProfile->getModPriority(index), modInfo->absolutePath()); -/* m_DirectoryStructure->addFromOrigin(ToWString(modInfo->name()), - ToWString(QDir::toNativeSeparators(modInfo->absolutePath())), - m_CurrentProfile->getModPriority(index));*/ DirectoryRefresher::cleanStructure(m_DirectoryStructure); } else { if (m_DirectoryStructure->originExists(ToWString(modInfo->name()))) { @@ -2201,6 +2198,16 @@ void MainWindow::modStatusChanged(unsigned int index) origin.enable(false); } } + + for (unsigned int i = 0; i < m_CurrentProfile->numMods(); ++i) { + ModInfo::Ptr modInfo = ModInfo::getByIndex(i); + int priority = m_CurrentProfile->getModPriority(i); + if (m_DirectoryStructure->originExists(ToWString(modInfo->name()))) { + m_DirectoryStructure->getOriginByName(ToWString(modInfo->name())).setPriority(priority); + } + } + m_DirectoryStructure->getFileRegister()->sortOrigins(); + refreshLists(); } catch (const std::exception& e) { reportError(tr("failed to update mod list: %1").arg(e.what())); @@ -2485,11 +2492,15 @@ void MainWindow::modlistChanged(const QModelIndex &index, int role) m_PluginList.enableESP(esm); } + int enabled = 0; QStringList esps = dir.entryList(QStringList("*.esp"), QDir::Files); foreach (const QString &esp, esps) { - m_PluginList.enableESP(esp); + if (!m_PluginList.isEnabled(esp)) { + m_PluginList.enableESP(esp); + ++enabled; + } } - if (esps.count() > 1) { + if (enabled > 1) { MessageDialog::showMessage(tr("Multiple esps activated, please check that they don't conflict."), this); } } @@ -2628,9 +2639,6 @@ void MainWindow::displayModInformation(ModInfo::Ptr modInfo, unsigned int index, FilesOrigin& origin = m_DirectoryStructure->getOriginByName(ToWString(modInfo->name())); origin.enable(false); -/* m_DirectoryStructure->addFromOrigin(ToWString(modInfo->name()), - ToWString(QDir::toNativeSeparators(modInfo->absolutePath())), - m_CurrentProfile->getModPriority(index));*/ DirectoryRefresher::addModToStructure(m_DirectoryStructure, modInfo->name(), m_CurrentProfile->getModPriority(index), modInfo->absolutePath()); @@ -2694,6 +2702,7 @@ void MainWindow::displayModInformation(const QString &modName, int tab) void MainWindow::displayModInformation(int row, int tab) { ModInfo::Ptr modInfo = ModInfo::getByIndex(row); +qDebug("%d - %s", row, qPrintable(modInfo->name())); displayModInformation(modInfo, row, tab); } @@ -2840,7 +2849,6 @@ void MainWindow::on_modList_doubleClicked(const QModelIndex &index) if (!index.isValid()) { return; } -// QModelIndex sourceIdx = m_ModListGroupProxy->mapToSource(index); QModelIndex sourceIdx = mapToModel(&m_ModList, index); if (!sourceIdx.isValid()) { return; @@ -2870,8 +2878,7 @@ bool MainWindow::addCategories(QMenu *menu, int targetID) if (m_CategoryFactory.getParentID(i) == targetID) { QMenu *targetMenu = menu; if (m_CategoryFactory.hasChildren(i)) { - targetMenu = menu->addMenu( - m_CategoryFactory.getCategoryName(i).replace('&', "&&")); + targetMenu = menu->addMenu(m_CategoryFactory.getCategoryName(i).replace('&', "&&")); } int id = m_CategoryFactory.getCategoryID(i); @@ -2902,6 +2909,7 @@ bool MainWindow::addCategories(QMenu *menu, int targetID) void MainWindow::saveCategoriesFromMenu(QMenu *menu, int modRow) { ModInfo::Ptr modInfo = ModInfo::getByIndex(modRow); +qDebug("%d - %s", modRow, qPrintable(modInfo->name())); foreach (QAction* action, menu->actions()) { if (action->menu() != NULL) { saveCategoriesFromMenu(action->menu(), modRow); @@ -2909,8 +2917,8 @@ void MainWindow::saveCategoriesFromMenu(QMenu *menu, int modRow) QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(action); if (widgetAction != NULL) { QCheckBox *checkbox = qobject_cast<QCheckBox*>(widgetAction->defaultWidget()); +qDebug("%s - %d", qPrintable(modInfo->name()), widgetAction->data().toInt()); modInfo->setCategory(widgetAction->data().toInt(), checkbox->isChecked()); -// m_ModList.setModCategory(modRow, widgetAction->data().toInt(), checkbox->isChecked()); } } } @@ -2924,7 +2932,6 @@ void MainWindow::saveCategories() qCritical("not a menu?"); return; } -// m_ModList.resetCategories(m_ContextRow); QModelIndexList selected = ui->modList->selectionModel()->selectedRows(); if (selected.size() > 0) { @@ -4256,18 +4263,14 @@ void MainWindow::on_groupCombo_currentIndexChanged(int index) newModel = NULL; } break; } + if (newModel != NULL) { -// newModel->setSourceModel(m_ModListSortProxy); m_ModListSortProxy->setSourceModel(newModel); connect(ui->modList, SIGNAL(expanded(QModelIndex)),newModel, SLOT(expanded(QModelIndex))); connect(ui->modList, SIGNAL(collapsed(QModelIndex)), newModel, SLOT(collapsed(QModelIndex))); connect(newModel, SIGNAL(expandItem(QModelIndex)), ui->modList, SLOT(expand(QModelIndex))); -// ui->modList->setModel(newModel); } else { m_ModListSortProxy->setSourceModel(&m_ModList); -// ui->modList->setModel(m_ModListSortProxy); } -// ui->modList->setModel(m_ModListSortProxy); - // ui->modList->setSelectionMode(QAbstractItemView::ExtendedSelection); } diff --git a/src/overwriteinfodialog.ui b/src/overwriteinfodialog.ui index c6119ca6..2c194ecf 100644 --- a/src/overwriteinfodialog.ui +++ b/src/overwriteinfodialog.ui @@ -34,6 +34,13 @@ </widget>
</item>
<item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>You can use drag&drop to move files and directories to regular mods.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/qtgroupingproxy.cpp b/src/qtgroupingproxy.cpp index 4e066f65..3ecb2a72 100644 --- a/src/qtgroupingproxy.cpp +++ b/src/qtgroupingproxy.cpp @@ -57,6 +57,7 @@ QtGroupingProxy::QtGroupingProxy(QAbstractItemModel *model, QModelIndex rootNode connect( sourceModel(), SIGNAL(layoutChanged()), SLOT(buildTree()) );
connect( sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
SLOT(modelDataChanged(QModelIndex,QModelIndex)) );
+ connect( sourceModel(), SIGNAL(modelReset()), this, SLOT(resetModel()) );
if( groupedColumn != -1 )
setGroupedColumn( groupedColumn );
@@ -985,6 +986,12 @@ QtGroupingProxy::modelRowsRemoved( const QModelIndex &parent, int start, int end }
void
+QtGroupingProxy::resetModel()
+{
+ buildTree();
+}
+
+void
QtGroupingProxy::modelDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight )
{
//TODO: need to look in the groupedColumn and see if it changed and changed grouping accordingly
diff --git a/src/qtgroupingproxy.h b/src/qtgroupingproxy.h index e09ae7b4..7df069f7 100644 --- a/src/qtgroupingproxy.h +++ b/src/qtgroupingproxy.h @@ -103,6 +103,7 @@ private slots: void modelRowsInserted( const QModelIndex &, int, int );
void modelRowsAboutToBeRemoved( const QModelIndex &, int ,int );
void modelRowsRemoved( const QModelIndex &, int, int );
+ void resetModel();
protected:
/** Maps an item to a group.
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp index abf9affb..9958b934 100644 --- a/src/shared/directoryentry.cpp +++ b/src/shared/directoryentry.cpp @@ -192,7 +192,6 @@ void FileEntry::addOrigin(int origin, FILETIME fileTime, const std::wstring &arc m_Origin = origin;
m_FileTime = fileTime;
m_Archive = archive;
-// } else if (FilesOrigin::getByID(origin).getPriority() > FilesOrigin::getByID(m_Origin).getPriority()) {
} else if (m_Parent->getOriginByID(origin).getPriority() > m_Parent->getOriginByID(m_Origin).getPriority()) {
if (std::find(m_Alternatives.begin(), m_Alternatives.end(), m_Origin) == m_Alternatives.end()) {
m_Alternatives.push_back(m_Origin);
@@ -269,7 +268,10 @@ bool FileEntry::removeOrigin(int origin) // sorted by priority descending
static bool ByOriginPriority(DirectoryEntry *entry, int LHS, int RHS)
{
- return entry->getOriginByID(LHS).getPriority() < entry->getOriginByID(RHS).getPriority();
+ int l = entry->getOriginByID(LHS).getPriority(); if (l < 0) l = INT_MAX;
+ int r = entry->getOriginByID(RHS).getPriority(); if (r < 0) r = INT_MAX;
+
+ return l < r;
}
diff --git a/src/syncoverwritedialog.cpp b/src/syncoverwritedialog.cpp index aae0fd7c..be9d06c2 100644 --- a/src/syncoverwritedialog.cpp +++ b/src/syncoverwritedialog.cpp @@ -37,7 +37,7 @@ SyncOverwriteDialog::SyncOverwriteDialog(const QString &path, DirectoryEntry *di ui(new Ui::SyncOverwriteDialog), m_SourcePath(path), m_DirectoryStructure(directoryStructure) { ui->setupUi(this); - refresh(path, directoryStructure); + refresh(path); QHeaderView *headerView = ui->syncTree->header(); #if QT_VERSION >= 0x050000 @@ -56,6 +56,14 @@ SyncOverwriteDialog::~SyncOverwriteDialog() } +static void addToComboBox(QComboBox *box, const QString &name, const QVariant &userData) +{ + if (QString::compare(name, "overwrite", Qt::CaseInsensitive) != 0) { + box->addItem(name, userData); + } +} + + void SyncOverwriteDialog::readTree(const QString &path, DirectoryEntry *directoryStructure, QTreeWidgetItem *subTree) { QDir overwrite(path); @@ -86,9 +94,12 @@ void SyncOverwriteDialog::readTree(const QString &path, DirectoryEntry *director QComboBox* combo = new QComboBox(ui->syncTree); combo->addItem(tr("<don't sync>"), -1); if (entry != NULL) { + bool ignore; + int origin = entry->getOrigin(ignore); + addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(origin).getName()), origin); const std::vector<int> &alternatives = entry->getAlternatives(); for (std::vector<int>::const_iterator iter = alternatives.begin(); iter != alternatives.end(); ++iter) { - combo->addItem(ToQString(m_DirectoryStructure->getOriginByID(*iter).getName()), *iter); + addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(*iter).getName()), *iter); } combo->setCurrentIndex(combo->count() - 1); } else { @@ -103,10 +114,10 @@ void SyncOverwriteDialog::readTree(const QString &path, DirectoryEntry *director } -void SyncOverwriteDialog::refresh(const QString &path, DirectoryEntry *directoryStructure) +void SyncOverwriteDialog::refresh(const QString &path) { QTreeWidgetItem *rootItem = new QTreeWidgetItem(ui->syncTree, QStringList("<data>")); - readTree(path, directoryStructure, rootItem); + readTree(path, m_DirectoryStructure, rootItem); ui->syncTree->addTopLevelItem(rootItem); ui->syncTree->expandAll(); } @@ -141,6 +152,11 @@ void SyncOverwriteDialog::applyTo(QTreeWidgetItem *item, const QString &path, co } } } + + QDir dir(m_SourcePath + "/" + path); + if ((path.length() > 0) && (dir.count() == 2)) { + dir.rmpath("."); + } } diff --git a/src/syncoverwritedialog.h b/src/syncoverwritedialog.h index da7c8cf5..74c9a58f 100644 --- a/src/syncoverwritedialog.h +++ b/src/syncoverwritedialog.h @@ -40,7 +40,7 @@ public: void apply(const QString &modDirectory); private: - void refresh(const QString &path, MOShared::DirectoryEntry *directoryStructure); + void refresh(const QString &path); void readTree(const QString &path, MOShared::DirectoryEntry *directoryStructure, QTreeWidgetItem *subTree); void applyTo(QTreeWidgetItem *item, const QString &path, const QString &modDirectory); |
