From 87c6b019bc3fa346fc1456b99713d4c1b01cf9cd Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Sat, 29 Dec 2018 14:56:43 -0600 Subject: Fix for download list refreshing, courtesy of bshd --- src/downloadlist.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 1e31973d..f470e57b 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -106,8 +106,7 @@ void DownloadList::update(int row) if (row < 0) { emit endResetModel(); } else if (row < this->rowCount()) { -#pragma message("updating only the one column is a hack") - emit dataChanged(this->index(row, 2, QModelIndex()), this->index(row, 2, QModelIndex())); + emit dataChanged(this->index(row, 0, QModelIndex()), this->index(row, this->columnCount(QModelIndex())-1, QModelIndex())); } else { qCritical("invalid row %d in download list, update failed", row); } -- cgit v1.3.1 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 ++- src/downloadlist.h | 2 +- src/downloadlistsortproxy.cpp | 14 +- src/downloadlistwidget.cpp | 10 +- src/downloadlistwidget.h | 16 +- src/mainwindow.cpp | 6 + src/mainwindow.ui | 2 +- src/organizer_en.ts | 657 +++++++++++++++++++++--------------------- 8 files changed, 398 insertions(+), 354 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; +} diff --git a/src/downloadlist.h b/src/downloadlist.h index e8833f0f..1a5ca0b2 100644 --- a/src/downloadlist.h +++ b/src/downloadlist.h @@ -38,7 +38,6 @@ public: enum EColumn { COL_NAME = 0, - COL_FILETIME, COL_STATUS, COL_SIZE }; @@ -92,6 +91,7 @@ private: DownloadManager *m_Manager; + QString sizeFormat(quint64 size) const; }; #endif // DOWNLOADLIST_H diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp index f791617a..ee16860a 100644 --- a/src/downloadlistsortproxy.cpp +++ b/src/downloadlistsortproxy.cpp @@ -42,13 +42,11 @@ bool DownloadListSortProxy::lessThan(const QModelIndex &left, if ((leftIndex < m_Manager->numTotalDownloads()) && (rightIndex < m_Manager->numTotalDownloads())) { if (left.column() == DownloadList::COL_NAME) { - return m_Manager->getFileName(leftIndex).compare(m_Manager->getFileName(rightIndex), Qt::CaseInsensitive) < 0; - } else if (left.column() == DownloadList::COL_FILETIME) { - return m_Manager->getFileTime(leftIndex) < m_Manager->getFileTime(rightIndex); + return m_Manager->getFileName(left.row()).compare(m_Manager->getFileName(right.row()), Qt::CaseInsensitive) < 0; } else if (left.column() == DownloadList::COL_STATUS) { - return m_Manager->getState(leftIndex) < m_Manager->getState(rightIndex); + return m_Manager->getState(left.row()) < m_Manager->getState(right.row()); } else if(left.column() == DownloadList::COL_SIZE){ - return m_Manager->getFileSize(leftIndex) < m_Manager->getFileSize(rightIndex); + return m_Manager->getFileSize(left.row()) < m_Manager->getFileSize(right.row()); } else { return leftIndex < rightIndex; } @@ -63,11 +61,9 @@ bool DownloadListSortProxy::filterAcceptsRow(int sourceRow, const QModelIndex&) if (m_CurrentFilter.length() == 0) { return true; } else if (sourceRow < m_Manager->numTotalDownloads()) { - int downloadIndex = sourceModel()->index(sourceRow, 0).data().toInt(); - QString displayedName = Settings::instance().metaDownloads() - ? m_Manager->getDisplayName(downloadIndex) - : m_Manager->getFileName(downloadIndex); + ? m_Manager->getDisplayName(sourceRow) + : m_Manager->getFileName(sourceRow); return displayedName.contains(m_CurrentFilter, Qt::CaseInsensitive); } else { return false; diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index c62d774c..b3d9b083 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -27,15 +27,19 @@ along with Mod Organizer. If not, see . DownloadListWidget::DownloadListWidget(QWidget *parent) - : QWidget(parent), ui(new Ui::DownloadListWidget) + : QTreeView(parent) { - ui->setupUi(this); + connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClick(QModelIndex))); } DownloadListWidget::~DownloadListWidget() { - delete ui; +} + +void DownloadListWidget::onDoubleClick(const QModelIndex &index) +{ + emit(resumeDownload(dynamic_cast(model())->mapToSource(index).row())); } diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index fe7f3b22..7a7a25f7 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -28,20 +28,22 @@ along with Mod Organizer. If not, see . #include namespace Ui { - class DownloadListWidget; + class DownloadListWidget; } -class DownloadListWidget : public QWidget +class DownloadListWidget : public QTreeView { - Q_OBJECT + Q_OBJECT public: - explicit DownloadListWidget(QWidget *parent = 0); - ~DownloadListWidget(); + explicit DownloadListWidget(QWidget *parent = 0); + ~DownloadListWidget(); +signals: + void resumeDownload(int index); -private: - Ui::DownloadListWidget *ui; +private slots: + void onDoubleClick(const QModelIndex &index); }; class DownloadManager; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 27ffc71e..5ca60ef1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5152,6 +5152,7 @@ void MainWindow::on_actionEndorseMO_triggered() void MainWindow::updateDownloadListDelegate() { + /* if (m_OrganizerCore.settings().compactDownloads()) { ui->downloadView->setItemDelegate( new DownloadListWidgetCompactDelegate(m_OrganizerCore.downloadManager(), @@ -5165,6 +5166,7 @@ void MainWindow::updateDownloadListDelegate() ui->downloadView, ui->downloadView)); } + */ DownloadListSortProxy *sortProxy = new DownloadListSortProxy(m_OrganizerCore.downloadManager(), ui->downloadView); sortProxy->setSourceModel(new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView)); @@ -5175,6 +5177,9 @@ void MainWindow::updateDownloadListDelegate() //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))); @@ -5185,6 +5190,7 @@ void MainWindow::updateDownloadListDelegate() 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))); + */ } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index b1ed8e5a..5dfd075b 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1303,7 +1303,7 @@ p, li { white-space: pre-wrap; } - + 320 diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 46bb42cf..9b61eafc 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -298,26 +298,31 @@ p, li { white-space: pre-wrap; } - Filetime + Size - Size + Status - - Done + + Installed - + + Downloaded + + + + Information missing, please select "Query Info" from the context menu to re-retrieve. - + pending download @@ -332,26 +337,26 @@ 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 @@ -559,165 +564,165 @@ p, li { white-space: pre-wrap; } DownloadListWidgetDelegate - + < game %1 mod %2 file %3 > - + Pending - + Fetching Info 1 - + Fetching Info 2 - - - - + + + + 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). - + 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... @@ -1620,7 +1625,7 @@ p, li { white-space: pre-wrap; } - + Create Backup @@ -1796,8 +1801,8 @@ p, li { white-space: pre-wrap; } - - + + Refresh @@ -2022,7 +2027,7 @@ Right now this has very limited functionality - + Endorse Mod Organizer @@ -2090,8 +2095,8 @@ Error: %1 - - + + Endorse @@ -2181,711 +2186,711 @@ Error: %1 - + 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" - - - - + + + + Confirm - + 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 - + This will move all files from overwrite into a new, regular mod. Please enter a name: - - + + Are you sure? - + About to recursively delete: - + Not logged in, endorsement information will be wrong - + Continue? - + The versioning scheme decides which version is considered newer than another. This function will guess the versioning scheme under the assumption that the installed version is outdated. - + Sorry - + I don't know a versioning scheme where %1 is newer than %2. - + Really enable all visible mods? - + Really disable all visible mods? - + Export to csv - + CSV (Comma Separated Values) is a format that can be imported in programs like Excel to create a spreadsheet. You can also use online editors and converters instead. - + Select what mods you want export: - + All installed mods - + Only active (checked) mods from your current profile - + All currently visible mods in the mod list - + Choose what Columns to export: - + Mod_Priority - + Mod_Name - + Mod_Status - + Primary_Category - + Nexus_ID - + Mod_Nexus_URL - + Mod_Version - + Install_Date - + Download_File_Name - + export failed: %1 - + Open Game folder - + Open MyGames folder - + Open INIs folder - + Open Instance folder - + Open Mods folder - + Open Profile folder - + Open Downloads folder - + Open MO2 Install folder - + Open MO2 Plugins folder - + Open MO2 Logs folder - + Install Mod... - + Create empty mod - + Create Separator - + Enable all visible - + Disable all visible - + Check all for update - + Export to csv... - - + + Send to - - + + Top - - + + Bottom - - + + Priority... - + Separator... - + All Mods - + Sync to Mods... - + Clear Overwrite... - - + + Open in Explorer - + Restore Backup - + Remove Backup... - - + + Change Categories - - + + Primary Category - + Rename Separator... - + Remove Separator... - + Select Color... - + Reset Color - + Change versioning scheme - + Un-ignore update - + Ignore update - - + + Enable selected - - + + Disable selected - + Rename Mod... - + Reinstall Mod - + Remove Mod... - + Un-Endorse - + Won't endorse - + Endorsement state unknown - + Ignore missing data - + Mark as converted/working - + Visit on Nexus - + Visit web page - + Information... - - + + Exception: - - + + Unknown exception - + <All> - + <Multiple> - + %1 more - + Are you sure you want to remove the following %n save(s)?<br><ul>%1</ul><br>Removed saves will be sent to the Recycle Bin. @@ -2893,12 +2898,12 @@ You can also use online editors and converters instead. - + Enable Mods... - + Delete %n save(s) @@ -2906,22 +2911,22 @@ You can also use online editors and converters instead. - + failed to remove %1 - + failed to create %1 - + Restarting MO - + Changing the managed game directory requires restarting MO. Any pending downloads will be paused. @@ -2929,7 +2934,7 @@ Click OK to restart MO now. - + Can't change download directory while downloads are in progress! @@ -3003,7 +3008,7 @@ Click OK to restart MO now. - + Set Priority @@ -3033,231 +3038,231 @@ Click OK to restart MO now. - + 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 @@ -4455,135 +4460,135 @@ p, li { white-space: pre-wrap; } - + Executable "%1" not found - + Start Steam? - + Steam is required to be running already to correctly start the game. Should MO try to start steam now? - + Error - + Windows Event Log Error - + The Windows Event Log service is disabled and/or not running. This prevents USVFS from running properly. Your mods may not be working in the executable that you are launching. Note that you may have to restart MO and/or your PC after the service is fixed. Continue launching %1? - + Blacklisted Executable - + The executable you are attempted to launch is blacklisted in the virtual file system. This will likely prevent the executable, and any executables that are launched by this one, from seeing any mods. This could extend to INI files, save games and any other virtualized files. Continue launching %1? - + No profile set - + Failed to refresh list of esps: %1 - + Multiple esps/esls activated, please check that they don't conflict. - + Download? - + A download has been started but no installed page plugin recognizes it. If you download anyway no information (i.e. version) will be associated with the download. Continue? - + failed to update mod list: %1 - - + + login successful - + Login failed - + Login failed, try again? - + login failed: %1. Download will not be associated with an account - + login failed: %1 - + login failed: %1. You need to log-in with Nexus to update MO. - + MO1 "Script Extender" load mechanism has left hook.dll in your game folder - - + + Description missing - + <a href="%1">hook.dll</a> has been found in your game folder (right click to copy the full path). This is most likely a leftover of setting the ModOrganizer 1 load mechanism to "Script Extender", in which case you must remove this file either by changing the load mechanism in ModOrganizer 1 or manually removing the file, otherwise the game is likely to crash and burn. - + failed to save load order: %1 - + The designated write target "%1" is not enabled. @@ -4730,94 +4735,94 @@ Continue? - + failed to update esp info for file %1 (source id: %2), error: %3 - + esp not found: %1 - - + + Confirm - + Really enable all plugins? - + Really disable all plugins? - + The file containing locked plugin indices is broken - - + + <b>Origin</b>: %1 - + <br><b><i>This plugin can't be disabled (enforced by the game).</i></b> - + Author - + Description - + Missing Masters - + Enabled Masters - + Loads Archives - + There are Archives connected to this plugin. Their assets will be added to your game, overwriting in case of conflicts following the plugin order. Loose files will always overwrite assets from Archives. (This flag only checks for Archives from the same mod as the plugin) - + Loads INI settings - + There is an ini file connected to this plugin. Its settings will be added to your game settings, overwriting in case of conflicts. - + This ESP is flagged as an ESL. It will adhere to the ESP load order but the records will be loaded in ESL space. - + failed to restore load order for %1 @@ -5619,13 +5624,13 @@ If the folder was still in use, restart MO and try again. - + <Manage...> - + failed to parse profile %1: %2 @@ -5661,12 +5666,12 @@ If the folder was still in use, restart MO and try again. - + failed to access %1 - + failed to set file time %1 -- 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 From 9dbac137ef235915d25142c4285e68925528eccc Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Thu, 21 Feb 2019 19:32:32 -0600 Subject: Limit the download file description to 4096 characters The description is limited to 255 characters on the Nexus so this is mostly protecting against invalid data. --- src/downloadlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 922de748..765ee646 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -133,7 +133,7 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const text += tr("Information missing, please select \"Query Info\" from the context menu to re-retrieve."); } else { const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(index.row()); - return QString("%1 (ID %2) %3
%4").arg(info->modName).arg(m_Manager->getModID(index.row())).arg(info->version.canonicalString()).arg(info->description); + return QString("%1 (ID %2) %3
%4").arg(info->modName).arg(m_Manager->getModID(index.row())).arg(info->version.canonicalString()).arg(info->description.chopped(4096)); } return text; } -- cgit v1.3.1 From 70bcd97bd23756a92507006e6202eee7af902cd3 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Thu, 7 Mar 2019 16:32:17 -0600 Subject: Use MD5 when querying info before bothering the user --- src/downloadlist.cpp | 5 +- src/downloadlistwidget.cpp | 9 +++- src/downloadlistwidget.h | 2 + src/downloadmanager.cpp | 114 ++++++++++++++++++++++++++++++++++++++++++++- src/downloadmanager.h | 37 +++++++++------ src/mainwindow.cpp | 1 + src/nexusinterface.cpp | 60 ++++++++++++++++++++++++ src/nexusinterface.h | 18 +++++++ 8 files changed, 225 insertions(+), 21 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 765ee646..dd72abbd 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -104,8 +104,9 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const 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_FETCHINGMODINFO: return tr("Fetching Info"); + case DownloadManager::STATE_FETCHINGFILEINFO: return tr("Fetching Info"); + case DownloadManager::STATE_FETCHINGMODINFO_MD5: return tr("Fetching Info"); case DownloadManager::STATE_READY: return tr("Downloaded"); case DownloadManager::STATE_INSTALLED: return tr("Installed"); case DownloadManager::STATE_UNINSTALLED: return tr("Uninstalled"); diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index be9d30e2..f0c4da1a 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -199,8 +199,8 @@ void DownloadListWidget::onCustomContextMenu(const QPoint &point) 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())); + if (m_Manager->isInfoIncomplete(m_ContextRow)) + menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfoMd5())); else menu.addAction(tr("Visit on Nexus"), this, SLOT(issueVisitOnNexus())); menu.addAction(tr("Open File"), this, SLOT(issueOpenFile())); @@ -252,6 +252,11 @@ void DownloadListWidget::issueQueryInfo() emit queryInfo(m_ContextRow); } +void DownloadListWidget::issueQueryInfoMd5() +{ + emit queryInfoMd5(m_ContextRow); +} + void DownloadListWidget::issueDelete() { if (QMessageBox::question(nullptr, tr("Delete Files?"), diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index 4776d259..ad07b0f1 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -78,6 +78,7 @@ public: signals: void installDownload(int index); void queryInfo(int index); + void queryInfoMd5(int index); void removeDownload(int index, bool deleteFile); void restoreDownload(int index); void cancelDownload(int index); @@ -109,6 +110,7 @@ private slots: void issueRemoveFromViewCompleted(); void issueRemoveFromViewUninstalled(); void issueQueryInfo(); + void issueQueryInfoMd5(); private: DownloadManager *m_Manager; diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index c3a6a3e7..3563ecdb 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -262,7 +262,8 @@ void DownloadManager::pauseAll() foreach (DownloadInfo *info, m_ActiveDownloads) { if ((info->m_State < STATE_CANCELED) || (info->m_State == STATE_FETCHINGFILEINFO) || - (info->m_State == STATE_FETCHINGMODINFO)) { + (info->m_State == STATE_FETCHINGMODINFO) || + (info->m_State == STATE_FETCHINGMODINFO_MD5)) { done = false; break; } @@ -819,7 +820,9 @@ void DownloadManager::pauseDownload(int index) } else { setState(info, STATE_PAUSED); } - } else if ((info->m_State == STATE_FETCHINGMODINFO) || (info->m_State == STATE_FETCHINGFILEINFO)) { + } else if ((info->m_State == STATE_FETCHINGMODINFO) || + (info->m_State == STATE_FETCHINGFILEINFO) || + (info->m_State == STATE_FETCHINGMODINFO_MD5)) { setState(info, STATE_READY); } } @@ -952,6 +955,46 @@ void DownloadManager::queryInfo(int index) setState(info, STATE_FETCHINGMODINFO); } +void DownloadManager::queryInfoMd5(int index) +{ + if ((index < 0) || (index >= m_ActiveDownloads.size())) { + reportError(tr("query: invalid download index %1").arg(index)); + return; + } + DownloadInfo *info = m_ActiveDownloads[index]; + + if (info->m_FileInfo->repository != "Nexus") { + qWarning("re-querying file info is currently only possible with Nexus"); + return; + } + + if (info->m_State < DownloadManager::STATE_READY) { + // UI shouldn't allow this + return; + } + + info->m_GamesToQuery << m_ManagedGame->gameShortName(); + info->m_GamesToQuery << m_ManagedGame->validShortNames(); + + QFile downloadFile(info->m_FileName); + if (!downloadFile.exists()) { + downloadFile.setFileName(m_OrganizerCore->downloadsPath() + "\\" + info->m_FileName); + } + if (!downloadFile.exists()) { + qDebug("Can't find download file %s", info->m_FileName); + return; + } + if (!downloadFile.open(QIODevice::ReadOnly)) { + qDebug("Can't open download file %s", info->m_FileName); + return; + } + info->m_Hash = QCryptographicHash::hash(downloadFile.readAll(), QCryptographicHash::Md5); + downloadFile.close(); + + info->m_ReQueried = true; + setState(info, STATE_FETCHINGMODINFO_MD5); +} + void DownloadManager::visitOnNexus(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { @@ -1329,6 +1372,9 @@ void DownloadManager::setState(DownloadManager::DownloadInfo *info, DownloadMana case STATE_FETCHINGFILEINFO: { m_RequestIDs.insert(m_NexusInterface->requestFiles(info->m_FileInfo->gameName, info->m_FileInfo->modID, this, info->m_DownloadID, QString())); } break; + case STATE_FETCHINGMODINFO_MD5: { + m_RequestIDs.insert(m_NexusInterface->requestInfoFromMd5(info->m_GamesToQuery[0], info->m_Hash, this, info->m_DownloadID, QString())); + } break; case STATE_READY: { createMetaFile(info); emit downloadComplete(row); @@ -1682,6 +1728,51 @@ void DownloadManager::nxmDownloadURLsAvailable(QString gameName, int modID, int } +void DownloadManager::nxmFileInfoFromMd5Available(QString gameName, QVariant userData, QVariant resultData, int requestID) +{ + std::set::iterator idIter = m_RequestIDs.find(requestID); + if (idIter == m_RequestIDs.end()) { + return; + } else { + m_RequestIDs.erase(idIter); + } + + auto resultlist = resultData.toList(); + auto results = resultlist[0].toMap(); + auto fileDetails = results["file_details"].toMap(); + auto modDetails = results["mod"].toMap(); + + DownloadInfo *info = downloadInfoByID(userData.toInt()); + + info->m_FileInfo->name = fileDetails["name"].toString(); + info->m_FileInfo->fileID = fileDetails["file_id"].toInt(); + info->m_FileInfo->description = fileDetails["description"].toString(); + info->m_FileInfo->version.parse(fileDetails["version"].toString()); + if (!info->m_FileInfo->version.isValid()) + info->m_FileInfo->version.parse(fileDetails["mod_version"].toString()); + info->m_FileInfo->fileCategory = fileDetails["category_id"].toInt(); + + info->m_FileInfo->modID = modDetails["mod_id"].toInt(); + info->m_FileInfo->modName = modDetails["name"].toString(); + info->m_FileInfo->categoryID = modDetails["category_id"].toInt(); + + QString gameShortName = gameName; + QStringList games(m_ManagedGame->validShortNames()); + games += m_ManagedGame->gameShortName(); + for (auto game : games) { + MOBase::IPluginGame *gamePlugin = m_OrganizerCore->getGame(game); + if (gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { + gameShortName = gamePlugin->gameShortName(); + break; + } + } + + info->m_FileInfo->gameName = gameShortName; + + setState(info, STATE_READY); +} + + void DownloadManager::nxmRequestFailed(QString gameName, int modID, int fileID, QVariant userData, int requestID, QNetworkReply::NetworkError error, const QString &errorString) { std::set::iterator idIter = m_RequestIDs.find(requestID); @@ -1691,10 +1782,29 @@ void DownloadManager::nxmRequestFailed(QString gameName, int modID, int fileID, m_RequestIDs.erase(idIter); } + DownloadInfo *userDataInfo = downloadInfoByID(userData.toInt()); + int index = 0; for (QVector::iterator iter = m_ActiveDownloads.begin(); iter != m_ActiveDownloads.end(); ++iter, ++index) { DownloadInfo *info = *iter; + if (info != userDataInfo) + continue; + + // MD5 searches continue until all possible games are done + if (info->m_State == STATE_FETCHINGMODINFO_MD5) { + if (info->m_GamesToQuery.count() >= 2) { + info->m_GamesToQuery.pop_front(); + setState(info, STATE_FETCHINGMODINFO_MD5); + break; + } else { + info->m_State = STATE_READY; + queryInfo(index); + emit update(index); + break; + } + } + if (info->m_FileInfo->modID == modID) { if (info->m_State < STATE_FETCHINGMODINFO) { m_ActiveDownloads.erase(iter); diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 841a9fbc..8033989e 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -61,6 +61,7 @@ public: STATE_ERROR, STATE_FETCHINGMODINFO, STATE_FETCHINGFILEINFO, + STATE_FETCHINGMODINFO_MD5, STATE_NOFETCH, STATE_READY, STATE_INSTALLED, @@ -86,6 +87,8 @@ private: qint64 m_ResumePos; qint64 m_TotalSize; QDateTime m_Created; // used as a cache in DownloadManager::getFileTime, may not be valid elsewhere + QByteArray m_Hash; + QStringList m_GamesToQuery; int m_Tries; bool m_ReQueried; @@ -153,16 +156,16 @@ public: **/ void setOutputDirectory(const QString &outputDirectory); - /** - * @brief disables feedback from the downlods fileSystemWhatcher untill disableDownloadsWatcherEnd() is called - * - **/ - static void startDisableDirWatcher(); + /** + * @brief disables feedback from the downlods fileSystemWhatcher untill disableDownloadsWatcherEnd() is called + * + **/ + static void startDisableDirWatcher(); - /** - * @brief re-enables feedback from the downlods fileSystemWhatcher after disableDownloadsWatcherStart() was called - **/ - static void endDisableDirWatcher(); + /** + * @brief re-enables feedback from the downlods fileSystemWhatcher after disableDownloadsWatcherStart() was called + **/ + static void endDisableDirWatcher(); /** * @return current download directory @@ -290,7 +293,7 @@ public: * the following states: * started -> downloading -> fetching mod info -> fetching file info -> done * in case of downloads started via nxm-link, file information is fetched first - * + * * @param index index of the file to look up * @return the download state **/ @@ -444,7 +447,9 @@ public slots: void queryInfo(int index); - void visitOnNexus(int index); + void queryInfoMd5(int index); + + void visitOnNexus(int index); void openFile(int index); @@ -458,6 +463,8 @@ public slots: void nxmDownloadURLsAvailable(QString gameName, int modID, int fileID, QVariant userData, QVariant resultData, int requestID); + void nxmFileInfoFromMd5Available(QString gameName, QVariant userData, QVariant resultData, int requestID); + void nxmRequestFailed(QString gameName, int modID, int fileID, QVariant userData, int requestID, QNetworkReply::NetworkError error, const QString &errorString); void managedGameChanged(MOBase::IPluginGame const *gamePlugin); @@ -547,10 +554,10 @@ private: QFileSystemWatcher m_DirWatcher; - //The dirWatcher is actually triggering off normal Mo operations such as deleting downloads or editing .meta files - //so it needs to be disabled during operations that are known to cause the creation or deletion of files in the Downloads folder. - //Notably using QSettings to edit a file creates a temporarily .lock file that causes the Watcher to trigger multiple listRefreshes freezing the ui. - static int m_DirWatcherDisabler; + //The dirWatcher is actually triggering off normal Mo operations such as deleting downloads or editing .meta files + //so it needs to be disabled during operations that are known to cause the creation or deletion of files in the Downloads folder. + //Notably using QSettings to edit a file creates a temporarily .lock file that causes the Watcher to trigger multiple listRefreshes freezing the ui. + static int m_DirWatcherDisabler; std::map m_DownloadFails; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3f6da2a6..0bdefe80 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5518,6 +5518,7 @@ void MainWindow::initDownloadView() 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(queryInfoMd5(int)), m_OrganizerCore.downloadManager(), SLOT(queryInfoMd5(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))); diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index b1f50fd8..33c5983c 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -555,6 +555,23 @@ int NexusInterface::requestToggleTracking(QString gameName, int modID, bool trac return -1; } +int NexusInterface::requestInfoFromMd5(QString gameName, QByteArray &hash, QObject *receiver, QVariant userData, + const QString &subModule, MOBase::IPluginGame const *game) +{ + NXMRequestInfo requestInfo(hash, NXMRequestInfo::TYPE_FILEINFO_MD5, userData, subModule, game); + requestInfo.m_Hash = hash; + m_RequestQueue.enqueue(requestInfo); + + connect(this, SIGNAL(nxmFileInfoFromMd5Available(QString, QVariant, QVariant, int)), + receiver, SLOT(nxmFileInfoFromMd5Available(QString, QVariant, QVariant, int)), Qt::UniqueConnection); + + connect(this, SIGNAL(nxmRequestFailed(QString, int, int, QVariant, int, QNetworkReply::NetworkError, QString)), + receiver, SLOT(nxmRequestFailed(QString, int, int, QVariant, int, QNetworkReply::NetworkError, QString)), Qt::UniqueConnection); + + nextRequest(); + return requestInfo.m_ID; +} + IPluginGame* NexusInterface::getGame(QString gameName) const { auto gamePlugins = m_PluginContainer->plugins(); @@ -673,6 +690,9 @@ void NexusInterface::nextRequest() case NXMRequestInfo::TYPE_TRACKEDMODS: { url = QStringLiteral("%1/user/tracked_mods").arg(info.m_URL); } break; + case NXMRequestInfo::TYPE_FILEINFO_MD5: { + url = QStringLiteral("%1/games/%2/mods/md5_search/%3").arg(info.m_URL).arg(info.m_GameName).arg(QString(info.m_Hash.toHex())); + } } } else { url = info.m_URL; @@ -719,6 +739,7 @@ void NexusInterface::requestFinished(std::list::iterator iter) if (reply->error() != QNetworkReply::NoError) { int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + if (statusCode == 429) { if (reply->rawHeader("x-rl-daily-remaining").toInt() || reply->rawHeader("x-rl-hourly-remaining").toInt()) qWarning("You appear to be making requests to the Nexus API too quickly and are being throttled. Please inform the MO2 team."); @@ -793,6 +814,9 @@ void NexusInterface::requestFinished(std::list::iterator iter) case NXMRequestInfo::TYPE_TRACKEDMODS: { emit nxmTrackedModsAvailable(iter->m_UserData, result, iter->m_ID); } break; + case NXMRequestInfo::TYPE_FILEINFO_MD5: { + emit nxmFileInfoFromMd5Available(iter->m_GameName, iter->m_UserData, result, iter->m_ID); + } break; } m_RemainingDailyRequests = reply->rawHeader("x-rl-daily-remaining").toInt(); @@ -890,6 +914,8 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID , m_NexusGameID(game->nexusGameID()) , m_GameName(game->gameNexusName()) , m_Endorse(false) + , m_Track(false) + , m_Hash(QByteArray()) { } @@ -915,6 +941,8 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID , m_NexusGameID(game->nexusGameID()) , m_GameName(game->gameNexusName()) , m_Endorse(false) + , m_Track(false) + , m_Hash(QByteArray()) {} NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID @@ -939,6 +967,8 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID , m_NexusGameID(game->nexusGameID()) , m_GameName(game->gameNexusName()) , m_Endorse(false) + , m_Track(false) + , m_Hash(QByteArray()) {} NexusInterface::NXMRequestInfo::NXMRequestInfo(Type type @@ -960,6 +990,8 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(Type type , m_NexusGameID(0) , m_GameName("") , m_Endorse(false) + , m_Track(false) + , m_Hash(QByteArray()) {} @@ -984,4 +1016,32 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(UpdatePeriod period , m_NexusGameID(game->nexusGameID()) , m_GameName(game->gameNexusName()) , m_Endorse(false) + , m_Track(false) + , m_Hash(QByteArray()) +{} + + +NexusInterface::NXMRequestInfo::NXMRequestInfo(QByteArray &hash + , NexusInterface::NXMRequestInfo::Type type + , QVariant userData + , const QString &subModule + , MOBase::IPluginGame const *game +) + : m_ModID(0) + , m_ModVersion("0") + , m_FileID(0) + , m_Reply(nullptr) + , m_Type(type) + , m_UpdatePeriod(UpdatePeriod::NONE) + , m_UserData(userData) + , m_Timeout(nullptr) + , m_Reroute(false) + , m_ID(s_NextID.fetchAndAddAcquire(1)) + , m_URL(get_management_url()) + , m_SubModule(subModule) + , m_NexusGameID(game->nexusGameID()) + , m_GameName(game->gameNexusName()) + , m_Endorse(false) + , m_Track(false) + , m_Hash(hash) {} diff --git a/src/nexusinterface.h b/src/nexusinterface.h index a0f94562..6f3c9cd1 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -369,6 +369,20 @@ public: int requestToggleTracking(QString gameName, int modID, bool track, QObject *receiver, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game); + /** + * + */ + int requestInfoFromMd5(QString gameName, QByteArray &hash, QObject *receiver, QVariant userData, const QString &subModule) + { + return requestInfoFromMd5(gameName, hash, receiver, userData, subModule, getGame(gameName)); + } + + /** + * + */ + int requestInfoFromMd5(QString gameName, QByteArray &hash, QObject *receiver, QVariant userData, const QString &subModule, + MOBase::IPluginGame const *game); + /** * @param directory the directory to store cache files **/ @@ -438,6 +452,7 @@ signals: void nxmUpdatesAvailable(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID); void nxmFilesAvailable(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID); void nxmFileInfoAvailable(QString gameName, int modID, int fileID, QVariant userData, QVariant resultData, int requestID); + void nxmFileInfoFromMd5Available(QString gameName, QVariant userData, QVariant resultData, int requestID); void nxmDownloadURLsAvailable(QString gameName, int modID, int fileID, QVariant userData, QVariant resultData, int requestID); void nxmEndorsementsAvailable(QVariant userData, QVariant resultData, int requestID); void nxmEndorsementToggled(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID); @@ -480,6 +495,7 @@ private: TYPE_CHECKUPDATES, TYPE_TOGGLETRACKING, TYPE_TRACKEDMODS, + TYPE_FILEINFO_MD5, } m_Type; UpdatePeriod m_UpdatePeriod; QVariant m_UserData; @@ -492,12 +508,14 @@ private: int m_ID; int m_Endorse; int m_Track; + QByteArray m_Hash; NXMRequestInfo(int modID, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game); NXMRequestInfo(int modID, QString modVersion, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game); NXMRequestInfo(int modID, int fileID, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game); NXMRequestInfo(Type type, QVariant userData, const QString &subModule); NXMRequestInfo(UpdatePeriod period, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game); + NXMRequestInfo(QByteArray &hash, Type type, QVariant userData, const QString &subModule, MOBase::IPluginGame const *game); private: static QAtomicInt s_NextID; -- cgit v1.3.1