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') 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