summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTheBloke <devnull@localhost>2014-07-11 01:46:42 +0100
committerTheBloke <devnull@localhost>2014-07-11 01:46:42 +0100
commit5d2b5202af6eb4dcd26767f1de0e219518b5e1f1 (patch)
tree343a0dc12aa563eaa5a0788b081f6ddd26979479 /src
parent8044ef4f1dccdaddf4d8fc55167826fc4740738b (diff)
- savegameList: Improved save game handling from MainWindow
-- Save game deletion now does Recycle Bin delete (wishlist #675) -- Save game deletion now also deletes .skse file (bug #687) -- Can select and delete multiple save games (ExtendedSelection) (wishlist #675) -- Uses new SaveGame->saveFiles() method to get filenames (eg .ess & .skse) -- Context menu - "Fix Mods.." option only appears if 1 save is selected -- Context menu - delete menu option labelled "Delete save" or "Delete saves", according to 1 or >1 saves selected. -- Context menu - delete menu confirmation shows list of all selected saves
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp58
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/mainwindow.ui6
3 files changed, 48 insertions, 18 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9cbe9c40..344173d4 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3884,26 +3884,42 @@ void MainWindow::on_categoriesList_itemSelectionChanged()
void MainWindow::deleteSavegame_clicked()
{
- QListWidgetItem *selectedItem = ui->savegameList->item(m_SelectedSaveGame);
- if (selectedItem == NULL) {
+ QItemSelectionModel *selection = ui->savegameList->selectionModel();
+
+ if (!selection->hasSelection())
return;
- }
- QString fileName = selectedItem->data(Qt::UserRole).toString();
+ int selectedCount = selection->selectedRows().count();
+ QString savesMsgLabel;
+ QRegExp saveSuffix(".ess$");
+ QStringList deleteFiles;
+
+ foreach (QModelIndex idx, selection->selectedRows()) {
+ QString name = idx.data().toString();
+ QString filename = idx.data(Qt::UserRole).toString();
+
+ SaveGame *save = new SaveGame(this, filename);
+ savesMsgLabel += "<li>" + name.replace(saveSuffix, "") + "</li>";
+ deleteFiles << save->saveFiles();
+ }
- if (QMessageBox::question(this, tr("Confirm"), tr("Really delete \"%1\"?").arg(selectedItem->text()),
+ if (QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to remove the following save%1?<br><ul>%2</ul><br>Removed saves will be sent to the Recycle Bin.")
+ .arg((selectedCount > 1) ? "s" : "")
+ .arg(savesMsgLabel),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
- shellDelete(QStringList() << fileName);
+ shellDelete(deleteFiles, true); // recycle bin delete.
}
}
void MainWindow::fixMods_clicked()
{
- QListWidgetItem *selectedItem = ui->savegameList->item(m_SelectedSaveGame);
- if (selectedItem == NULL) {
- return;
- }
+ QItemSelectionModel *selection = ui->savegameList->selectionModel();
+
+ if (!selection->hasSelection() || selection->selectedRows().count() > 1)
+ return; // Count should never be > 1 because of condition on context menu; check again just for safety.
+
+ QListWidgetItem *selectedItem = ui->savegameList->item(selection->selectedRows().first().row());
// if required, parse the save game
if (selectedItem->data(Qt::UserRole).isNull()) {
@@ -3994,16 +4010,24 @@ void MainWindow::fixMods_clicked()
void MainWindow::on_savegameList_customContextMenuRequested(const QPoint &pos)
{
- QListWidgetItem *selectedItem = ui->savegameList->itemAt(pos);
- if (selectedItem == NULL) {
- return;
- }
+ QItemSelection currentSelection = ui->savegameList->selectionModel()->selection();
+
+ bool enableFixMods = false;
+ int selectedCount = currentSelection.count();
- m_SelectedSaveGame = ui->savegameList->row(selectedItem);
+ if ( selectedCount == 0) {
+ return;
+ } else if (currentSelection.count() == 1)
+ enableFixMods = true;
QMenu menu;
- menu.addAction(tr("Fix Mods..."), this, SLOT(fixMods_clicked()));
- menu.addAction(tr("Delete"), this, SLOT(deleteSavegame_clicked()));
+
+ if (enableFixMods)
+ menu.addAction(tr("Fix Mods..."), this, SLOT(fixMods_clicked()));
+
+ QString deleteMenuLabel = tr("Delete save%1").arg((selectedCount > 1) ? "s" : "");
+
+ menu.addAction(deleteMenuLabel, this, SLOT(deleteSavegame_clicked()));
menu.exec(ui->savegameList->mapToGlobal(pos));
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index cc144287..c1cfdb3c 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -335,7 +335,7 @@ private:
QTreeWidgetItem *m_ContextItem;
QAction *m_ContextAction;
- int m_SelectedSaveGame;
+ //int m_SelectedSaveGame;
Settings m_Settings;
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 1a45e21b..4201babf 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -1100,6 +1100,12 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;If you click &amp;quot;Fix Mods...&amp;quot; in the context menu, MO will try to activate all mods and esps to fix those missing esps. It will not disable anything!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
</widget>
</item>
</layout>