summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAl12rs <gabriel.cortesi@outlook.com>2018-05-21 01:27:13 +0200
committerAl12rs <gabriel.cortesi@outlook.com>2018-05-21 01:27:13 +0200
commit186f26b71e4597e9999a3d946b0d9497255fc986 (patch)
tree826b2accfffa4c3eb78baa58de4e8cdbd32eac60 /src
parent6d6444c126c59c4307873755b08fc5773b3d3955 (diff)
Added un-hide all option to downlods tab.
Improved performace when hiding/unhiding. There is still room for improvement for hiding but it requires refactoring the function
Diffstat (limited to 'src')
-rw-r--r--src/downloadlistwidget.cpp24
-rw-r--r--src/downloadlistwidget.h1
-rw-r--r--src/downloadlistwidgetcompact.cpp22
-rw-r--r--src/downloadlistwidgetcompact.h1
-rw-r--r--src/downloadmanager.cpp40
5 files changed, 64 insertions, 24 deletions
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp
index 94394778..d7bd01bb 100644
--- a/src/downloadlistwidget.cpp
+++ b/src/downloadlistwidget.cpp
@@ -255,9 +255,15 @@ void DownloadListWidgetDelegate::issueRemoveFromView()
void DownloadListWidgetDelegate::issueRestoreToView()
{
- emit restoreDownload(m_ContextRow);
+ emit restoreDownload(m_ContextRow);
}
+void DownloadListWidgetDelegate::issueRestoreToViewAll()
+{
+ emit restoreDownload(-1);
+}
+
+
void DownloadListWidgetDelegate::issueCancel()
{
emit cancelDownload(m_ContextRow);
@@ -353,11 +359,17 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *
}
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
- if (!hidden) {
- menu.addSeparator();
- menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
- menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
- }
+
+ if (!hidden) {
+ menu.addSeparator();
+ menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
+ menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
+ }
+ if (hidden) {
+ menu.addSeparator();
+ menu.addAction(tr("Un-Hide All..."), this, SLOT(issueRestoreToViewAll()));
+ }
+
menu.exec(mouseEvent->globalPos());
event->accept();
diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h
index 62f21837..6e628cc7 100644
--- a/src/downloadlistwidget.h
+++ b/src/downloadlistwidget.h
@@ -89,6 +89,7 @@ private slots:
void issueDelete();
void issueRemoveFromView();
void issueRestoreToView();
+ void issueRestoreToViewAll();
void issueCancel();
void issuePause();
void issueResume();
diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp
index 898d400a..97e3655b 100644
--- a/src/downloadlistwidgetcompact.cpp
+++ b/src/downloadlistwidgetcompact.cpp
@@ -219,9 +219,15 @@ void DownloadListWidgetCompactDelegate::issueRemoveFromView()
void DownloadListWidgetCompactDelegate::issueRestoreToView()
{
- emit restoreDownload(m_ContextIndex.row());
+ emit restoreDownload(m_ContextIndex.row());
}
+void DownloadListWidgetCompactDelegate::issueRestoreToViewAll()
+{
+ emit restoreDownload(-1);
+}
+
+
void DownloadListWidgetCompactDelegate::issueCancel()
{
emit cancelDownload(m_ContextIndex.row());
@@ -318,11 +324,15 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem
}
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
- if (!hidden) {
- menu.addSeparator();
- menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
- menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
- }
+ if (!hidden) {
+ menu.addSeparator();
+ menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
+ menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
+ }
+ if (hidden) {
+ menu.addSeparator();
+ menu.addAction(tr("Un-Hide All..."), this, SLOT(issueRestoreToViewAll()));
+ }
menu.exec(mouseEvent->globalPos());
event->accept();
diff --git a/src/downloadlistwidgetcompact.h b/src/downloadlistwidgetcompact.h
index bf855d5f..df1a5f58 100644
--- a/src/downloadlistwidgetcompact.h
+++ b/src/downloadlistwidgetcompact.h
@@ -87,6 +87,7 @@ private slots:
void issueDelete();
void issueRemoveFromView();
void issueRestoreToView();
+ void issueRestoreToViewAll();
void issueCancel();
void issuePause();
void issueResume();
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 6cd86ece..93a46d78 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -645,22 +645,38 @@ void DownloadManager::refreshAlphabeticalTranslation()
void DownloadManager::restoreDownload(int index)
{
- if ((index < 0) || (index >= m_ActiveDownloads.size())) {
- throw MyException(tr("restore: invalid download index: %1").arg(index));
- }
- DownloadInfo *download = m_ActiveDownloads.at(index);
- download->m_Hidden = false;
+ if (index < 0) {
+ DownloadState minState = STATE_READY ;
+ index = 0;
- QString filePath = m_OutputDirectory + "/" + download->m_FileName;
+ for (QVector<DownloadInfo*>::const_iterator iter = m_ActiveDownloads.begin(); iter != m_ActiveDownloads.end(); ++iter ) {
+
+ if ((*iter)->m_State >= minState) {
+ restoreDownload(index);
+ }
+ index++;
+ }
+ }
+ else {
+ if (index >= m_ActiveDownloads.size()) {
+ throw MyException(tr("restore: invalid download index: %1").arg(index));
+ }
- //avoid dirWatcher triggering refreshes
- startDisableDirWatcher();
+ DownloadInfo *download = m_ActiveDownloads.at(index);
+ if (download->m_Hidden) {
+ download->m_Hidden = false;
- QSettings metaSettings(filePath.append(".meta"), QSettings::IniFormat);
- metaSettings.setValue("removed", false);
+ QString filePath = m_OutputDirectory + "/" + download->m_FileName;
- endDisableDirWatcher();
+ //avoid dirWatcher triggering refreshes
+ startDisableDirWatcher();
+ QSettings metaSettings(filePath.append(".meta"), QSettings::IniFormat);
+ metaSettings.setValue("removed", false);
+
+ endDisableDirWatcher();
+ }
+ }
}
@@ -680,7 +696,7 @@ void DownloadManager::removeDownload(int index, bool deleteFile)
removeFile(index, deleteFile);
delete *iter;
iter = m_ActiveDownloads.erase(iter);
- QCoreApplication::processEvents();
+ //QCoreApplication::processEvents();
}
else {
++iter;