From 5920dc2cd14ef5dc6e3802939cbe6256ea13848b Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Sun, 30 Dec 2018 12:07:40 +0100 Subject: Disable downloadlist widget delegates, port partial functionality to QTreeView --- src/downloadlist.cpp | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index f470e57b..503274e6 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -40,7 +40,7 @@ int DownloadList::rowCount(const QModelIndex&) const int DownloadList::columnCount(const QModelIndex&) const { - return 4; + return 3; } @@ -61,21 +61,34 @@ QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int if ((role == Qt::DisplayRole) && (orientation == Qt::Horizontal)) { switch (section) { - case COL_NAME: return tr("Name"); - case COL_FILETIME: return tr("Filetime"); - case COL_SIZE: return tr("Size"); - default: return tr("Done"); + case COL_NAME : return tr("Name"); + case COL_SIZE : return tr("Size"); + case COL_STATUS : return tr("Status"); + default : return "-"; } } else { return QAbstractItemModel::headerData(section, orientation, role); } } - QVariant DownloadList::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { - return index.row(); + if (index.column() == COL_NAME) { + return m_Manager->getFileName(index.row()); + } else if (index.column() == COL_SIZE) { + return sizeFormat(m_Manager->getFileSize(index.row())); + } else if (index.column() == COL_STATUS) { + DownloadManager::DownloadState state = m_Manager->getState(index.row()); + switch (state) { + case DownloadManager::STATE_INSTALLED : return tr("Installed"); + case DownloadManager::STATE_READY : return tr("Downloaded"); + case DownloadManager::STATE_DOWNLOADING : return m_Manager->getProgress(index.row()).second; + default : return state; + } + } else { + return index.row(); + } } else if (role == Qt::ToolTipRole) { if (index.row() < m_Manager->numTotalDownloads()) { QString text = m_Manager->getFileName(index.row()) + "\n"; @@ -112,3 +125,21 @@ void DownloadList::update(int row) } } +QString DownloadList::sizeFormat(quint64 size) const +{ + qreal calc = size; + QStringList list; + list << "MB" << "GB" << "TB"; + + QStringListIterator i(list); + QString unit("KB"); + + calc /= 1024.0; + while (calc >= 1024.0 && i.hasNext()) + { + unit = i.next(); + calc /= 1024.0; + } + + return QString().setNum(calc, 'f', 2) + " " + unit; +} -- cgit v1.3.1 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/downloadlist.cpp') 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 From 4d40e8d18c789e71af403997fa1b10e8dd7168e1 Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Sun, 30 Dec 2018 16:22:35 +0100 Subject: Fix adding new downloads, add missing download progress states --- src/downloadlist.cpp | 71 +++++++++++++++++++++++++++++---------- src/downloadlistsortproxy.cpp | 4 +-- src/downloadlistwidgetcompact.cpp | 1 - 3 files changed, 55 insertions(+), 21 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index a44850cb..178e4083 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -64,7 +64,7 @@ QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int case COL_NAME : return tr("Name"); case COL_SIZE : return tr("Size"); case COL_STATUS : return tr("Status"); - default : return "-"; + default : return QVariant(); } } else { return QAbstractItemModel::headerData(section, orientation, role); @@ -73,26 +73,63 @@ QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int QVariant DownloadList::data(const QModelIndex &index, int role) const { + bool pendingDownload = index.row() >= m_Manager->numTotalDownloads(); if (role == Qt::DisplayRole) { - if (index.column() == COL_NAME) { - return m_Manager->getFileName(index.row()); - } else if (index.column() == COL_SIZE) { - return sizeFormat(m_Manager->getFileSize(index.row())); - } else if (index.column() == COL_STATUS) { - 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; + if (pendingDownload) { + std::tuple nexusids = m_Manager->getPendingDownload(index.row() - m_Manager->numTotalDownloads()); + switch (index.column()) { + case COL_NAME: + return tr("< game %1 mod %2 file %3 >").arg(std::get<0>(nexusids)).arg(std::get<1>(nexusids)).arg(std::get<2>(nexusids)); + case COL_SIZE: + return tr("Unknown"); + case COL_STATUS: + return tr("Pending"); + default: + return QVariant(); } } else { - return index.row(); + switch (index.column()) { + case COL_NAME: + return m_Manager->getFileName(index.row()); + case COL_SIZE: + return sizeFormat(m_Manager->getFileSize(index.row())); + case COL_STATUS: + switch (m_Manager->getState(index.row())) { + case DownloadManager::STATE_STARTED: + return tr("Started"); + case DownloadManager::STATE_DOWNLOADING: + return m_Manager->getProgress(index.row()).second; + case DownloadManager::STATE_CANCELING: + return tr("Canceling"); + case DownloadManager::STATE_PAUSING: + return tr("Pausing"); + case DownloadManager::STATE_CANCELED: + return tr("Canceled"); + case DownloadManager::STATE_PAUSED: + return tr("Paused"); + case DownloadManager::STATE_ERROR: + return tr("Error"); + case DownloadManager::STATE_FETCHINGMODINFO: + return tr("Fetching Info 1"); + case DownloadManager::STATE_FETCHINGFILEINFO: + return tr("Fetching Info 2"); + case DownloadManager::STATE_READY: + return tr("Downloaded"); + case DownloadManager::STATE_INSTALLED: + return tr("Installed"); + case DownloadManager::STATE_UNINSTALLED: + return tr("Uninstalled"); + default: + return QVariant(); + } + default: + return QVariant(); + } } } else if (role == Qt::ToolTipRole) { - if (index.row() < m_Manager->numTotalDownloads()) { + if (pendingDownload) { + return tr("pending download"); + } else { QString text = m_Manager->getFileName(index.row()) + "\n"; if (m_Manager->isInfoIncomplete(index.row())) { text += tr("Information missing, please select \"Query Info\" from the context menu to re-retrieve."); @@ -101,8 +138,6 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const return QString("%1 (ID %2) %3
%4").arg(info->modName).arg(m_Manager->getModID(index.row())).arg(info->version.canonicalString()).arg(info->description); } return text; - } else { - return tr("pending download"); } } else { return QVariant(); diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp index 1a2606c9..5e455529 100644 --- a/src/downloadlistsortproxy.cpp +++ b/src/downloadlistsortproxy.cpp @@ -37,8 +37,8 @@ void DownloadListSortProxy::updateFilter(const QString &filter) bool DownloadListSortProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const { - int leftIndex = left.data().toInt(); - int rightIndex = right.data().toInt(); + int leftIndex = left.row(); + int rightIndex = right.row(); if ((leftIndex < m_Manager->numTotalDownloads()) && (rightIndex < m_Manager->numTotalDownloads())) { if (left.column() == DownloadList::COL_NAME) { diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp index b534b95b..e033c202 100644 --- a/src/downloadlistwidgetcompact.cpp +++ b/src/downloadlistwidgetcompact.cpp @@ -124,7 +124,6 @@ void DownloadListWidgetCompactDelegate::paintRegularDownload(int downloadIndex) name.append("..."); } m_NameLabel->setText(name); - DownloadManager::DownloadState state = m_Manager->getState(downloadIndex); if (m_SizeLabel != nullptr) { -- cgit v1.3.1 From cfb941082e27925279535cade18d2b3c912c8930 Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Sun, 30 Dec 2018 19:41:05 +0100 Subject: Add downloadlist styling tweaks --- src/downloadlist.cpp | 33 +++++++++++++++++++++++++-------- src/downloadlist.h | 2 ++ src/downloadlistsortproxy.cpp | 4 ++-- src/mainwindow.cpp | 7 +++++-- src/organizer_en.ts | 38 +++++++++++++++++++------------------- 5 files changed, 53 insertions(+), 31 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 178e4083..d78e97f9 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -20,12 +20,14 @@ along with Mod Organizer. If not, see . #include "downloadlist.h" #include "downloadmanager.h" #include +#include #include DownloadList::DownloadList(DownloadManager *manager, QObject *parent) : QAbstractTableModel(parent), m_Manager(manager) + , m_FontMetrics(QFont()) { connect(m_Manager, SIGNAL(update(int)), this, SLOT(update(int))); connect(m_Manager, SIGNAL(aboutToUpdate()), this, SLOT(aboutToUpdate())); @@ -84,8 +86,6 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const return tr("Unknown"); case COL_STATUS: return tr("Pending"); - default: - return QVariant(); } } else { switch (index.column()) { @@ -119,13 +119,21 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const return tr("Installed"); case DownloadManager::STATE_UNINSTALLED: return tr("Uninstalled"); - default: - return QVariant(); } - default: - return QVariant(); } } + } else if (role == Qt::ForegroundRole) { + if (pendingDownload) { + return QColor(Qt::darkBlue); + } else if (index.column() == COL_STATUS) { + DownloadManager::DownloadState state = m_Manager->getState(index.row()); + if (state == DownloadManager::STATE_READY) + return QColor(Qt::darkGreen); + else if (state == DownloadManager::STATE_UNINSTALLED) + return QColor(Qt::darkYellow); + else if (state == DownloadManager::STATE_PAUSED) + return QColor(Qt::darkRed); + } } else if (role == Qt::ToolTipRole) { if (pendingDownload) { return tr("pending download"); @@ -139,9 +147,18 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const } return text; } - } else { - return QVariant(); + } else if (role == Qt::TextAlignmentRole) { + if (index.column() == COL_SIZE) + return Qt::AlignVCenter | Qt::AlignRight; + else + return Qt::AlignVCenter | Qt::AlignLeft; + } else if (role == Qt::SizeHintRole) { + QSize temp = m_FontMetrics.size(Qt::TextSingleLine, data(index, Qt::DisplayRole).toString()); + temp.rwidth() += 20; + temp.rheight() += 12; + return temp; } + return QVariant(); } diff --git a/src/downloadlist.h b/src/downloadlist.h index 1a5ca0b2..d7764763 100644 --- a/src/downloadlist.h +++ b/src/downloadlist.h @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see . #define DOWNLOADLIST_H #include +#include class DownloadManager; @@ -90,6 +91,7 @@ public slots: private: DownloadManager *m_Manager; + QFontMetrics m_FontMetrics; QString sizeFormat(quint64 size) const; }; diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp index 5e455529..1df3a9f1 100644 --- a/src/downloadlistsortproxy.cpp +++ b/src/downloadlistsortproxy.cpp @@ -47,9 +47,9 @@ bool DownloadListSortProxy::lessThan(const QModelIndex &left, DownloadManager::DownloadState leftState = m_Manager->getState(left.row()); DownloadManager::DownloadState rightState = m_Manager->getState(right.row()); if (leftState == rightState) - return m_Manager->getFileTime(left.row()) > m_Manager->getFileTime(right.row()); + return m_Manager->getFileTime(left.row()) < m_Manager->getFileTime(right.row()); else - return leftState < rightState; + return leftState > rightState; } else if(left.column() == DownloadList::COL_SIZE){ return m_Manager->getFileSize(left.row()) < m_Manager->getFileSize(right.row()); } else { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9ae7e2de..b2876e33 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5154,8 +5154,11 @@ void MainWindow::initDownloadList() ui->downloadView->setModel(sortProxy); ui->downloadView->setManager(m_OrganizerCore.downloadManager()); - //ui->downloadView->sortByColumn(1, Qt::DescendingOrder); - ui->downloadView->header()->resizeSections(QHeaderView::Stretch); + ui->downloadView->setUniformRowHeights(true); + ui->downloadView->header()->setStretchLastSection(false); + ui->downloadView->header()->setSectionResizeMode(QHeaderView::Interactive); + ui->downloadView->header()->setSectionResizeMode(0, QHeaderView::Stretch); + ui->downloadView->sortByColumn(1, Qt::DescendingOrder); connect(ui->downloadView, SIGNAL(installDownload(int)), &m_OrganizerCore, SLOT(installDownload(int))); connect(ui->downloadView, SIGNAL(queryInfo(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfo(int))); diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 71a438cb..6c1488eb 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -292,97 +292,97 @@ p, li { white-space: pre-wrap; } DownloadList - + Name - + Size - + Status - + < game %1 mod %2 file %3 > - + Unknown - + Pending - + Started - + Canceling - + Pausing - + Canceled - + Paused - + Error - + Fetching Info 1 - + Fetching Info 2 - + Downloaded - + Installed - + Uninstalled - + pending download - + Information missing, please select "Query Info" from the context menu to re-retrieve. -- cgit v1.3.1 From c11ff7e2db09514304cef35a650aa3fbef27dd16 Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Sun, 30 Dec 2018 22:13:15 +0100 Subject: Add icon for incomplete download info, add download progress delegate --- src/downloadlist.cpp | 5 +++++ src/downloadlist.h | 1 - src/downloadlistwidget.cpp | 26 ++++++++++++++++++++++++++ src/downloadlistwidget.h | 18 ++++++++++++++++++ src/downloadmanager.cpp | 6 +++--- src/mainwindow.cpp | 7 ++++--- src/mainwindow.h | 2 +- 7 files changed, 57 insertions(+), 8 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index d78e97f9..09f6968c 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see . #include "downloadmanager.h" #include #include +#include #include @@ -147,6 +148,10 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const } return text; } + } else if (role == Qt::DecorationRole && index.column() == COL_NAME) { + if (!pendingDownload && m_Manager->getState(index.row()) >= DownloadManager::STATE_READY + && m_Manager->isInfoIncomplete(index.row())) + return QIcon(":/MO/gui/warning_16"); } else if (role == Qt::TextAlignmentRole) { if (index.column() == COL_SIZE) return Qt::AlignVCenter | Qt::AlignRight; diff --git a/src/downloadlist.h b/src/downloadlist.h index d7764763..3b33fc40 100644 --- a/src/downloadlist.h +++ b/src/downloadlist.h @@ -23,7 +23,6 @@ along with Mod Organizer. If not, see . #include #include - class DownloadManager; diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 9cf8e097..6a85c317 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -17,13 +17,39 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ +#include "downloadlist.h" #include "downloadlistwidget.h" #include #include #include #include #include +#include +void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QModelIndex sourceIndex = m_SortProxy->mapToSource(index); + if (sourceIndex.column() == DownloadList::COL_STATUS && sourceIndex.row() < m_Manager->numTotalDownloads() + && m_Manager->getState(sourceIndex.row()) == DownloadManager::STATE_DOWNLOADING) { + bool pendingDownload = sourceIndex.row() >= m_Manager->numTotalDownloads(); + QStyleOptionProgressBar progressBarOption; + progressBarOption.state = QStyle::State_Enabled; + progressBarOption.direction = QApplication::layoutDirection(); + progressBarOption.rect = option.rect; + progressBarOption.fontMetrics = QApplication::fontMetrics(); + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.textAlignment = Qt::AlignCenter; + progressBarOption.textVisible = true; + progressBarOption.progress = m_Manager->getProgress(sourceIndex.row()).first; + progressBarOption.text = m_Manager->getProgress(sourceIndex.row()).second; + + QApplication::style()->drawControl(QStyle::CE_ProgressBar, + &progressBarOption, painter); + } else { + QStyledItemDelegate::paint(painter, option, index); + } +} DownloadListWidget::DownloadListWidget(QWidget *parent) : QTreeView(parent) diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index 0c17de87..c19e4473 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -21,11 +21,14 @@ along with Mod Organizer. If not, see . #define DOWNLOADLISTWIDGET_H #include "downloadmanager.h" +#include "downloadlistsortproxy.h" #include #include #include #include #include +#include + namespace Ui { class DownloadListWidget; @@ -33,6 +36,21 @@ namespace Ui { class DownloadManager; +class DownloadProgressDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + DownloadProgressDelegate(DownloadManager *manager, DownloadListSortProxy *sortProxy, QWidget *parent = 0) : QStyledItemDelegate(parent), m_Manager(manager), m_SortProxy(sortProxy) {} + + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + +private: + DownloadManager *m_Manager; + DownloadListSortProxy *m_SortProxy; +}; + class DownloadListWidget : public QTreeView { Q_OBJECT diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 9f07b030..b94b5864 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -64,7 +64,7 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createNew(const Mo info->m_DownloadID = s_NextDownloadID++; info->m_StartTime.start(); info->m_PreResumeSize = 0LL; - info->m_Progress = std::make_pair(0, " 0.0 Bytes/s "); + info->m_Progress = std::make_pair(0, "0.0 B/s "); info->m_ResumePos = 0; info->m_FileInfo = new ModRepositoryFileInfo(*fileInfo); info->m_Urls = URLs; @@ -1338,7 +1338,7 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) QString unit; if (speed < 1000) { - unit = "Bytes/s"; + unit = "B/s"; } else if (speed < 1000*1024) { speed /= 1024; @@ -1349,7 +1349,7 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) unit = "MB/s"; } - info->m_Progress.second = QString::fromLatin1("%1% - %2 %3").arg(info->m_Progress.first).arg(speed, 8, 'f', 1,' ').arg(unit, -8, ' '); + info->m_Progress.second = QString::fromLatin1("%1% - %2 %3").arg(info->m_Progress.first).arg(QString::number(speed, 'f', 1)).arg(unit); TaskProgressManager::instance().updateProgress(info->m_TaskProgressId, bytesReceived, bytesTotal); emit update(index); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b2876e33..4f60ae16 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -319,6 +319,7 @@ MainWindow::MainWindow(QSettings &initSettings //ui->bsaList->setLocalMoveOnly(true); + initDownloadView(); bool pluginListAdjusted = registerWidgetState(ui->espList->objectName(), ui->espList->header(), "plugin_list_state"); registerWidgetState(ui->dataTree->objectName(), ui->dataTree->header()); registerWidgetState(ui->downloadView->objectName(), @@ -340,8 +341,6 @@ MainWindow::MainWindow(QSettings &initSettings ui->openFolderMenu->setMenu(openFolderMenu()); - initDownloadList(); - ui->savegameList->installEventFilter(this); ui->savegameList->setMouseTracking(true); @@ -5145,15 +5144,17 @@ void MainWindow::on_actionEndorseMO_triggered() } -void MainWindow::initDownloadList() +void MainWindow::initDownloadView() { 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->setObjectName("downloadView"); ui->downloadView->setModel(sortProxy); ui->downloadView->setManager(m_OrganizerCore.downloadManager()); + ui->downloadView->setItemDelegate(new DownloadProgressDelegate(m_OrganizerCore.downloadManager(), sortProxy, ui->downloadView)); ui->downloadView->setUniformRowHeights(true); ui->downloadView->header()->setStretchLastSection(false); ui->downloadView->header()->setSectionResizeMode(QHeaderView::Interactive); diff --git a/src/mainwindow.h b/src/mainwindow.h index 93f2ed5f..13a66a8e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -246,7 +246,7 @@ private: bool populateMenuCategories(QMenu *menu, int targetID); - void initDownloadList(); + void initDownloadView(); // remove invalid category-references from mods void fixCategories(); -- cgit v1.3.1 From 03823a433a27bb5f9a94973c47e1408dd83cc5c0 Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Mon, 31 Dec 2018 02:15:47 +0100 Subject: Add qss styling options for progress bar and compact mode widgets --- src/downloadlist.cpp | 13 +++---------- src/downloadlistwidget.cpp | 30 ++++++++++++++++-------------- src/mainwindow.cpp | 13 +++++++++++++ src/mainwindow.h | 1 + 4 files changed, 33 insertions(+), 24 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 09f6968c..6d79b0f5 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -98,8 +98,6 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const switch (m_Manager->getState(index.row())) { case DownloadManager::STATE_STARTED: return tr("Started"); - case DownloadManager::STATE_DOWNLOADING: - return m_Manager->getProgress(index.row()).second; case DownloadManager::STATE_CANCELING: return tr("Canceling"); case DownloadManager::STATE_PAUSING: @@ -153,15 +151,10 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const && m_Manager->isInfoIncomplete(index.row())) return QIcon(":/MO/gui/warning_16"); } else if (role == Qt::TextAlignmentRole) { - if (index.column() == COL_SIZE) - return Qt::AlignVCenter | Qt::AlignRight; - else + if (index.column() == COL_NAME) return Qt::AlignVCenter | Qt::AlignLeft; - } else if (role == Qt::SizeHintRole) { - QSize temp = m_FontMetrics.size(Qt::TextSingleLine, data(index, Qt::DisplayRole).toString()); - temp.rwidth() += 20; - temp.rheight() += 12; - return temp; + else + return Qt::AlignVCenter | Qt::AlignRight; } return QVariant(); } diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 6a85c317..e908faf3 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -32,20 +32,22 @@ void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewIt if (sourceIndex.column() == DownloadList::COL_STATUS && sourceIndex.row() < m_Manager->numTotalDownloads() && m_Manager->getState(sourceIndex.row()) == DownloadManager::STATE_DOWNLOADING) { bool pendingDownload = sourceIndex.row() >= m_Manager->numTotalDownloads(); - QStyleOptionProgressBar progressBarOption; - progressBarOption.state = QStyle::State_Enabled; - progressBarOption.direction = QApplication::layoutDirection(); - progressBarOption.rect = option.rect; - progressBarOption.fontMetrics = QApplication::fontMetrics(); - progressBarOption.minimum = 0; - progressBarOption.maximum = 100; - progressBarOption.textAlignment = Qt::AlignCenter; - progressBarOption.textVisible = true; - progressBarOption.progress = m_Manager->getProgress(sourceIndex.row()).first; - progressBarOption.text = m_Manager->getProgress(sourceIndex.row()).second; - - QApplication::style()->drawControl(QStyle::CE_ProgressBar, - &progressBarOption, painter); + QProgressBar progressBarOption; + progressBarOption.setProperty("compact", option.widget->property("compact")); + progressBarOption.setMinimum(0); + progressBarOption.setMaximum(100); + progressBarOption.setAlignment(Qt::AlignCenter); + progressBarOption.resize(option.rect.width(), option.rect.height()); + progressBarOption.setValue(m_Manager->getProgress(sourceIndex.row()).first); + progressBarOption.setFormat(m_Manager->getProgress(sourceIndex.row()).second); + + // paint the background with default delegate first to preserve table cell styling + QStyledItemDelegate::paint(painter, option, index); + + painter->save(); + painter->translate(option.rect.topLeft()); + progressBarOption.render(painter); + painter->restore(); } else { QStyledItemDelegate::paint(painter, option, index); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4f60ae16..328c0b2d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4655,6 +4655,8 @@ void MainWindow::on_actionSettings_triggered() NexusInterface::instance(&m_PluginContainer)->setNMMVersion(settings.getNMMVersion()); + updateDownloadView(); + m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType(), settings.executablesBlacklist()); m_OrganizerCore.cycleDiagnostics(); } @@ -4709,6 +4711,7 @@ void MainWindow::languageChange(const QString &newLanguage) createHelpWidget(); + updateDownloadView(); updateProblemsButton(); ui->listOptionsBtn->setMenu(modListContextMenu()); @@ -5160,6 +5163,7 @@ void MainWindow::initDownloadView() ui->downloadView->header()->setSectionResizeMode(QHeaderView::Interactive); ui->downloadView->header()->setSectionResizeMode(0, QHeaderView::Stretch); ui->downloadView->sortByColumn(1, Qt::DescendingOrder); + updateDownloadView(); connect(ui->downloadView, SIGNAL(installDownload(int)), &m_OrganizerCore, SLOT(installDownload(int))); connect(ui->downloadView, SIGNAL(queryInfo(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfo(int))); @@ -5173,6 +5177,15 @@ void MainWindow::initDownloadView() connect(ui->downloadView, SIGNAL(resumeDownload(int)), this, SLOT(resumeDownload(int))); } +void MainWindow::updateDownloadView() +{ + if (m_OrganizerCore.settings().compactDownloads()) + ui->downloadView->setProperty("compact", true); + else + ui->downloadView->setProperty("compact", false); + ui->downloadView->style()->unpolish(ui->downloadView); + ui->downloadView->style()->polish(ui->downloadView); +} void MainWindow::modDetailsUpdated(bool) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 13a66a8e..a419b797 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -247,6 +247,7 @@ private: bool populateMenuCategories(QMenu *menu, int targetID); void initDownloadView(); + void updateDownloadView(); // remove invalid category-references from mods void fixCategories(); -- cgit v1.3.1 From b8babae78a452071c3a707347d21a06fef759bab Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Mon, 31 Dec 2018 18:48:53 +0100 Subject: Fix download layout bug, port most of remaining themes --- src/downloadlist.cpp | 66 ++++++++++++--------------------- src/downloadlist.h | 1 - src/downloadlistwidget.cpp | 63 ++++++++++++++++--------------- src/downloadlistwidget.h | 2 - src/mainwindow.cpp | 1 + src/stylesheets/Paper Automata.qss | 27 +++++++------- src/stylesheets/Paper Dark by 6788.qss | 35 ++++++++--------- src/stylesheets/Paper Light by 6788.qss | 5 --- src/stylesheets/dark.qss | 9 ++++- src/stylesheets/dracula.qss | 22 ++++++++++- src/stylesheets/skyrim.qss | 10 ++++- src/stylesheets/vs15 Dark-Green.qss | 14 +++++-- src/stylesheets/vs15 Dark-Orange.qss | 14 +++++-- src/stylesheets/vs15 Dark-Purple.qss | 14 +++++-- src/stylesheets/vs15 Dark-Red.qss | 14 +++++-- src/stylesheets/vs15 Dark-Yellow.qss | 14 +++++-- src/stylesheets/vs15 Dark.qss | 14 +++++-- 17 files changed, 191 insertions(+), 134 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 6d79b0f5..fa2cc077 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -28,7 +28,6 @@ along with Mod Organizer. If not, see . DownloadList::DownloadList(DownloadManager *manager, QObject *parent) : QAbstractTableModel(parent), m_Manager(manager) - , m_FontMetrics(QFont()) { connect(m_Manager, SIGNAL(update(int)), this, SLOT(update(int))); connect(m_Manager, SIGNAL(aboutToUpdate()), this, SLOT(aboutToUpdate())); @@ -81,50 +80,35 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const if (pendingDownload) { std::tuple nexusids = m_Manager->getPendingDownload(index.row() - m_Manager->numTotalDownloads()); switch (index.column()) { - case COL_NAME: - return tr("< game %1 mod %2 file %3 >").arg(std::get<0>(nexusids)).arg(std::get<1>(nexusids)).arg(std::get<2>(nexusids)); - case COL_SIZE: - return tr("Unknown"); - case COL_STATUS: - return tr("Pending"); + case COL_NAME: return tr("< game %1 mod %2 file %3 >").arg(std::get<0>(nexusids)).arg(std::get<1>(nexusids)).arg(std::get<2>(nexusids)); + case COL_SIZE: return tr("Unknown"); + case COL_STATUS: return tr("Pending"); } } else { switch (index.column()) { - case COL_NAME: - return m_Manager->getFileName(index.row()); - case COL_SIZE: - return sizeFormat(m_Manager->getFileSize(index.row())); + case COL_NAME: return m_Manager->getFileName(index.row()); + case COL_SIZE: return sizeFormat(m_Manager->getFileSize(index.row())); case COL_STATUS: switch (m_Manager->getState(index.row())) { - case DownloadManager::STATE_STARTED: - return tr("Started"); - case DownloadManager::STATE_CANCELING: - return tr("Canceling"); - case DownloadManager::STATE_PAUSING: - return tr("Pausing"); - case DownloadManager::STATE_CANCELED: - return tr("Canceled"); - case DownloadManager::STATE_PAUSED: - return tr("Paused"); - case DownloadManager::STATE_ERROR: - return tr("Error"); - case DownloadManager::STATE_FETCHINGMODINFO: - return tr("Fetching Info 1"); - case DownloadManager::STATE_FETCHINGFILEINFO: - return tr("Fetching Info 2"); - case DownloadManager::STATE_READY: - return tr("Downloaded"); - case DownloadManager::STATE_INSTALLED: - return tr("Installed"); - case DownloadManager::STATE_UNINSTALLED: - return tr("Uninstalled"); + // STATE_DOWNLOADING handled by DownloadProgressDelegate + case DownloadManager::STATE_STARTED: return tr("Started"); + case DownloadManager::STATE_CANCELING: return tr("Canceling"); + case DownloadManager::STATE_PAUSING: return tr("Pausing"); + case DownloadManager::STATE_CANCELED: return tr("Canceled"); + case DownloadManager::STATE_PAUSED: return tr("Paused"); + case DownloadManager::STATE_ERROR: return tr("Error"); + case DownloadManager::STATE_FETCHINGMODINFO: return tr("Fetching Info 1"); + case DownloadManager::STATE_FETCHINGFILEINFO: return tr("Fetching Info 2"); + case DownloadManager::STATE_READY: return tr("Downloaded"); + case DownloadManager::STATE_INSTALLED: return tr("Installed"); + case DownloadManager::STATE_UNINSTALLED: return tr("Uninstalled"); } } } - } else if (role == Qt::ForegroundRole) { + } else if (role == Qt::ForegroundRole && index.column() == COL_STATUS) { if (pendingDownload) { return QColor(Qt::darkBlue); - } else if (index.column() == COL_STATUS) { + } else { DownloadManager::DownloadState state = m_Manager->getState(index.row()); if (state == DownloadManager::STATE_READY) return QColor(Qt::darkGreen); @@ -135,7 +119,7 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const } } else if (role == Qt::ToolTipRole) { if (pendingDownload) { - return tr("pending download"); + return tr("Pending download"); } else { QString text = m_Manager->getFileName(index.row()) + "\n"; if (m_Manager->isInfoIncomplete(index.row())) { @@ -168,13 +152,12 @@ void DownloadList::aboutToUpdate() void DownloadList::update(int row) { - if (row < 0) { + if (row < 0) emit endResetModel(); - } else if (row < this->rowCount()) { + else if (row < this->rowCount()) emit dataChanged(this->index(row, 0, QModelIndex()), this->index(row, this->columnCount(QModelIndex())-1, QModelIndex())); - } else { + else qCritical("invalid row %d in download list, update failed", row); - } } QString DownloadList::sizeFormat(quint64 size) const @@ -187,8 +170,7 @@ QString DownloadList::sizeFormat(quint64 size) const QString unit("KB"); calc /= 1024.0; - while (calc >= 1024.0 && i.hasNext()) - { + while (calc >= 1024.0 && i.hasNext()) { unit = i.next(); calc /= 1024.0; } diff --git a/src/downloadlist.h b/src/downloadlist.h index 3b33fc40..4e0b5ef4 100644 --- a/src/downloadlist.h +++ b/src/downloadlist.h @@ -90,7 +90,6 @@ public slots: private: DownloadManager *m_Manager; - QFontMetrics m_FontMetrics; QString sizeFormat(quint64 size) const; }; diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index ac327f7b..f69f9e9f 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -34,13 +34,17 @@ void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewIt bool pendingDownload = sourceIndex.row() >= m_Manager->numTotalDownloads(); QProgressBar progressBar; progressBar.setProperty("downloadView", option.widget->property("downloadView")); + progressBar.setProperty("downloadProgress", true); progressBar.resize(option.rect.width(), option.rect.height()); - progressBar.setTextVisible(false); + progressBar.setTextVisible(true); + progressBar.setAlignment(Qt::AlignCenter); progressBar.setMinimum(0); progressBar.setMaximum(100); progressBar.setValue(m_Manager->getProgress(sourceIndex.row()).first); + progressBar.setFormat(m_Manager->getProgress(sourceIndex.row()).second); progressBar.setStyle(QApplication::style()); + /* QLabel progressText; progressText.setProperty("downloadView", option.widget->property("downloadView")); progressText.setProperty("downloadProgress", true); @@ -49,6 +53,7 @@ void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewIt progressText.setAlignment(Qt::AlignCenter); progressText.setText(m_Manager->getProgress(sourceIndex.row()).second); progressText.setStyle(QApplication::style()); + */ // paint the background with default delegate first to preserve table cell styling QStyledItemDelegate::paint(painter, option, index); @@ -56,7 +61,7 @@ void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewIt painter->save(); painter->translate(option.rect.topLeft()); progressBar.render(painter); - progressText.render(painter); + //progressText.render(painter); painter->restore(); } else { QStyledItemDelegate::paint(painter, option, index); @@ -82,11 +87,11 @@ void DownloadListWidget::setManager(DownloadManager *manager) void DownloadListWidget::onDoubleClick(const QModelIndex &index) { QModelIndex sourceIndex = qobject_cast(model())->mapToSource(index); - if (m_Manager->getState(sourceIndex.row()) >= DownloadManager::STATE_READY) { + 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)) { + else if ((m_Manager->getState(sourceIndex.row()) >= DownloadManager::STATE_PAUSED) + || (m_Manager->getState(sourceIndex.row()) == DownloadManager::STATE_PAUSING)) emit resumeDownload(sourceIndex.row()); - } } void DownloadListWidget::onCustomContextMenu(const QPoint &point) @@ -94,38 +99,34 @@ void DownloadListWidget::onCustomContextMenu(const QPoint &point) 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)) { + if (m_Manager->isInfoIncomplete(m_ContextRow)) menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo())); - } - else { + 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) { + if (hidden) menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView())); - } - else { + else menu.addAction(tr("Hide"), this, SLOT(issueRemoveFromView())); - } - } - else if (state == DownloadManager::STATE_DOWNLOADING) { + } 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)) { + } 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())); @@ -137,14 +138,12 @@ void DownloadListWidget::onCustomContextMenu(const QPoint &point) menu.addAction(tr("Delete Uninstalled..."), this, SLOT(issueDeleteUninstalled())); menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll())); + menu.addSeparator(); 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(); + } else { menu.addAction(tr("Un-Hide All..."), this, SLOT(issueRestoreToViewAll())); } @@ -163,11 +162,11 @@ void DownloadListWidget::issueQueryInfo() void DownloadListWidget::issueDelete() { - if (QMessageBox::question(nullptr, tr("Delete Files?"), - tr("This will permanently delete the selected download."), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - emit removeDownload(m_ContextRow, true); - } + if (QMessageBox::question(nullptr, tr("Delete Files?"), + tr("This will permanently delete the selected download."), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + emit removeDownload(m_ContextRow, true); + } } void DownloadListWidget::issueRemoveFromView() @@ -178,7 +177,7 @@ void DownloadListWidget::issueRemoveFromView() void DownloadListWidget::issueRestoreToView() { - emit restoreDownload(m_ContextRow); + emit restoreDownload(m_ContextRow); } void DownloadListWidget::issueRestoreToViewAll() @@ -237,8 +236,8 @@ void DownloadListWidget::issueDeleteCompleted() void DownloadListWidget::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) { + tr("This will remove all uninstalled downloads from this list and from disk."), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { emit removeDownload(-3, true); } } @@ -264,8 +263,8 @@ void DownloadListWidget::issueRemoveFromViewCompleted() 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)."), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + tr("This will remove all uninstalled downloads from this list (but NOT from disk)."), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { emit removeDownload(-3, false); } } diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index c19e4473..93ece07a 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -34,8 +34,6 @@ namespace Ui { class DownloadListWidget; } -class DownloadManager; - class DownloadProgressDelegate : public QStyledItemDelegate { Q_OBJECT diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b4d77085..f20665eb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5184,6 +5184,7 @@ void MainWindow::updateDownloadView() ui->downloadView->setProperty("downloadView", "standard"); ui->downloadView->style()->unpolish(ui->downloadView); ui->downloadView->style()->polish(ui->downloadView); + m_OrganizerCore.downloadManager()->refreshList(); } void MainWindow::modDetailsUpdated(bool) diff --git a/src/stylesheets/Paper Automata.qss b/src/stylesheets/Paper Automata.qss index 748e589e..572d3313 100644 --- a/src/stylesheets/Paper Automata.qss +++ b/src/stylesheets/Paper Automata.qss @@ -893,29 +893,28 @@ DownloadListWidget { background: transparent; } -DownloadListWidget QFrame, -DownloadListWidgetCompact, -DownloadListWidgetCompact QLabel { - /* an entry on the Downloads tab */ +DownloadListWidget::item:!selected { background: #DAD4BB; } -DownloadListWidget QFrame#frame { - /* outer box of an entry on the Downloads tab */ - border: 2px solid #DAD4BB; +DownloadListWidget[downloadView=standard]::item { + padding: 15px; + margin-bottom: 2px; } -DownloadListWidget QLabel#installLabel { - /* installed/done label */ - color: none; +QProgressBar[downloadView=standard] { + margin: 4px 0px 6px 0px; } /* Compact Downloads View */ -DownloadListWidgetCompact, -DownloadListWidgetCompact QLabel { - /* an entry on the Downloads tab */ - background: #DAD4BB; +DownloadListWidget[downloadView=compact]::item { + padding: 4px 4px 6px 4px; + margin-bottom: 2px; +} + +QProgressBar[downloadView=compact] { + margin: 1px 0px 3px 0px; } /* Categories Filter */ diff --git a/src/stylesheets/Paper Dark by 6788.qss b/src/stylesheets/Paper Dark by 6788.qss index 9f4db66f..ae6ea77b 100644 --- a/src/stylesheets/Paper Dark by 6788.qss +++ b/src/stylesheets/Paper Dark by 6788.qss @@ -919,29 +919,30 @@ QSlider::handle:hover { background: #242424; } -DownloadListWidget QFrame, -DownloadListWidgetCompact, -DownloadListWidgetCompact QLabel { - /* an entry on the Downloads tab */ - background: #141414; +DownloadListWidget[downloadView=standard]::item { + padding: 15px; + border-bottom: 2px solid #666666; } -DownloadListWidget#frame { - /* outer box of an entry on the Downloads tab */ - border: none; -} - -#installLabel { - /* installed/done label */ - color: none; +QProgressBar[downloadView=standard] { + background: transparent; + border: 2px solid #666666; + border-radius: 8px; + margin: 4px 0px 6px 0px; } /* Compact Downloads View */ -DownloadListWidgetCompact, -DownloadListWidgetCompact QLabel { - /* an entry on the Downloads tab */ - background: #141414; +DownloadListWidget[downloadView=compact]::item { + padding: 3px; + border-bottom: 2px solid #666666; +} + +QProgressBar[downloadView=compact] { + background: transparent; + border: 2px solid gray; + border-radius: 8px; + margin: 1px 0px 3px 0px; } /* Categories Filter */ diff --git a/src/stylesheets/Paper Light by 6788.qss b/src/stylesheets/Paper Light by 6788.qss index 3193b817..5e69b79d 100644 --- a/src/stylesheets/Paper Light by 6788.qss +++ b/src/stylesheets/Paper Light by 6788.qss @@ -940,11 +940,6 @@ QProgressBar[downloadView=standard] { margin: 4px 0px 6px 0px; } -QLabel[downloadProgress] { - qproperty-alignment: AlignCenter; - padding-bottom: 3px; -} - /* Compact Downloads View */ DownloadListWidget[downloadView=compact]::item { diff --git a/src/stylesheets/dark.qss b/src/stylesheets/dark.qss index d5a7aedf..5bbb0f0c 100644 --- a/src/stylesheets/dark.qss +++ b/src/stylesheets/dark.qss @@ -257,7 +257,6 @@ QProgressBar QProgressBar::chunk { background-color: #427683; - width: 20px; } QTabBar::tab @@ -366,4 +365,12 @@ QTreeView::branch:open:has-children:has-siblings DownloadListWidget QLabel#installLabel { color: none; +} + +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; } \ No newline at end of file diff --git a/src/stylesheets/dracula.qss b/src/stylesheets/dracula.qss index 99cf918d..33ce5f66 100644 --- a/src/stylesheets/dracula.qss +++ b/src/stylesheets/dracula.qss @@ -394,4 +394,24 @@ SaveGameInfoWidget { DownloadListWidget QLabel#installLabel { color: none; -} \ No newline at end of file +} + +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + +QProgressBar +{ + border: 2px solid grey; + border-radius: 5px; + text-align: center; +} + +QProgressBar::chunk +{ + background-color: #427683; +} diff --git a/src/stylesheets/skyrim.qss b/src/stylesheets/skyrim.qss index e4d87499..d36eac57 100644 --- a/src/stylesheets/skyrim.qss +++ b/src/stylesheets/skyrim.qss @@ -534,7 +534,7 @@ QProgressBar { background-color: transparent; color: transparent; height: 14px; - margin: 0 10px; + margin: 0 0px; border-width: 4px 21px; border-style: solid; border-color: transparent; @@ -542,6 +542,14 @@ QProgressBar { QProgressBar::chunk { background: url(./skyrim/progress-bar-chunk.png) center center repeat-x qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #95BED9, stop:0.78781 #6EB9CE); } +DownloadListWidget[downloadView=standard]::item { + padding: 15px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + /* Right Pane and Tab Bars #QTabWidget, #QTabBar */ QTabWidget::pane { border: none; diff --git a/src/stylesheets/vs15 Dark-Green.qss b/src/stylesheets/vs15 Dark-Green.qss index 5427b38a..10f923cb 100644 --- a/src/stylesheets/vs15 Dark-Green.qss +++ b/src/stylesheets/vs15 Dark-Green.qss @@ -532,8 +532,8 @@ QHeaderView::up-arrow { image: url(./vs15/sort-asc.png); margin-bottom: -37px; } -QTreeView#downloadView QHeaderView::up-arrow { - margin-bottom: -32px; } +DownloadListWidget QHeaderView::up-arrow { + margin-bottom: -47px; } QHeaderView::down-arrow { image: url(./vs15/sort-desc.png); @@ -599,11 +599,19 @@ QProgressBar { text-align: center; border-style: solid; border-width: 1px; - margin: 0 10px; } + margin: 0 0px; } QProgressBar::chunk { background: #06B025; } +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + /* Right Pane and Tab Bars #QTabWidget, #QTabBar */ QTabWidget::pane { border-color: #3F3F46; diff --git a/src/stylesheets/vs15 Dark-Orange.qss b/src/stylesheets/vs15 Dark-Orange.qss index fe65ece0..bbde1f82 100644 --- a/src/stylesheets/vs15 Dark-Orange.qss +++ b/src/stylesheets/vs15 Dark-Orange.qss @@ -533,8 +533,8 @@ QHeaderView::up-arrow { image: url(./vs15/sort-asc.png); margin-bottom: -37px; } -QTreeView#downloadView QHeaderView::up-arrow { - margin-bottom: -32px; } +DownloadListWidget QHeaderView::up-arrow { + margin-bottom: -47px; } QHeaderView::down-arrow { image: url(./vs15/sort-desc.png); @@ -600,11 +600,19 @@ QProgressBar { text-align: center; border-style: solid; border-width: 1px; - margin: 0 10px; } + margin: 0 0px; } QProgressBar::chunk { background: #06B025; } +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + /* Right Pane and Tab Bars #QTabWidget, #QTabBar */ QTabWidget::pane { border-color: #3F3F46; diff --git a/src/stylesheets/vs15 Dark-Purple.qss b/src/stylesheets/vs15 Dark-Purple.qss index eb2e8b82..faad7297 100644 --- a/src/stylesheets/vs15 Dark-Purple.qss +++ b/src/stylesheets/vs15 Dark-Purple.qss @@ -533,8 +533,8 @@ QHeaderView::up-arrow { image: url(./vs15/sort-asc.png); margin-bottom: -37px; } -QTreeView#downloadView QHeaderView::up-arrow { - margin-bottom: -32px; } +DownloadListWidget QHeaderView::up-arrow { + margin-bottom: -47px; } QHeaderView::down-arrow { image: url(./vs15/sort-desc.png); @@ -600,11 +600,19 @@ QProgressBar { text-align: center; border-style: solid; border-width: 1px; - margin: 0 10px; } + margin: 0px 0px; } QProgressBar::chunk { background: #06B025; } +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + /* Right Pane and Tab Bars #QTabWidget, #QTabBar */ QTabWidget::pane { border-color: #3F3F46; diff --git a/src/stylesheets/vs15 Dark-Red.qss b/src/stylesheets/vs15 Dark-Red.qss index ee363e0b..2ffcff68 100644 --- a/src/stylesheets/vs15 Dark-Red.qss +++ b/src/stylesheets/vs15 Dark-Red.qss @@ -533,8 +533,8 @@ QHeaderView::up-arrow { image: url(./vs15/sort-asc.png); margin-bottom: -37px; } -QTreeView#downloadView QHeaderView::up-arrow { - margin-bottom: -32px; } +DownloadListWidget QHeaderView::up-arrow { + margin-bottom: -47px; } QHeaderView::down-arrow { image: url(./vs15/sort-desc.png); @@ -600,11 +600,19 @@ QProgressBar { text-align: center; border-style: solid; border-width: 1px; - margin: 0 10px; } + margin: 0 0px; } QProgressBar::chunk { background: #06B025; } +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + /* Right Pane and Tab Bars #QTabWidget, #QTabBar */ QTabWidget::pane { border-color: #3F3F46; diff --git a/src/stylesheets/vs15 Dark-Yellow.qss b/src/stylesheets/vs15 Dark-Yellow.qss index 08dbe758..24afe005 100644 --- a/src/stylesheets/vs15 Dark-Yellow.qss +++ b/src/stylesheets/vs15 Dark-Yellow.qss @@ -533,8 +533,8 @@ QHeaderView::up-arrow { image: url(./vs15/sort-asc.png); margin-bottom: -37px; } -QTreeView#downloadView QHeaderView::up-arrow { - margin-bottom: -32px; } +DownloadListWidget QHeaderView::up-arrow { + margin-bottom: -47px; } QHeaderView::down-arrow { image: url(./vs15/sort-desc.png); @@ -600,11 +600,19 @@ QProgressBar { text-align: center; border-style: solid; border-width: 1px; - margin: 0 10px; } + margin: 0 0px; } QProgressBar::chunk { background: #06B025; } +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + /* Right Pane and Tab Bars #QTabWidget, #QTabBar */ QTabWidget::pane { border-color: #3F3F46; diff --git a/src/stylesheets/vs15 Dark.qss b/src/stylesheets/vs15 Dark.qss index 8c4d354e..6a551775 100644 --- a/src/stylesheets/vs15 Dark.qss +++ b/src/stylesheets/vs15 Dark.qss @@ -532,8 +532,8 @@ QHeaderView::up-arrow { image: url(./vs15/sort-asc.png); margin-bottom: -37px; } -QTreeView#downloadView QHeaderView::up-arrow { - margin-bottom: -32px; } +DownloadListWidget QHeaderView::up-arrow { + margin-bottom: -47px; } QHeaderView::down-arrow { image: url(./vs15/sort-desc.png); @@ -599,11 +599,19 @@ QProgressBar { text-align: center; border-style: solid; border-width: 1px; - margin: 0 10px; } + margin: 0 0px; } QProgressBar::chunk { background: #06B025; } +DownloadListWidget[downloadView=standard]::item { + padding: 16px; +} + +DownloadListWidget[downloadView=compact]::item { + padding: 4px; +} + /* Right Pane and Tab Bars #QTabWidget, #QTabBar */ QTabWidget::pane { border-color: #3F3F46; -- cgit v1.3.1 From fd6345cd4e49a135dd833e8567cb5bbe6887ebb9 Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Mon, 31 Dec 2018 20:29:03 +0100 Subject: Add 'download meta information' support to download tab --- src/downloadlist.cpp | 7 +- src/downloadlist.h | 3 + src/downloadlistwidget.cpp | 10 + src/downloadlistwidget.h | 4 + src/mainwindow.cpp | 7 +- src/organizer_en.ts | 502 ++++++++++++++++++++++----------------------- 6 files changed, 279 insertions(+), 254 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index fa2cc077..a0286aef 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -33,6 +33,11 @@ DownloadList::DownloadList(DownloadManager *manager, QObject *parent) connect(m_Manager, SIGNAL(aboutToUpdate()), this, SLOT(aboutToUpdate())); } +void DownloadList::setMetaDisplay(bool metaDisplay) +{ + m_MetaDisplay = metaDisplay; +} + int DownloadList::rowCount(const QModelIndex&) const { @@ -86,7 +91,7 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const } } else { switch (index.column()) { - case COL_NAME: return m_Manager->getFileName(index.row()); + case COL_NAME: return m_MetaDisplay ? m_Manager->getDisplayName(index.row()) : m_Manager->getFileName(index.row()); case COL_SIZE: return sizeFormat(m_Manager->getFileSize(index.row())); case COL_STATUS: switch (m_Manager->getState(index.row())) { diff --git a/src/downloadlist.h b/src/downloadlist.h index 4e0b5ef4..a504f209 100644 --- a/src/downloadlist.h +++ b/src/downloadlist.h @@ -52,6 +52,8 @@ public: **/ explicit DownloadList(DownloadManager *manager, QObject *parent = 0); + void setMetaDisplay(bool metaDisplay); + /** * @brief retrieve the number of rows to display. Invoked by Qt * @@ -90,6 +92,7 @@ public slots: private: DownloadManager *m_Manager; + bool m_MetaDisplay; QString sizeFormat(quint64 size) const; }; diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index f69f9e9f..6c7447c8 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -84,6 +84,16 @@ void DownloadListWidget::setManager(DownloadManager *manager) m_Manager = manager; } +void DownloadListWidget::setSourceModel(DownloadList *sourceModel) +{ + m_SourceModel = sourceModel; +} + +void DownloadListWidget::setMetaDisplay(bool metaDisplay) +{ + m_SourceModel->setMetaDisplay(metaDisplay); +} + void DownloadListWidget::onDoubleClick(const QModelIndex &index) { QModelIndex sourceIndex = qobject_cast(model())->mapToSource(index); diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index 93ece07a..c8d4fe6e 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see . #define DOWNLOADLISTWIDGET_H #include "downloadmanager.h" +#include "downloadlist.h" #include "downloadlistsortproxy.h" #include #include @@ -58,6 +59,8 @@ public: ~DownloadListWidget(); void setManager(DownloadManager *manager); + void setSourceModel(DownloadList *sourceModel); + void setMetaDisplay(bool metaDisplay); signals: void installDownload(int index); @@ -95,6 +98,7 @@ private slots: private: DownloadManager *m_Manager; + DownloadList *m_SourceModel; int m_ContextRow; }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2fcec086..63606833 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5150,12 +5150,14 @@ void MainWindow::on_actionEndorseMO_triggered() void MainWindow::initDownloadView() { + DownloadList *sourceModel = new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView); DownloadListSortProxy *sortProxy = new DownloadListSortProxy(m_OrganizerCore.downloadManager(), ui->downloadView); - sortProxy->setSourceModel(new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView)); + sortProxy->setSourceModel(sourceModel); 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->setSourceModel(sourceModel); + ui->downloadView->setModel(sortProxy); ui->downloadView->setManager(m_OrganizerCore.downloadManager()); ui->downloadView->setItemDelegate(new DownloadProgressDelegate(m_OrganizerCore.downloadManager(), sortProxy, ui->downloadView)); ui->downloadView->setUniformRowHeights(true); @@ -5183,6 +5185,7 @@ void MainWindow::updateDownloadView() ui->downloadView->setProperty("downloadView", "compact"); else ui->downloadView->setProperty("downloadView", "standard"); + ui->downloadView->setMetaDisplay(m_OrganizerCore.settings().metaDownloads()); ui->downloadView->style()->unpolish(ui->downloadView); ui->downloadView->style()->polish(ui->downloadView); m_OrganizerCore.downloadManager()->refreshList(); diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 6c1488eb..48936ca9 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -292,97 +292,97 @@ p, li { white-space: pre-wrap; } DownloadList - + Name - + Size - + Status - + < game %1 mod %2 file %3 > - + Unknown - + Pending - + Started - + Canceling - + Pausing - + Canceled - + Paused - + Error - + Fetching Info 1 - + Fetching Info 2 - + Downloaded - + Installed - + Uninstalled - - pending download + + Pending download - + Information missing, please select "Query Info" from the context menu to re-retrieve. @@ -390,145 +390,145 @@ p, li { white-space: pre-wrap; } DownloadListWidget - + Install - + Query Info - + Visit on Nexus - + Open File - - - + + + Show in Folder - - + + Delete - + Un-Hide - + Hide - + Cancel - + Pause - + Resume - + Delete Installed... - + Delete Uninstalled... - + Delete All... - + Hide Installed... - + Hide Uninstalled... - + Hide All... - + Un-Hide All... - - - - + + + + Delete Files? - + 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 remove all installed downloads from this list (but NOT from disk). - + This will remove all uninstalled downloads from this list (but NOT from disk). @@ -1608,7 +1608,7 @@ p, li { white-space: pre-wrap; } - + Refresh @@ -1792,7 +1792,7 @@ p, li { white-space: pre-wrap; } - + Update @@ -1803,7 +1803,7 @@ p, li { white-space: pre-wrap; } - + No Problems @@ -1833,7 +1833,7 @@ Right now this has very limited functionality - + Endorse Mod Organizer @@ -1853,288 +1853,288 @@ Right now this has very limited functionality - + Toolbar - + Desktop - + Start Menu - + There is no supported sort mechanism for this game. You will probably have to use a third-party tool. - + Crash on exit - + MO crashed while exiting. Some settings may not be saved. Error: %1 - + Problems - + There are potential problems with your setup - + Everything seems to be in order - + Endorse - + Won't Endorse - + Help on UI - + Documentation Wiki - + Report Issue - + Tutorials - + About - + About Qt - + Name - + Please enter a name for the new profile - + failed to create profile: %1 - + Show tutorial? - + You are starting Mod Organizer for the first time. Do you want to show a tutorial of its basic features? If you choose no you can always start the tutorial from the "Help"-menu. - + Downloads in progress - + There are still downloads in progress, do you really want to quit? - + Plugin "%1" failed: %2 - + Plugin "%1" failed - + Browse Mod Page - + Also in: <br> - + No conflict - + <Edit...> - + This bsa is enabled in the ini file so it may be required! - + Activating Network Proxy - + Notice: Your current MO version (%1) is lower than the previous version (%2).<br>The GUI may not downgrade gracefully, so you may experience oddities.<br>However, there should be no serious issues. - + Choose Mod - + Mod Archive - + Start Tutorial? - + You're about to start a tutorial. For technical reasons it's not possible to end the tutorial early. Continue? - + failed to spawn notepad.exe: %1 - + failed to change origin name: %1 - + failed to move "%1" from mod "%2" to "%3": %4 - + <Contains %1> - + <Checked> - + <Unchecked> - + <Update> - + <Mod Backup> - + <Managed by MO> - + <Managed outside MO> - + <No category> - + <Conflicted> - + <Not Endorsed> - + failed to rename mod: %1 - + Overwrite? - + This will replace the existing mod "%1". Continue? - + failed to remove mod "%1" - - - + + + failed to rename "%1" to "%2" - + @@ -2142,129 +2142,129 @@ Error: %1 - + Remove the following mods?<br><ul>%1</ul> - + failed to remove mod: %1 - - - + + + Failed - + Installation file no longer exists - + Mods installed with old versions of MO can't be reinstalled in this way. - + Failed to create backup. - + You need to be logged in with Nexus to resume a download - - - - + + + + You need to be logged in with Nexus to endorse - - + + Endorsing multiple mods will take a while. Please wait... - - + + Unendorsing multiple mods will take a while. Please wait... - + Failed to display overwrite dialog: %1 - + Opening Nexus Links - + You are trying to open %1 links to Nexus Mods. Are you sure you want to do this? - + Nexus ID for this Mod is unknown - + Web page for this mod is unknown - + <table cellspacing="5"><tr><th>Type</th><th>All</th><th>Visible</th><tr><td>Enabled mods:&emsp;</td><td align=right>%1 / %2</td><td align=right>%3 / %4</td></tr><tr><td>Unmanaged/DLCs:&emsp;</td><td align=right>%5</td><td align=right>%6</td></tr><tr><td>Mod backups:&emsp;</td><td align=right>%7</td><td align=right>%8</td></tr><tr><td>Separators:&emsp;</td><td align=right>%9</td><td align=right>%10</td></tr></table> - + <table cellspacing="4"><tr><th>Type</th><th>Active</th><th>Total</th></tr><tr><td>Active plugins:</td><td align=right>%1</td><td align=right>%2</td></tr><tr><td>Active ESMs:</td><td align=right>%3</td><td align=right>%4</td></tr><tr><td>Active ESPs:</td><td align=right>%7</td><td align=right>%8</td></tr><tr><td>Active ESMs+ESPs:</td><td align=right>%9</td><td align=right>%10</td></tr><tr><td>Active ESLs:</td><td align=right>%5</td><td align=right>%6</td></tr></table> - + Create Mod... - + This will create an empty mod. Please enter a name: - + A mod with this name already exists - + Create Separator... - + This will create a new separator. Please enter a name: - + A separator with this name already exists @@ -2276,7 +2276,7 @@ Please enter a name: - + Are you sure? @@ -2304,7 +2304,7 @@ This function will guess the versioning scheme under the assumption that the ins - + Sorry @@ -2603,13 +2603,13 @@ You can also use online editors and converters instead. - + Enable selected - + Disable selected @@ -2670,13 +2670,13 @@ You can also use online editors and converters instead. - + Exception: - + Unknown exception @@ -2745,330 +2745,330 @@ Click OK to restart MO now. - + failed to write to file %1 - + %1 written - + Select binary - + Binary - + Enter Name - + Please enter a name for the executable - + Not an executable - + This is not a recognized executable. - - + + Replace file? - + There already is a hidden version of this file. Replace it? - - + + File operation failed - - + + Failed to remove "%1". Maybe you lack the required file permissions? - + There already is a visible version of this file. Replace it? - - + + Set Priority - + Set the priority of the selected plugins - + file not found: %1 - + failed to generate preview for %1 - + Sorry, can't preview anything. This function currently does not support extracting from bsas. - + Update available - + Open/Execute - + Add as Executable - + Preview - + Un-Hide - + Hide - + Write To File... - + Do you want to endorse Mod Organizer on %1 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 @@ -5410,7 +5410,7 @@ If the folder was still in use, restart MO and try again. - + Mod Organizer @@ -5425,18 +5425,18 @@ If the folder was still in use, restart MO and try again. - + Please use "Help" from the toolbar to get usage instructions to all elements - - + + <Manage...> - + failed to parse profile %1: %2 @@ -5487,12 +5487,12 @@ If the folder was still in use, restart MO and try again. - + Script Extender - + Proxy DLL @@ -5708,28 +5708,28 @@ Select Show Details option to see the full change-log. - - + + attempt to store setting for unknown plugin "%1" - + Error - + Failed to create "%1", you may not have the necessary permission. path remains unchanged. - + Restart Mod Organizer? - + In order to reset the window geometries, MO must be restarted. Restart it now? @@ -6410,22 +6410,22 @@ programs you are intentionally running. - + Confirm - + Changing the mod directory affects all your profiles! Mods not present (or named differently) in the new location will be disabled in all profiles. There is no way to undo this unless you backed up your profiles manually. Proceed? - + Executables Blacklist - + Enter one executable per line to be blacklisted from the virtual file system. Mods and other virtualized files will not be visible to these executables and any executables launched by them. @@ -6436,47 +6436,47 @@ Example: - + Select base directory - + Select download directory - + Select mod directory - + Select cache directory - + Select profiles directory - + Select overwrite directory - + Select game executable - + Confirm? - + This will make all dialogs show up again where you checked the "Remember selection"-box. Continue? -- cgit v1.3.1 From 895556f257c2625ac53371089835aab0d01979be Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Mon, 31 Dec 2018 20:53:35 +0100 Subject: Add filetime column to download tab --- src/downloadlist.cpp | 12 +++++++----- src/downloadlist.h | 3 ++- src/downloadlistsortproxy.cpp | 4 +++- src/mainwindow.cpp | 2 +- src/mainwindow.ui | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index a0286aef..b21a5306 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -47,7 +47,7 @@ int DownloadList::rowCount(const QModelIndex&) const int DownloadList::columnCount(const QModelIndex&) const { - return 3; + return 4; } @@ -68,10 +68,11 @@ QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int if ((role == Qt::DisplayRole) && (orientation == Qt::Horizontal)) { switch (section) { - case COL_NAME : return tr("Name"); - case COL_SIZE : return tr("Size"); - case COL_STATUS : return tr("Status"); - default : return QVariant(); + case COL_NAME: return tr("Name"); + case COL_SIZE: return tr("Size"); + case COL_STATUS: return tr("Status"); + case COL_FILETIME: return tr("Filetime"); + default: return QVariant(); } } else { return QAbstractItemModel::headerData(section, orientation, role); @@ -93,6 +94,7 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const switch (index.column()) { case COL_NAME: return m_MetaDisplay ? m_Manager->getDisplayName(index.row()) : m_Manager->getFileName(index.row()); case COL_SIZE: return sizeFormat(m_Manager->getFileSize(index.row())); + case COL_FILETIME: return m_Manager->getFileTime(index.row()); case COL_STATUS: switch (m_Manager->getState(index.row())) { // STATE_DOWNLOADING handled by DownloadProgressDelegate diff --git a/src/downloadlist.h b/src/downloadlist.h index a504f209..2c32a397 100644 --- a/src/downloadlist.h +++ b/src/downloadlist.h @@ -39,7 +39,8 @@ public: enum EColumn { COL_NAME = 0, COL_STATUS, - COL_SIZE + COL_SIZE, + COL_FILETIME }; public: diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp index 1df3a9f1..dc97dc3e 100644 --- a/src/downloadlistsortproxy.cpp +++ b/src/downloadlistsortproxy.cpp @@ -50,8 +50,10 @@ bool DownloadListSortProxy::lessThan(const QModelIndex &left, return m_Manager->getFileTime(left.row()) < m_Manager->getFileTime(right.row()); else return leftState > rightState; - } else if(left.column() == DownloadList::COL_SIZE){ + } else if (left.column() == DownloadList::COL_SIZE) { return m_Manager->getFileSize(left.row()) < m_Manager->getFileSize(right.row()); + } else if (left.column() == DownloadList::COL_FILETIME) { + return m_Manager->getFileTime(left.row()) < m_Manager->getFileTime(right.row()); } else { return leftIndex < rightIndex; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 63606833..f913ad0a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5160,7 +5160,7 @@ void MainWindow::initDownloadView() ui->downloadView->setModel(sortProxy); ui->downloadView->setManager(m_OrganizerCore.downloadManager()); ui->downloadView->setItemDelegate(new DownloadProgressDelegate(m_OrganizerCore.downloadManager(), sortProxy, ui->downloadView)); - ui->downloadView->setUniformRowHeights(true); + ui->downloadView->setUniformRowHeights(false); ui->downloadView->header()->setStretchLastSection(false); ui->downloadView->header()->setSectionResizeMode(QHeaderView::Interactive); ui->downloadView->header()->setSectionResizeMode(0, QHeaderView::Stretch); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 771832fd..ba4b8d63 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1365,7 +1365,7 @@ p, li { white-space: pre-wrap; } 15 - true + false -- cgit v1.3.1 From 954785f83e466d56450af76db8a1f2e72a09ddaa Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Mon, 31 Dec 2018 21:01:15 +0100 Subject: Fix some compiler warnings --- src/downloadlist.cpp | 4 ++-- src/organizer_en.ts | 37 +++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index b21a5306..922de748 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -143,9 +143,9 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const return QIcon(":/MO/gui/warning_16"); } else if (role == Qt::TextAlignmentRole) { if (index.column() == COL_NAME) - return Qt::AlignVCenter | Qt::AlignLeft; + return QVariant(Qt::AlignVCenter | Qt::AlignLeft); else - return Qt::AlignVCenter | Qt::AlignRight; + return QVariant(Qt::AlignVCenter | Qt::AlignRight); } return QVariant(); } diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 8576b392..82fe46e8 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -307,82 +307,87 @@ p, li { white-space: pre-wrap; } - - < game %1 mod %2 file %3 > + + Filetime - Unknown + < game %1 mod %2 file %3 > + Unknown + + + + Pending - + Started - + Canceling - + Pausing - + Canceled - + Paused - + Error - + Fetching Info 1 - + Fetching Info 2 - + Downloaded - + Installed - + Uninstalled - + Pending download - + Information missing, please select "Query Info" from the context menu to re-retrieve. -- cgit v1.3.1