From ec8dbcbf280bf6b542e9087d562e51757d205299 Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Sun, 30 Dec 2018 14:54:28 +0100 Subject: Port context menus to new downloadlist --- src/downloadlist.cpp | 2 + src/downloadlistwidget.cpp | 359 +++++++++----------------------------- src/downloadlistwidget.h | 58 +------ src/downloadmanager.cpp | 2 +- src/mainwindow.cpp | 41 ++--- src/mainwindow.ui | 2 +- src/organizer_en.ts | 417 +++++++++++++++++++++------------------------ 7 files changed, 291 insertions(+), 590 deletions(-) (limited to 'src') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 503274e6..a44850cb 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -82,8 +82,10 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const DownloadManager::DownloadState state = m_Manager->getState(index.row()); switch (state) { case DownloadManager::STATE_INSTALLED : return tr("Installed"); + case DownloadManager::STATE_UNINSTALLED : return tr("Uninstalled"); case DownloadManager::STATE_READY : return tr("Downloaded"); case DownloadManager::STATE_DOWNLOADING : return m_Manager->getProgress(index.row()).second; + case DownloadManager::STATE_PAUSED : return tr("Paused"); default : return state; } } else { diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index b3d9b083..915ddda5 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -30,224 +30,101 @@ DownloadListWidget::DownloadListWidget(QWidget *parent) : QTreeView(parent) { connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClick(QModelIndex))); + connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenu(QPoint))); } - DownloadListWidget::~DownloadListWidget() { } -void DownloadListWidget::onDoubleClick(const QModelIndex &index) -{ - emit(resumeDownload(dynamic_cast(model())->mapToSource(index).row())); -} - - -DownloadListWidgetDelegate::DownloadListWidgetDelegate(DownloadManager *manager, bool metaDisplay, QTreeView *view, QObject *parent) - : QItemDelegate(parent) - , m_Manager(manager) - , m_MetaDisplay(metaDisplay) - , m_ItemWidget(new DownloadListWidget) - , m_ContextRow(0) - , m_View(view) -{ - m_NameLabel = m_ItemWidget->findChild("nameLabel"); - m_SizeLabel = m_ItemWidget->findChild("sizeLabel"); - m_Progress = m_ItemWidget->findChild("downloadProgress"); - m_InstallLabel = m_ItemWidget->findChild("installLabel"); - - m_InstallLabel->setVisible(false); - m_Progress->setTextVisible(true); - - connect(manager, SIGNAL(stateChanged(int,DownloadManager::DownloadState)), this, SLOT(stateChanged(int,DownloadManager::DownloadState))); - connect(manager, SIGNAL(downloadRemoved(int)), this, SLOT(resetCache(int))); -} - - -DownloadListWidgetDelegate::~DownloadListWidgetDelegate() -{ - delete m_ItemWidget; -} - - -void DownloadListWidgetDelegate::stateChanged(int row,DownloadManager::DownloadState) +void DownloadListWidget::setManager(DownloadManager *manager) { - m_Cache.remove(row); + m_Manager = manager; } - -void DownloadListWidgetDelegate::resetCache(int) +void DownloadListWidget::onDoubleClick(const QModelIndex &index) { - m_Cache.clear(); + QModelIndex sourceIndex = qobject_cast(model())->mapToSource(index); + if (m_Manager->getState(sourceIndex.row()) >= DownloadManager::STATE_READY) { + emit installDownload(sourceIndex.row()); + } else if ((m_Manager->getState(sourceIndex.row()) >= DownloadManager::STATE_PAUSED) || (m_Manager->getState(sourceIndex.row()) == DownloadManager::STATE_PAUSING)) { + emit resumeDownload(sourceIndex.row()); + } } - -void DownloadListWidgetDelegate::drawCache(QPainter *painter, const QStyleOptionViewItem &option, const QPixmap &cache) const +void DownloadListWidget::onCustomContextMenu(const QPoint &point) { - QRect rect = option.rect; - rect.setLeft(0); - rect.setWidth(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2) + m_View->columnWidth(3)); - painter->drawPixmap(rect, cache); -} - - -QString DownloadListWidgetDelegate::sizeFormat(quint64 size) const -{ - qreal calc = size; - QStringList list; - list << "KB" << "MB" << "GB" << "TB"; - - QStringListIterator i(list); - QString unit("byte(s)"); - - while (calc >= 1024.0 && i.hasNext()) - { - unit = i.next(); - calc /= 1024.0; - } - - return QString().setNum(calc, 'f', 2) + " " + unit; -} - + QMenu menu(this); + QModelIndex index = indexAt(point); + bool hidden = false; + if (index.row() >= 0) { + m_ContextRow = qobject_cast(model())->mapToSource(index).row(); + DownloadManager::DownloadState state = m_Manager->getState(m_ContextRow); + hidden = m_Manager->isHidden(m_ContextRow); + 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(issueQueryInfo())); + } + else { + menu.addAction(tr("Visit on Nexus"), this, SLOT(issueVisitOnNexus())); + } -void DownloadListWidgetDelegate::paintPendingDownload(int downloadIndex) const -{ - std::tuple nexusids = m_Manager->getPendingDownload(downloadIndex); - m_NameLabel->setText(tr("< game %1 mod %2 file %3 >").arg(std::get<0>(nexusids)).arg(std::get<1>(nexusids)).arg(std::get<2>(nexusids))); - m_SizeLabel->setText("???"); - m_InstallLabel->setVisible(true); - m_InstallLabel->setText(tr("Pending")); - m_Progress->setVisible(false); -} + menu.addAction(tr("Open File"), this, SLOT(issueOpenFile())); + menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder())); + menu.addSeparator(); -void DownloadListWidgetDelegate::paintRegularDownload(int downloadIndex) const -{ - QString name = m_MetaDisplay ? m_Manager->getDisplayName(downloadIndex) : m_Manager->getFileName(downloadIndex); - if (name.length() > 120) { - name.truncate(120); - name.append("..."); - } - m_NameLabel->setText(name); - m_SizeLabel->setText(sizeFormat(m_Manager->getFileSize(downloadIndex) )); - DownloadManager::DownloadState state = m_Manager->getState(downloadIndex); - if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR) || (state == DownloadManager::STATE_PAUSING)) { - QPalette labelPalette; - m_InstallLabel->setVisible(true); - m_Progress->setVisible(false); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Paused - Double Click to resume", 0)); -#else - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Paused - Double Click to resume", 0, QApplication::UnicodeUTF8)); -#endif - labelPalette.setColor(QPalette::WindowText, Qt::darkRed); - m_InstallLabel->setPalette(labelPalette); - } else if (state == DownloadManager::STATE_FETCHINGMODINFO) { - m_InstallLabel->setText(tr("Fetching Info 1")); - m_Progress->setVisible(false); - } else if (state == DownloadManager::STATE_FETCHINGFILEINFO) { - m_InstallLabel->setText(tr("Fetching Info 2")); - m_Progress->setVisible(false); - } else if (state >= DownloadManager::STATE_READY) { - QPalette labelPalette; - m_InstallLabel->setVisible(true); - m_Progress->setVisible(false); - if (state == DownloadManager::STATE_INSTALLED) { - // the tr-macro doesn't work here, maybe because the translation is actually associated with DownloadListWidget instead - // of DownloadListWidgetDelegate? -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Installed - Double Click to re-install", 0)); -#else - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Installed - Double Click to re-install", 0, QApplication::UnicodeUTF8)); -#endif - labelPalette.setColor(QPalette::WindowText, Qt::darkGray); - } else if (state == DownloadManager::STATE_UNINSTALLED) { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Uninstalled - Double Click to re-install", 0)); -#else - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Uninstalled - Double Click to re-install", 0, QApplication::UnicodeUTF8)); -#endif - labelPalette.setColor(QPalette::WindowText, Qt::lightGray); - } else { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Done - Double Click to install", 0)); -#else - m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Done - Double Click to install", 0, QApplication::UnicodeUTF8)); -#endif - labelPalette.setColor(QPalette::WindowText, Qt::darkGreen); + menu.addAction(tr("Delete"), this, SLOT(issueDelete())); + if (hidden) { + menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView())); + } + else { + menu.addAction(tr("Hide"), this, SLOT(issueRemoveFromView())); + } } - m_InstallLabel->setPalette(labelPalette); - if (m_Manager->isInfoIncomplete(downloadIndex)) { - m_NameLabel->setText(" " + m_NameLabel->text()); + else if (state == DownloadManager::STATE_DOWNLOADING) { + menu.addAction(tr("Cancel"), this, SLOT(issueCancel())); + menu.addAction(tr("Pause"), this, SLOT(issuePause())); + menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder())); } - } else { - m_InstallLabel->setVisible(false); - m_Progress->setVisible(true); - m_Progress->setValue(m_Manager->getProgress(downloadIndex).first); - m_Progress->setFormat(m_Manager->getProgress(downloadIndex).second); - } -} - -void DownloadListWidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - try { - auto iter = m_Cache.find(index.row()); - if (iter != m_Cache.end()) { - drawCache(painter, option, *iter); - return; + 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("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder())); } - m_ItemWidget->resize(QSize(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2) + m_View->columnWidth(3), option.rect.height())); - - int downloadIndex = index.data().toInt(); - - if (downloadIndex >= m_Manager->numTotalDownloads()) { - paintPendingDownload(downloadIndex - m_Manager->numTotalDownloads()); - } else { - paintRegularDownload(downloadIndex); - } - -#pragma message("caching disabled because changes in the list (including resorting) doesn't work correctly") -// if (state >= DownloadManager::STATE_READY) { - if (false) { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - QPixmap cache = m_ItemWidget->grab(); -#else - QPixmap cache = QPixmap::grabWidget(m_ItemWidget); -#endif - m_Cache[index.row()] = cache; - drawCache(painter, option, cache); - } else { - painter->save(); - painter->translate(QPoint(0, option.rect.topLeft().y())); - - m_ItemWidget->render(painter); - painter->restore(); - } - } catch (const std::exception &e) { - qCritical("failed to paint download list: %s", e.what()); + 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) { + menu.addSeparator(); + menu.addAction(tr("Un-Hide All..."), this, SLOT(issueRestoreToViewAll())); } -} -QSize DownloadListWidgetDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const -{ - const int width = m_ItemWidget->minimumWidth(); - const int height = m_ItemWidget->height(); - return QSize(width, height); + menu.exec(viewport()->mapToGlobal(point)); } - -void DownloadListWidgetDelegate::issueInstall() +void DownloadListWidget::issueInstall() { emit installDownload(m_ContextRow); } -void DownloadListWidgetDelegate::issueQueryInfo() +void DownloadListWidget::issueQueryInfo() { emit queryInfo(m_ContextRow); } -void DownloadListWidgetDelegate::issueDelete() +void DownloadListWidget::issueDelete() { if (QMessageBox::question(nullptr, tr("Delete Files?"), tr("This will permanently delete the selected download."), @@ -256,52 +133,53 @@ void DownloadListWidgetDelegate::issueDelete() } } -void DownloadListWidgetDelegate::issueRemoveFromView() +void DownloadListWidget::issueRemoveFromView() { + qDebug() << "removing from view: " << m_ContextRow; emit removeDownload(m_ContextRow, false); } -void DownloadListWidgetDelegate::issueRestoreToView() +void DownloadListWidget::issueRestoreToView() { emit restoreDownload(m_ContextRow); } -void DownloadListWidgetDelegate::issueRestoreToViewAll() +void DownloadListWidget::issueRestoreToViewAll() { emit restoreDownload(-1); } -void DownloadListWidgetDelegate::issueVisitOnNexus() +void DownloadListWidget::issueVisitOnNexus() { emit visitOnNexus(m_ContextRow); } -void DownloadListWidgetDelegate::issueOpenFile() +void DownloadListWidget::issueOpenFile() { emit openFile(m_ContextRow); } -void DownloadListWidgetDelegate::issueOpenInDownloadsFolder() +void DownloadListWidget::issueOpenInDownloadsFolder() { emit openInDownloadsFolder(m_ContextRow); } -void DownloadListWidgetDelegate::issueCancel() +void DownloadListWidget::issueCancel() { emit cancelDownload(m_ContextRow); } -void DownloadListWidgetDelegate::issuePause() +void DownloadListWidget::issuePause() { emit pauseDownload(m_ContextRow); } -void DownloadListWidgetDelegate::issueResume() +void DownloadListWidget::issueResume() { emit resumeDownload(m_ContextRow); } -void DownloadListWidgetDelegate::issueDeleteAll() +void DownloadListWidget::issueDeleteAll() { if (QMessageBox::question(nullptr, tr("Delete Files?"), tr("This will remove all finished downloads from this list and from disk."), @@ -310,7 +188,7 @@ void DownloadListWidgetDelegate::issueDeleteAll() } } -void DownloadListWidgetDelegate::issueDeleteCompleted() +void DownloadListWidget::issueDeleteCompleted() { if (QMessageBox::question(nullptr, tr("Delete Files?"), tr("This will remove all installed downloads from this list and from disk."), @@ -319,7 +197,7 @@ void DownloadListWidgetDelegate::issueDeleteCompleted() } } -void DownloadListWidgetDelegate::issueDeleteUninstalled() +void DownloadListWidget::issueDeleteUninstalled() { if (QMessageBox::question(nullptr, tr("Delete Files?"), tr("This will remove all uninstalled downloads from this list and from disk."), @@ -328,7 +206,7 @@ void DownloadListWidgetDelegate::issueDeleteUninstalled() } } -void DownloadListWidgetDelegate::issueRemoveFromViewAll() +void DownloadListWidget::issueRemoveFromViewAll() { if (QMessageBox::question(nullptr, tr("Are you sure?"), tr("This will remove all finished downloads from this list (but NOT from disk)."), @@ -337,7 +215,7 @@ void DownloadListWidgetDelegate::issueRemoveFromViewAll() } } -void DownloadListWidgetDelegate::issueRemoveFromViewCompleted() +void DownloadListWidget::issueRemoveFromViewCompleted() { if (QMessageBox::question(nullptr, tr("Are you sure?"), tr("This will remove all installed downloads from this list (but NOT from disk)."), @@ -346,7 +224,7 @@ void DownloadListWidgetDelegate::issueRemoveFromViewCompleted() } } -void DownloadListWidgetDelegate::issueRemoveFromViewUninstalled() +void DownloadListWidget::issueRemoveFromViewUninstalled() { if (QMessageBox::question(nullptr, tr("Are you sure?"), tr("This will remove all uninstalled downloads from this list (but NOT from disk)."), @@ -354,82 +232,3 @@ void DownloadListWidgetDelegate::issueRemoveFromViewUninstalled() emit removeDownload(-3, false); } } - -bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, - const QStyleOptionViewItem &option, const QModelIndex &index) -{ - try { - if (event->type() == QEvent::MouseButtonDblClick) { - QModelIndex sourceIndex = qobject_cast(model)->mapToSource(index); - if (m_Manager->getState(sourceIndex.row()) >= DownloadManager::STATE_READY) { - emit installDownload(sourceIndex.row()); - } else if ((m_Manager->getState(sourceIndex.row()) >= DownloadManager::STATE_PAUSED) || (m_Manager->getState(sourceIndex.row()) == DownloadManager::STATE_PAUSING)) { - emit resumeDownload(sourceIndex.row()); - } - return true; - } else if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast(event); - if (mouseEvent->button() == Qt::RightButton) { - QMenu menu(m_View); - bool hidden = false; - m_ContextRow = qobject_cast(model)->mapToSource(index).row(); - if (m_ContextRow < m_Manager->numTotalDownloads()) { - DownloadManager::DownloadState state = m_Manager->getState(m_ContextRow); - hidden = m_Manager->isHidden(m_ContextRow); - 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(issueQueryInfo())); - }else { - menu.addAction(tr("Visit on Nexus"), this,SLOT(issueVisitOnNexus())); - } - - menu.addAction(tr("Open File"), this, SLOT(issueOpenFile())); - menu.addAction(tr("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder())); - - menu.addSeparator(); - - menu.addAction(tr("Delete"), this, SLOT(issueDelete())); - if (hidden) { - menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView())); - } else { - menu.addAction(tr("Hide"), this, SLOT(issueRemoveFromView())); - } - } else if (state == DownloadManager::STATE_DOWNLOADING){ - menu.addAction(tr("Cancel"), this, SLOT(issueCancel())); - menu.addAction(tr("Pause"), this, SLOT(issuePause())); - menu.addAction(tr("Show in Folder"), 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("Show in Folder"), this, SLOT(issueOpenInDownloadsFolder())); - } - - 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) { - menu.addSeparator(); - menu.addAction(tr("Un-Hide All..."), this, SLOT(issueRestoreToViewAll())); - } - - menu.exec(mouseEvent->globalPos()); - - event->accept(); - return true; - } - } - } catch (const std::exception &e) { - qCritical("failed to handle editor event: %s", e.what()); - } - return QItemDelegate::editorEvent(event, model, option, index); -} diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index 7a7a25f7..0c17de87 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -31,6 +31,8 @@ namespace Ui { class DownloadListWidget; } +class DownloadManager; + class DownloadListWidget : public QTreeView { Q_OBJECT @@ -39,33 +41,9 @@ public: explicit DownloadListWidget(QWidget *parent = 0); ~DownloadListWidget(); -signals: - void resumeDownload(int index); - -private slots: - void onDoubleClick(const QModelIndex &index); -}; - -class DownloadManager; - -class DownloadListWidgetDelegate : public QItemDelegate -{ - - Q_OBJECT - -public: - - DownloadListWidgetDelegate(DownloadManager *manager, bool metaDisplay, QTreeView *view, QObject *parent = 0); - ~DownloadListWidgetDelegate(); - - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - - void paintPendingDownload(int downloadIndex) const; - void paintRegularDownload(int downloadIndex) const; + void setManager(DownloadManager *manager); signals: - void installDownload(int index); void queryInfo(int index); void removeDownload(int index, bool deleteFile); @@ -77,19 +55,9 @@ signals: void openFile(int index); void openInDownloadsFolder(int index); -protected: - - QString sizeFormat(quint64 size) const; - bool editorEvent(QEvent *event, QAbstractItemModel *model, - const QStyleOptionViewItem &option, const QModelIndex &index); - -private: - - - void drawCache(QPainter *painter, const QStyleOptionViewItem &option, const QPixmap &cache) const; - private slots: - + void onDoubleClick(const QModelIndex &index); + void onCustomContextMenu(const QPoint &point); void issueInstall(); void issueDelete(); void issueRemoveFromView(); @@ -109,25 +77,9 @@ private slots: void issueRemoveFromViewUninstalled(); void issueQueryInfo(); - void stateChanged(int row, DownloadManager::DownloadState); - void resetCache(int); - private: - - DownloadListWidget *m_ItemWidget; DownloadManager *m_Manager; - - bool m_MetaDisplay; - - QLabel *m_NameLabel; - QLabel *m_SizeLabel; - QProgressBar *m_Progress; - QLabel *m_InstallLabel; int m_ContextRow; - - QTreeView *m_View; - - mutable QMap m_Cache; }; #endif // DOWNLOADLISTWIDGET_H diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index f1cbf109..9f07b030 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1853,4 +1853,4 @@ void DownloadManager::writeData(DownloadInfo *info) "Canceling download \"%2\"...").arg(ret).arg(fileName)); } } -} \ No newline at end of file +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5ca60ef1..80ddf093 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5152,45 +5152,26 @@ void MainWindow::on_actionEndorseMO_triggered() void MainWindow::updateDownloadListDelegate() { - /* - if (m_OrganizerCore.settings().compactDownloads()) { - ui->downloadView->setItemDelegate( - new DownloadListWidgetCompactDelegate(m_OrganizerCore.downloadManager(), - m_OrganizerCore.settings().metaDownloads(), - ui->downloadView, - ui->downloadView)); - } else { - ui->downloadView->setItemDelegate( - new DownloadListWidgetDelegate(m_OrganizerCore.downloadManager(), - m_OrganizerCore.settings().metaDownloads(), - ui->downloadView, - ui->downloadView)); - } - */ - DownloadListSortProxy *sortProxy = new DownloadListSortProxy(m_OrganizerCore.downloadManager(), ui->downloadView); sortProxy->setSourceModel(new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView)); connect(ui->downloadFilterEdit, SIGNAL(textChanged(QString)), sortProxy, SLOT(updateFilter(QString))); connect(ui->downloadFilterEdit, SIGNAL(textChanged(QString)), this, SLOT(downloadFilterChanged(QString))); ui->downloadView->setModel(sortProxy); + ui->downloadView->setManager(m_OrganizerCore.downloadManager()); //ui->downloadView->sortByColumn(1, Qt::DescendingOrder); ui->downloadView->header()->resizeSections(QHeaderView::Stretch); - connect(ui->downloadView, SIGNAL(resumeDownload(int)), m_OrganizerCore.downloadManager(), SLOT(resumeDownload(int))); - - /* - connect(ui->downloadView->itemDelegate(), SIGNAL(installDownload(int)), &m_OrganizerCore, SLOT(installDownload(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(queryInfo(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfo(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(visitOnNexus(int)), m_OrganizerCore.downloadManager(), SLOT(visitOnNexus(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(openFile(int)), m_OrganizerCore.downloadManager(), SLOT(openFile(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(openInDownloadsFolder(int)), m_OrganizerCore.downloadManager(), SLOT(openInDownloadsFolder(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(removeDownload(int, bool)), m_OrganizerCore.downloadManager(), SLOT(removeDownload(int, bool))); - connect(ui->downloadView->itemDelegate(), SIGNAL(restoreDownload(int)), m_OrganizerCore.downloadManager(), SLOT(restoreDownload(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(cancelDownload(int)), m_OrganizerCore.downloadManager(), SLOT(cancelDownload(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(pauseDownload(int)), m_OrganizerCore.downloadManager(), SLOT(pauseDownload(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(resumeDownload(int)), this, SLOT(resumeDownload(int))); - */ + connect(ui->downloadView, SIGNAL(installDownload(int)), &m_OrganizerCore, SLOT(installDownload(int))); + connect(ui->downloadView, SIGNAL(queryInfo(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfo(int))); + connect(ui->downloadView, SIGNAL(visitOnNexus(int)), m_OrganizerCore.downloadManager(), SLOT(visitOnNexus(int))); + connect(ui->downloadView, SIGNAL(openFile(int)), m_OrganizerCore.downloadManager(), SLOT(openFile(int))); + connect(ui->downloadView, SIGNAL(openInDownloadsFolder(int)), m_OrganizerCore.downloadManager(), SLOT(openInDownloadsFolder(int))); + connect(ui->downloadView, SIGNAL(removeDownload(int, bool)), m_OrganizerCore.downloadManager(), SLOT(removeDownload(int, bool))); + connect(ui->downloadView, SIGNAL(restoreDownload(int)), m_OrganizerCore.downloadManager(), SLOT(restoreDownload(int))); + connect(ui->downloadView, SIGNAL(cancelDownload(int)), m_OrganizerCore.downloadManager(), SLOT(cancelDownload(int))); + connect(ui->downloadView, SIGNAL(pauseDownload(int)), m_OrganizerCore.downloadManager(), SLOT(pauseDownload(int))); + connect(ui->downloadView, SIGNAL(resumeDownload(int)), this, SLOT(resumeDownload(int))); } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 5dfd075b..771832fd 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1311,7 +1311,7 @@ p, li { white-space: pre-wrap; } - Qt::PreventContextMenu + Qt::CustomContextMenu true diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 9b61eafc..e958c116 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -313,16 +313,26 @@ p, li { white-space: pre-wrap; } + Uninstalled + + + + Downloaded - + + Paused + + + + Information missing, please select "Query Info" from the context menu to re-retrieve. - + pending download @@ -337,392 +347,349 @@ p, li { white-space: pre-wrap; } - - Done - Double Click to install - - - Paused - Double Click to resume - - - - - - Installed - Double Click to re-install - - - - - - Uninstalled - Double Click to re-install - - - - - DownloadListWidgetCompact - - - - Placeholder - - - - - Done - - - - - DownloadListWidgetCompactDelegate - - - < game %1 mod %2 file %3 > - - - - - Pending - - - - - Paused + + Install - - Fetching Info 1 + + Query Info - - Fetching Info 2 + + Visit on Nexus - - Installed + + Open File - - Uninstalled + + + + Show in Folder - - Done + + + Delete - - - - - - - - Are you sure? + + Un-Hide - - This will permanently delete the selected download. + + Hide - - This will remove all finished downloads from this list and from disk. + + Cancel - - This will remove all installed downloads from this list and from disk. + + Pause - - This will remove all uninstalled downloads from this list and from disk. + + Resume - - This will permanently remove all finished downloads from this list (but NOT from disk). + + Delete Installed... - - This will permanently remove all installed downloads from this list (but NOT from disk). + + Delete Uninstalled... - - This will permanently remove all uninstalled downloads from this list (but NOT from disk). + + Delete All... - - Install + + Hide Installed... - - Query Info + + Hide Uninstalled... - - Visit on Nexus + + Hide All... - - Open File + + Un-Hide All... - - - - Show in Folder + + + + + Delete Files? - - Delete + + This will permanently delete the selected download. - - Un-Hide + + This will remove all finished downloads from this list and from disk. - - Hide + + This will remove all installed downloads from this list and from disk. - - Cancel + + This will remove all uninstalled downloads from this list and from disk. - - Pause + + + + Are you sure? - - Remove + + This will remove all finished downloads from this list (but NOT from disk). - - Resume + + This will remove all installed downloads from this list (but NOT from disk). - - Delete Installed... + + This will remove all uninstalled downloads from this list (but NOT from disk). + + + DownloadListWidgetCompact - - Delete Uninstalled... + + + Placeholder - - Delete All... + + Done + + + DownloadListWidgetCompactDelegate - - Hide Installed... + + < game %1 mod %2 file %3 > - - Hide Uninstalled... + + Pending - - Hide All... + + Paused - - Un-Hide All... + + Fetching Info 1 - - - DownloadListWidgetDelegate - - < game %1 mod %2 file %3 > + + Fetching Info 2 - - Pending + + Installed - - Fetching Info 1 + + Uninstalled - - Fetching Info 2 + + Done - - - - - Delete Files? + + + + + + + + Are you sure? - + This will permanently delete the selected download. - + This will remove all finished downloads from this list and from disk. - + This will remove all installed downloads from this list and from disk. - + This will remove all uninstalled downloads from this list and from disk. - - - - Are you sure? - - - - - This will remove all finished downloads from this list (but NOT from disk). + + This will permanently remove all finished downloads from this list (but NOT from disk). - - This will remove all installed downloads from this list (but NOT from disk). + + This will permanently remove all installed downloads from this list (but NOT from disk). - - This will remove all uninstalled downloads from this list (but NOT from disk). + + This will permanently remove all uninstalled downloads from this list (but NOT from disk). - + Install - + Query Info - + Visit on Nexus - + Open File - - - + + + Show in Folder - - + Delete - + Un-Hide - + Hide - + Cancel - + Pause - + + Remove + + + + Resume - + Delete Installed... - + Delete Uninstalled... - + Delete All... - + Hide Installed... - + Hide Uninstalled... - + Hide All... - + Un-Hide All... @@ -2470,7 +2437,7 @@ Please enter a name: - + Are you sure? @@ -2797,13 +2764,13 @@ You can also use online editors and converters instead. - + Enable selected - + Disable selected @@ -2864,13 +2831,13 @@ You can also use online editors and converters instead. - + Exception: - + Unknown exception @@ -3008,7 +2975,7 @@ Click OK to restart MO now. - + Set Priority @@ -3073,196 +3040,196 @@ Click OK to restart MO now. - + Thank you! - + Thank you for your endorsement! - + Request to Nexus failed: %1 - - + + failed to read %1: %2 - - + + Error - + failed to extract %1 (errorcode %2) - + Extract BSA - + This archive contains invalid hashes. Some files may be broken. - + Extract... - + This will restart MO, continue? - + Edit Categories... - + Deselect filter - + Remove - + Enable all - + Disable all - + Unlock load order - + Lock load order - + Open Origin in Explorer - + Open Origin Info... - + depends on missing "%1" - + incompatible with "%1" - + Please wait while LOOT is running - + loot failed. Exit code was: %1 - + failed to start loot - + failed to run loot: %1 - + Errors occured - + Backup of load order created - + Choose backup to restore - + No Backups - + There are no backups to restore - - + + Restore failed - - + + Failed to restore the backup. Errorcode: %1 - + Backup of modlist created - + A file with the same name has already been downloaded. What would you like to do? - + Overwrite - + Rename new file - + Ignore file - + Set the priority of the selected mods -- cgit v1.3.1