summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-15 20:12:19 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-15 20:12:19 +0100
commitff3f24ff9e0e6e0785fdb29cef0d58f232abfc1e (patch)
treec85183f20924c46b689cdc9d3865f44305e3402e
parent899308b31d541e78a3e4395bf33cd66c5ec4f769 (diff)
Rename DownloadListWidget -> DownloadListView. Clean context menu.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/downloadlistview.cpp (renamed from src/downloadlistwidget.cpp)135
-rw-r--r--src/downloadlistview.h (renamed from src/downloadlistwidget.h)48
-rw-r--r--src/downloadstab.cpp8
-rw-r--r--src/downloadstab.h4
-rw-r--r--src/mainwindow.cpp1
-rw-r--r--src/mainwindow.ui12
7 files changed, 105 insertions, 105 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d1092637..a5d15740 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -63,7 +63,7 @@ add_filter(NAME src/dialogs GROUPS
add_filter(NAME src/downloads GROUPS
downloadlist
- downloadlistwidget
+ downloadlistview
downloadmanager
)
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistview.cpp
index 22e3a3b9..5e49f107 100644
--- a/src/downloadlistwidget.cpp
+++ b/src/downloadlistview.cpp
@@ -18,7 +18,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "downloadlist.h"
-#include "downloadlistwidget.h"
+#include "downloadlistview.h"
#include <report.h>
#include <log.h>
#include <QPainter>
@@ -34,7 +34,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
using namespace MOBase;
DownloadProgressDelegate::DownloadProgressDelegate(
- DownloadManager* manager, DownloadListWidget* list)
+ DownloadManager* manager, DownloadListView* list)
: QStyledItemDelegate(list), m_Manager(manager), m_List(list)
{
}
@@ -113,7 +113,7 @@ void DownloadListHeader::mouseReleaseEvent(QMouseEvent *event)
customResizeSections();
}
-DownloadListWidget::DownloadListWidget(QWidget *parent)
+DownloadListView::DownloadListView(QWidget *parent)
: QTreeView(parent)
{
setHeader(new DownloadListHeader(Qt::Horizontal, this));
@@ -135,11 +135,11 @@ DownloadListWidget::DownloadListWidget(QWidget *parent)
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenu(QPoint)));
}
-DownloadListWidget::~DownloadListWidget()
+DownloadListView::~DownloadListView()
{
}
-void DownloadListWidget::setManager(DownloadManager *manager)
+void DownloadListView::setManager(DownloadManager *manager)
{
m_Manager = manager;
@@ -154,18 +154,18 @@ void DownloadListWidget::setManager(DownloadManager *manager)
header()->hideSection(DownloadList::COL_SOURCEGAME);
}
-void DownloadListWidget::setSourceModel(DownloadList *sourceModel)
+void DownloadListView::setSourceModel(DownloadList *sourceModel)
{
m_SourceModel = sourceModel;
}
-void DownloadListWidget::setMetaDisplay(bool metaDisplay)
+void DownloadListView::setMetaDisplay(bool metaDisplay)
{
if (m_SourceModel != nullptr)
m_SourceModel->setMetaDisplay(metaDisplay);
}
-void DownloadListWidget::onDoubleClick(const QModelIndex &index)
+void DownloadListView::onDoubleClick(const QModelIndex &index)
{
QModelIndex sourceIndex = qobject_cast<QSortFilterProxyModel*>(model())->mapToSource(index);
if (m_Manager->getState(sourceIndex.row()) >= DownloadManager::STATE_READY)
@@ -175,7 +175,7 @@ void DownloadListWidget::onDoubleClick(const QModelIndex &index)
emit resumeDownload(sourceIndex.row());
}
-void DownloadListWidget::onHeaderCustomContextMenu(const QPoint &point)
+void DownloadListView::onHeaderCustomContextMenu(const QPoint &point)
{
QMenu menu;
@@ -209,13 +209,13 @@ void DownloadListWidget::onHeaderCustomContextMenu(const QPoint &point)
qobject_cast<DownloadListHeader*>(header())->customResizeSections();
}
-void DownloadListWidget::resizeEvent(QResizeEvent *event)
+void DownloadListView::resizeEvent(QResizeEvent *event)
{
QTreeView::resizeEvent(event);
qobject_cast<DownloadListHeader*>(header())->customResizeSections();
}
-void DownloadListWidget::onCustomContextMenu(const QPoint &point)
+void DownloadListView::onCustomContextMenu(const QPoint &point)
{
QMenu menu(this);
QModelIndex index = indexAt(point);
@@ -224,37 +224,38 @@ void DownloadListWidget::onCustomContextMenu(const QPoint &point)
try
{
if (index.row() >= 0) {
- m_ContextRow = qobject_cast<QSortFilterProxyModel*>(model())->mapToSource(index).row();
- DownloadManager::DownloadState state = m_Manager->getState(m_ContextRow);
+ const int row = qobject_cast<QSortFilterProxyModel*>(model())->mapToSource(index).row();
+ DownloadManager::DownloadState state = m_Manager->getState(row);
- hidden = m_Manager->isHidden(m_ContextRow);
+ hidden = m_Manager->isHidden(row);
if (state >= DownloadManager::STATE_READY) {
- menu.addAction(tr("Install"), this, SLOT(issueInstall()));
- if (m_Manager->isInfoIncomplete(m_ContextRow))
- menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfoMd5()));
+ menu.addAction(tr("Install"), [=] { issueInstall(row); });
+ if (m_Manager->isInfoIncomplete(row))
+ menu.addAction(tr("Query Info"), [=] { issueQueryInfoMd5(row); });
else
- menu.addAction(tr("Visit on Nexus"), this, SLOT(issueVisitOnNexus()));
- menu.addAction(tr("Open File"), this, SLOT(issueOpenFile()));
- menu.addAction(tr("Open Meta File"), this, SLOT(issueOpenMetaFile()));
- menu.addAction(tr("Reveal in Explorer"), this, SLOT(issueOpenInDownloadsFolder()));
+ menu.addAction(tr("Visit on Nexus"), [=] { issueVisitOnNexus(row); });
+ menu.addAction(tr("Open File"), [=] { issueOpenFile(row); });
+ menu.addAction(tr("Open Meta File"), [=] { issueOpenMetaFile(row); });
+ menu.addAction(tr("Reveal in Explorer"), [=] { issueOpenInDownloadsFolder(row); });
menu.addSeparator();
- menu.addAction(tr("Delete..."), this, SLOT(issueDelete()));
+ menu.addAction(tr("Delete..."), [=] { issueDelete(row); });
if (hidden)
- menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView()));
+ menu.addAction(tr("Un-Hide"), [=] { issueRestoreToView(row); });
else
- menu.addAction(tr("Hide"), this, SLOT(issueRemoveFromView()));
+ menu.addAction(tr("Hide"), [=] { issueRemoveFromView(row); });
} else if (state == DownloadManager::STATE_DOWNLOADING) {
- menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
- menu.addAction(tr("Pause"), this, SLOT(issuePause()));
- menu.addAction(tr("Reveal in Explorer"), this, SLOT(issueOpenInDownloadsFolder()));
- } else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)
- || (state == DownloadManager::STATE_PAUSING)) {
- menu.addAction(tr("Delete..."), this, SLOT(issueDelete()));
- menu.addAction(tr("Resume"), this, SLOT(issueResume()));
- menu.addAction(tr("Reveal in Explorer"), this, SLOT(issueOpenInDownloadsFolder()));
+ menu.addAction(tr("Cancel"), [=] { issueCancel(row); });
+ menu.addAction(tr("Pause"), [=] { issuePause(row); });
+ menu.addAction(tr("Reveal in Explorer"), [=] { issueOpenInDownloadsFolder(row); });
+ }
+ else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)
+ || (state == DownloadManager::STATE_PAUSING)) {
+ menu.addAction(tr("Delete..."), [=] { issueDelete(row); });
+ menu.addAction(tr("Resume"), [=] { issueResume(row); });
+ menu.addAction(tr("Reveal in Explorer"), [=] { issueOpenInDownloadsFolder(row); });
}
menu.addSeparator();
@@ -281,26 +282,26 @@ void DownloadListWidget::onCustomContextMenu(const QPoint &point)
menu.exec(viewport()->mapToGlobal(point));
}
-void DownloadListWidget::issueInstall()
+void DownloadListView::issueInstall(int index)
{
- emit installDownload(m_ContextRow);
+ emit installDownload(index);
}
-void DownloadListWidget::issueQueryInfo()
+void DownloadListView::issueQueryInfo(int index)
{
- emit queryInfo(m_ContextRow);
+ emit queryInfo(index);
}
-void DownloadListWidget::issueQueryInfoMd5()
+void DownloadListView::issueQueryInfoMd5(int index)
{
- emit queryInfoMd5(m_ContextRow);
+ emit queryInfoMd5(index);
}
-void DownloadListWidget::issueDelete()
+void DownloadListView::issueDelete(int index)
{
const auto r = MOBase::TaskDialog(this, tr("Delete download"))
.main("Are you sure you want to delete this download?")
- .content(m_Manager->getFilePath(m_ContextRow))
+ .content(m_Manager->getFilePath(index))
.icon(QMessageBox::Question)
.button({tr("Move to the Recycle Bin"), QMessageBox::Yes})
.button({tr("Cancel"), QMessageBox::Cancel})
@@ -310,60 +311,60 @@ void DownloadListWidget::issueDelete()
return;
}
- emit removeDownload(m_ContextRow, true);
+ emit removeDownload(index, true);
}
-void DownloadListWidget::issueRemoveFromView()
+void DownloadListView::issueRemoveFromView(int index)
{
- log::debug("removing from view: {}", m_ContextRow);
- emit removeDownload(m_ContextRow, false);
+ log::debug("removing from view: {}", index);
+ emit removeDownload(index, false);
}
-void DownloadListWidget::issueRestoreToView()
+void DownloadListView::issueRestoreToView(int index)
{
- emit restoreDownload(m_ContextRow);
+ emit restoreDownload(index);
}
-void DownloadListWidget::issueRestoreToViewAll()
+void DownloadListView::issueRestoreToViewAll()
{
emit restoreDownload(-1);
}
-void DownloadListWidget::issueVisitOnNexus()
+void DownloadListView::issueVisitOnNexus(int index)
{
- emit visitOnNexus(m_ContextRow);
+ emit visitOnNexus(index);
}
-void DownloadListWidget::issueOpenFile()
+void DownloadListView::issueOpenFile(int index)
{
- emit openFile(m_ContextRow);
+ emit openFile(index);
}
-void DownloadListWidget::issueOpenMetaFile() {
- emit openMetaFile(m_ContextRow);
+void DownloadListView::issueOpenMetaFile(int index) {
+ emit openMetaFile(index);
}
-void DownloadListWidget::issueOpenInDownloadsFolder()
+void DownloadListView::issueOpenInDownloadsFolder(int index)
{
- emit openInDownloadsFolder(m_ContextRow);
+ emit openInDownloadsFolder(index);
}
-void DownloadListWidget::issueCancel()
+void DownloadListView::issueCancel(int index)
{
- emit cancelDownload(m_ContextRow);
+ emit cancelDownload(index);
}
-void DownloadListWidget::issuePause()
+void DownloadListView::issuePause(int index)
{
- emit pauseDownload(m_ContextRow);
+ emit pauseDownload(index);
}
-void DownloadListWidget::issueResume()
+void DownloadListView::issueResume(int index)
{
- emit resumeDownload(m_ContextRow);
+ emit resumeDownload(index);
}
-void DownloadListWidget::issueDeleteAll()
+void DownloadListView::issueDeleteAll()
{
if (QMessageBox::warning(nullptr, tr("Delete Files?"),
tr("This will remove all finished downloads from this list and from disk.\n\nAre you absolutely sure you want to proceed?"),
@@ -372,7 +373,7 @@ void DownloadListWidget::issueDeleteAll()
}
}
-void DownloadListWidget::issueDeleteCompleted()
+void DownloadListView::issueDeleteCompleted()
{
if (QMessageBox::warning(nullptr, tr("Delete Files?"),
tr("This will remove all installed downloads from this list and from disk.\n\nAre you absolutely sure you want to proceed?"),
@@ -381,7 +382,7 @@ void DownloadListWidget::issueDeleteCompleted()
}
}
-void DownloadListWidget::issueDeleteUninstalled()
+void DownloadListView::issueDeleteUninstalled()
{
if (QMessageBox::warning(nullptr, tr("Delete Files?"),
tr("This will remove all uninstalled downloads from this list and from disk.\n\nAre you absolutely sure you want to proceed?"),
@@ -390,7 +391,7 @@ void DownloadListWidget::issueDeleteUninstalled()
}
}
-void DownloadListWidget::issueRemoveFromViewAll()
+void DownloadListView::issueRemoveFromViewAll()
{
if (QMessageBox::question(nullptr, tr("Hide Files?"),
tr("This will remove all finished downloads from this list (but NOT from disk)."),
@@ -399,7 +400,7 @@ void DownloadListWidget::issueRemoveFromViewAll()
}
}
-void DownloadListWidget::issueRemoveFromViewCompleted()
+void DownloadListView::issueRemoveFromViewCompleted()
{
if (QMessageBox::question(nullptr, tr("Hide Files?"),
tr("This will remove all installed downloads from this list (but NOT from disk)."),
@@ -408,7 +409,7 @@ void DownloadListWidget::issueRemoveFromViewCompleted()
}
}
-void DownloadListWidget::issueRemoveFromViewUninstalled()
+void DownloadListView::issueRemoveFromViewUninstalled()
{
if (QMessageBox::question(nullptr, tr("Hide Files?"),
tr("This will remove all uninstalled downloads from this list (but NOT from disk)."),
diff --git a/src/downloadlistwidget.h b/src/downloadlistview.h
index 64e1a6e8..0a3e575b 100644
--- a/src/downloadlistwidget.h
+++ b/src/downloadlistview.h
@@ -32,24 +32,24 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace Ui {
- class DownloadListWidget;
+ class DownloadListView;
}
-class DownloadListWidget;
+class DownloadListView;
class DownloadProgressDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
- DownloadProgressDelegate(DownloadManager* manager, DownloadListWidget* list);
+ DownloadProgressDelegate(DownloadManager* manager, DownloadListView* list);
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
private:
DownloadManager* m_Manager;
- DownloadListWidget* m_List;
+ DownloadListView* m_List;
};
class DownloadListHeader : public QHeaderView
@@ -64,13 +64,13 @@ private:
void mouseReleaseEvent(QMouseEvent *event) override;
};
-class DownloadListWidget : public QTreeView
+class DownloadListView : public QTreeView
{
Q_OBJECT
public:
- explicit DownloadListWidget(QWidget *parent = 0);
- ~DownloadListWidget();
+ explicit DownloadListView(QWidget *parent = 0);
+ ~DownloadListView();
void setManager(DownloadManager *manager);
void setSourceModel(DownloadList *sourceModel);
@@ -91,34 +91,34 @@ signals:
void openInDownloadsFolder(int index);
private slots:
- void onDoubleClick(const QModelIndex &index);
- void onCustomContextMenu(const QPoint &point);
- void onHeaderCustomContextMenu(const QPoint &point);
- void issueInstall();
- void issueDelete();
- void issueRemoveFromView();
- void issueRestoreToView();
+ void onDoubleClick(const QModelIndex& index);
+ void onCustomContextMenu(const QPoint& point);
+ void onHeaderCustomContextMenu(const QPoint& point);
+
+ void issueInstall(int index);
+ void issueDelete(int index);
+ void issueRemoveFromView(int index);
+ void issueRestoreToView(int index);
void issueRestoreToViewAll();
- void issueVisitOnNexus();
- void issueOpenFile();
- void issueOpenMetaFile();
- void issueOpenInDownloadsFolder();
- void issueCancel();
- void issuePause();
- void issueResume();
+ void issueVisitOnNexus(int index);
+ void issueOpenFile(int index);
+ void issueOpenMetaFile(int index);
+ void issueOpenInDownloadsFolder(int index);
+ void issueCancel(int index);
+ void issuePause(int index);
+ void issueResume(int index);
void issueDeleteAll();
void issueDeleteCompleted();
void issueDeleteUninstalled();
void issueRemoveFromViewAll();
void issueRemoveFromViewCompleted();
void issueRemoveFromViewUninstalled();
- void issueQueryInfo();
- void issueQueryInfoMd5();
+ void issueQueryInfo(int index);
+ void issueQueryInfoMd5(int index);
private:
DownloadManager *m_Manager;
DownloadList *m_SourceModel = 0;
- int m_ContextRow;
void resizeEvent(QResizeEvent *event);
};
diff --git a/src/downloadstab.cpp b/src/downloadstab.cpp
index a0602ede..ab7a1c9a 100644
--- a/src/downloadstab.cpp
+++ b/src/downloadstab.cpp
@@ -1,6 +1,6 @@
#include "downloadstab.h"
#include "downloadlist.h"
-#include "downloadlistwidget.h"
+#include "downloadlistview.h"
#include "organizercore.h"
#include "ui_mainwindow.h"
@@ -37,7 +37,7 @@ DownloadsTab::DownloadsTab(OrganizerCore& core, Ui::MainWindow* mwui)
connect(ui.list, SIGNAL(restoreDownload(int)), m_core.downloadManager(), SLOT(restoreDownload(int)));
connect(ui.list, SIGNAL(cancelDownload(int)), m_core.downloadManager(), SLOT(cancelDownload(int)));
connect(ui.list, SIGNAL(pauseDownload(int)), m_core.downloadManager(), SLOT(pauseDownload(int)));
- connect(ui.list, &DownloadListWidget::resumeDownload, [&](int i){ resumeDownload(i); });
+ connect(ui.list, &DownloadListView::resumeDownload, [&](int i){ resumeDownload(i); });
}
void DownloadsTab::update()
@@ -50,10 +50,10 @@ void DownloadsTab::update()
// set the view attribute and default row sizes
if (m_core.settings().interface().compactDownloads()) {
ui.list->setProperty("downloadView", "compact");
- ui.list->setStyleSheet("DownloadListWidget::item { padding: 4px 2px; }");
+ ui.list->setStyleSheet("DownloadListView::item { padding: 4px 2px; }");
} else {
ui.list->setProperty("downloadView", "standard");
- ui.list->setStyleSheet("DownloadListWidget::item { padding: 16px 4px; }");
+ ui.list->setStyleSheet("DownloadListView::item { padding: 16px 4px; }");
}
ui.list->setMetaDisplay(m_core.settings().interface().metaDownloads());
diff --git a/src/downloadstab.h b/src/downloadstab.h
index ac0cf0e2..f39f4ba5 100644
--- a/src/downloadstab.h
+++ b/src/downloadstab.h
@@ -5,7 +5,7 @@
namespace Ui { class MainWindow; }
class OrganizerCore;
-class DownloadListWidget;
+class DownloadListView;
class DownloadsTab : public QObject
{
@@ -20,7 +20,7 @@ private:
struct DownloadsTabUi
{
QPushButton* refresh;
- DownloadListWidget* list;
+ DownloadListView* list;
QCheckBox* showHidden;
QLineEdit* filter;
};
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c9824a24..9c049efa 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -46,7 +46,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "categoriesdialog.h"
#include "overwriteinfodialog.h"
#include "downloadlist.h"
-#include "downloadlistwidget.h"
#include "messagedialog.h"
#include "installationmanager.h"
#include "motddialog.h"
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index a0900542..4317b6c0 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -1282,7 +1282,7 @@ p, li { white-space: pre-wrap; }
<item>
<layout class="QVBoxLayout" name="downloadLayout">
<item>
- <widget class="DownloadListWidget" name="downloadView">
+ <widget class="DownloadListView" name="downloadView">
<property name="minimumSize">
<size>
<width>320</width>
@@ -1942,11 +1942,6 @@ p, li { white-space: pre-wrap; }
<header>lcdnumber.h</header>
</customwidget>
<customwidget>
- <class>DownloadListWidget</class>
- <extends>QTreeView</extends>
- <header>downloadlistwidget.h</header>
- </customwidget>
- <customwidget>
<class>MOBase::SortableTreeWidget</class>
<extends>QWidget</extends>
<header>sortabletreewidget.h</header>
@@ -1961,6 +1956,11 @@ p, li { white-space: pre-wrap; }
<extends>QStatusBar</extends>
<header>statusbar.h</header>
</customwidget>
+ <customwidget>
+ <class>DownloadListView</class>
+ <extends>QTreeView</extends>
+ <header>downloadlistview.h</header>
+ </customwidget>
</customwidgets>
<resources>
<include location="resources.qrc"/>