summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAl12rs <gabriel.cortesi@outlook.com>2018-07-17 00:49:41 +0200
committerAl12rs <gabriel.cortesi@outlook.com>2018-07-17 00:49:41 +0200
commit872c33fe5592eb84a2f6c01a2e47b72602b6139e (patch)
treeed0b5d3203500b15a55801a009a0fec680b4a6db /src
parent9ddb26ea5100581c832920015f79de8d7366463f (diff)
Added new "Hide Uninstalled" and "Delete Uninstalled" options to downloads tab.
Diffstat (limited to 'src')
-rw-r--r--src/downloadlistwidget.cpp20
-rw-r--r--src/downloadlistwidget.h2
-rw-r--r--src/downloadlistwidgetcompact.cpp20
-rw-r--r--src/downloadlistwidgetcompact.h2
-rw-r--r--src/downloadmanager.cpp8
5 files changed, 51 insertions, 1 deletions
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp
index 1a401d10..ad694107 100644
--- a/src/downloadlistwidget.cpp
+++ b/src/downloadlistwidget.cpp
@@ -310,6 +310,15 @@ void DownloadListWidgetDelegate::issueDeleteCompleted()
}
}
+void DownloadListWidgetDelegate::issueDeleteUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Delete Files?"),
+ tr("This will remove all uninstalled downloads from this list and from disk."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, true);
+ }
+}
+
void DownloadListWidgetDelegate::issueRemoveFromViewAll()
{
if (QMessageBox::question(nullptr, tr("Are you sure?"),
@@ -328,6 +337,15 @@ void DownloadListWidgetDelegate::issueRemoveFromViewCompleted()
}
}
+void DownloadListWidgetDelegate::issueRemoveFromViewUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Are you sure?"),
+ tr("This will remove all uninstalled downloads from this list (but NOT from disk)."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, false);
+ }
+}
+
bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option, const QModelIndex &index)
{
@@ -380,11 +398,13 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *
menu.addSeparator();
}
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
+ menu.addAction(tr("Delete Uninstalled..."), this, SLOT(issueDeleteUninstalled()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
if (!hidden) {
menu.addSeparator();
menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
+ menu.addAction(tr("Hide Uninstalled..."), this, SLOT(issueRemoveFromViewUninstalled()));
menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
}
if (hidden) {
diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h
index 4dcbea99..2dd73e73 100644
--- a/src/downloadlistwidget.h
+++ b/src/downloadlistwidget.h
@@ -99,8 +99,10 @@ private slots:
void issueResume();
void issueDeleteAll();
void issueDeleteCompleted();
+ void issueDeleteUninstalled();
void issueRemoveFromViewAll();
void issueRemoveFromViewCompleted();
+ void issueRemoveFromViewUninstalled();
void issueQueryInfo();
void stateChanged(int row, DownloadManager::DownloadState);
diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp
index ad9e0994..34e31006 100644
--- a/src/downloadlistwidgetcompact.cpp
+++ b/src/downloadlistwidgetcompact.cpp
@@ -292,6 +292,15 @@ void DownloadListWidgetCompactDelegate::issueDeleteCompleted()
}
}
+void DownloadListWidgetCompactDelegate::issueDeleteUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Are you sure?"),
+ tr("This will remove all uninstalled downloads from this list and from disk."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, true);
+ }
+}
+
void DownloadListWidgetCompactDelegate::issueRemoveFromViewAll()
{
if (QMessageBox::question(nullptr, tr("Are you sure?"),
@@ -310,6 +319,15 @@ void DownloadListWidgetCompactDelegate::issueRemoveFromViewCompleted()
}
}
+void DownloadListWidgetCompactDelegate::issueRemoveFromViewUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Are you sure?"),
+ tr("This will permanently remove all uninstalled downloads from this list (but NOT from disk)."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, false);
+ }
+}
+
bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option, const QModelIndex &index)
@@ -359,10 +377,12 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem
menu.addSeparator();
}
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
+ menu.addAction(tr("Delete Uninstalled..."), this, SLOT(issueDeleteUninstalled()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
if (!hidden) {
menu.addSeparator();
menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
+ menu.addAction(tr("Hide Uninstalled..."), this, SLOT(issueRemoveFromViewUninstalled()));
menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
}
if (hidden) {
diff --git a/src/downloadlistwidgetcompact.h b/src/downloadlistwidgetcompact.h
index 1fcab3e6..b1b3c617 100644
--- a/src/downloadlistwidgetcompact.h
+++ b/src/downloadlistwidgetcompact.h
@@ -98,8 +98,10 @@ private slots:
void issueResume();
void issueDeleteAll();
void issueDeleteCompleted();
+ void issueDeleteUninstalled();
void issueRemoveFromViewAll();
void issueRemoveFromViewCompleted();
+ void issueRemoveFromViewUninstalled();
void issueQueryInfo();
void stateChanged(int row, DownloadManager::DownloadState);
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 1a2934a5..0c83bf92 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -690,7 +690,13 @@ void DownloadManager::removeDownload(int index, bool deleteFile)
emit aboutToUpdate();
if (index < 0) {
- DownloadState minState = index == -1 ? STATE_READY : STATE_INSTALLED;
+ DownloadState minState;
+ if (index == -3) {
+ minState = STATE_UNINSTALLED;
+ }
+ else
+ minState = index == -1 ? STATE_READY : STATE_INSTALLED;
+
index = 0;
for (QVector<DownloadInfo*>::iterator iter = m_ActiveDownloads.begin(); iter != m_ActiveDownloads.end();) {
if ((*iter)->m_State >= minState) {