diff options
| author | Krzysztof Starecki <krzysztof.starecki@gmail.com> | 2018-12-31 23:21:01 +0100 |
|---|---|---|
| committer | Krzysztof Starecki <krzysztof.starecki@gmail.com> | 2018-12-31 23:24:19 +0100 |
| commit | 263a3f7d24f177bb28ad988ec70bc97106c0816b (patch) | |
| tree | 0753470342eb571c5bdd6a7fe6a39b8672bce724 /src | |
| parent | 79a2f8477b02c506ff8ae18367d3739aa17307ad (diff) | |
Make download tab columns hideable by user
Diffstat (limited to 'src')
| -rw-r--r-- | src/downloadlistwidget.cpp | 38 | ||||
| -rw-r--r-- | src/downloadlistwidget.h | 1 | ||||
| -rw-r--r-- | src/organizer_en.ts | 168 |
3 files changed, 123 insertions, 84 deletions
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 393a8a98..24695032 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -25,6 +25,9 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <QMessageBox>
#include <QSortFilterProxyModel>
#include <QApplication>
+#include <QHeaderView>
+#include <QCheckBox>
+#include <QWidgetAction>
void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
@@ -73,6 +76,9 @@ DownloadListWidget::DownloadListWidget(QWidget *parent) {
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClick(QModelIndex)));
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenu(QPoint)));
+
+ header()->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(header(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onHeaderCustomContextMenu(QPoint)));
}
DownloadListWidget::~DownloadListWidget()
@@ -105,6 +111,38 @@ void DownloadListWidget::onDoubleClick(const QModelIndex &index) emit resumeDownload(sourceIndex.row());
}
+void DownloadListWidget::onHeaderCustomContextMenu(const QPoint &point)
+{
+ QMenu menu;
+
+ // display a list of all headers as checkboxes
+ QAbstractItemModel *model = header()->model();
+ for (int i = 1; i < model->columnCount(); ++i) {
+ QString columnName = model->headerData(i, Qt::Horizontal).toString();
+ QCheckBox *checkBox = new QCheckBox(&menu);
+ checkBox->setText(columnName);
+ checkBox->setChecked(!header()->isSectionHidden(i));
+ QWidgetAction *checkableAction = new QWidgetAction(&menu);
+ checkableAction->setDefaultWidget(checkBox);
+ menu.addAction(checkableAction);
+ }
+
+ menu.exec(header()->viewport()->mapToGlobal(point));
+
+ // view/hide columns depending on check-state
+ int i = 1;
+ for (const QAction *action : menu.actions()) {
+ const QWidgetAction *widgetAction = qobject_cast<const QWidgetAction*>(action);
+ if (widgetAction != nullptr) {
+ const QCheckBox *checkBox = qobject_cast<const QCheckBox*>(widgetAction->defaultWidget());
+ if (checkBox != nullptr) {
+ header()->setSectionHidden(i, !checkBox->isChecked());
+ }
+ }
+ ++i;
+ }
+}
+
void DownloadListWidget::onCustomContextMenu(const QPoint &point)
{
QMenu menu(this);
diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index bfe504aa..0002e2b4 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -77,6 +77,7 @@ signals: private slots:
void onDoubleClick(const QModelIndex &index);
void onCustomContextMenu(const QPoint &point);
+ void onHeaderCustomContextMenu(const QPoint &point);
void issueInstall();
void issueDelete();
void issueRemoveFromView();
diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 82fe46e8..ace06361 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -395,145 +395,145 @@ p, li { white-space: pre-wrap; } <context> <name>DownloadListWidget</name> <message> - <location filename="downloadlistwidget.cpp" line="120"/> + <location filename="downloadlistwidget.cpp" line="159"/> <source>Install</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="122"/> + <location filename="downloadlistwidget.cpp" line="161"/> <source>Query Info</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="124"/> + <location filename="downloadlistwidget.cpp" line="163"/> <source>Visit on Nexus</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="125"/> + <location filename="downloadlistwidget.cpp" line="164"/> <source>Open File</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="126"/> - <location filename="downloadlistwidget.cpp" line="138"/> - <location filename="downloadlistwidget.cpp" line="143"/> + <location filename="downloadlistwidget.cpp" line="165"/> + <location filename="downloadlistwidget.cpp" line="177"/> + <location filename="downloadlistwidget.cpp" line="182"/> <source>Show in Folder</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="130"/> - <location filename="downloadlistwidget.cpp" line="141"/> + <location filename="downloadlistwidget.cpp" line="169"/> + <location filename="downloadlistwidget.cpp" line="180"/> <source>Delete</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="132"/> + <location filename="downloadlistwidget.cpp" line="171"/> <source>Un-Hide</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="134"/> + <location filename="downloadlistwidget.cpp" line="173"/> <source>Hide</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="136"/> + <location filename="downloadlistwidget.cpp" line="175"/> <source>Cancel</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="137"/> + <location filename="downloadlistwidget.cpp" line="176"/> <source>Pause</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="142"/> + <location filename="downloadlistwidget.cpp" line="181"/> <source>Resume</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="148"/> + <location filename="downloadlistwidget.cpp" line="187"/> <source>Delete Installed...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="149"/> + <location filename="downloadlistwidget.cpp" line="188"/> <source>Delete Uninstalled...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="150"/> + <location filename="downloadlistwidget.cpp" line="189"/> <source>Delete All...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="154"/> + <location filename="downloadlistwidget.cpp" line="193"/> <source>Hide Installed...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="155"/> + <location filename="downloadlistwidget.cpp" line="194"/> <source>Hide Uninstalled...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="156"/> + <location filename="downloadlistwidget.cpp" line="195"/> <source>Hide All...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="158"/> + <location filename="downloadlistwidget.cpp" line="197"/> <source>Un-Hide All...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="176"/> - <location filename="downloadlistwidget.cpp" line="231"/> - <location filename="downloadlistwidget.cpp" line="240"/> - <location filename="downloadlistwidget.cpp" line="249"/> + <location filename="downloadlistwidget.cpp" line="215"/> + <location filename="downloadlistwidget.cpp" line="270"/> + <location filename="downloadlistwidget.cpp" line="279"/> + <location filename="downloadlistwidget.cpp" line="288"/> <source>Delete Files?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="177"/> + <location filename="downloadlistwidget.cpp" line="216"/> <source>This will permanently delete the selected download.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="232"/> + <location filename="downloadlistwidget.cpp" line="271"/> <source>This will remove all finished downloads from this list and from disk.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="241"/> + <location filename="downloadlistwidget.cpp" line="280"/> <source>This will remove all installed downloads from this list and from disk.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="250"/> + <location filename="downloadlistwidget.cpp" line="289"/> <source>This will remove all uninstalled downloads from this list and from disk.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="258"/> - <location filename="downloadlistwidget.cpp" line="267"/> - <location filename="downloadlistwidget.cpp" line="276"/> + <location filename="downloadlistwidget.cpp" line="297"/> + <location filename="downloadlistwidget.cpp" line="306"/> + <location filename="downloadlistwidget.cpp" line="315"/> <source>Are you sure?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="259"/> + <location filename="downloadlistwidget.cpp" line="298"/> <source>This will remove all finished downloads from this list (but NOT from disk).</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="268"/> + <location filename="downloadlistwidget.cpp" line="307"/> <source>This will remove all installed downloads from this list (but NOT from disk).</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadlistwidget.cpp" line="277"/> + <location filename="downloadlistwidget.cpp" line="316"/> <source>This will remove all uninstalled downloads from this list (but NOT from disk).</source> <translation type="unfinished"></translation> </message> @@ -593,7 +593,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="downloadmanager.cpp" line="588"/> - <location filename="downloadmanager.cpp" line="725"/> + <location filename="downloadmanager.cpp" line="721"/> <source>remove: invalid download index %1</source> <translation type="unfinished"></translation> </message> @@ -613,234 +613,234 @@ p, li { white-space: pre-wrap; } <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="747"/> + <location filename="downloadmanager.cpp" line="743"/> <source>cancel: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="760"/> + <location filename="downloadmanager.cpp" line="756"/> <source>pause: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="780"/> + <location filename="downloadmanager.cpp" line="776"/> <source>resume: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="791"/> + <location filename="downloadmanager.cpp" line="787"/> <source>resume (int): invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="815"/> + <location filename="downloadmanager.cpp" line="811"/> <source>No known download urls. Sorry, this download can't be resumed.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="856"/> + <location filename="downloadmanager.cpp" line="852"/> <source>query: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="878"/> + <location filename="downloadmanager.cpp" line="874"/> <source>Please enter the nexus mod id</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="878"/> + <location filename="downloadmanager.cpp" line="874"/> <source>Mod ID:</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="888"/> + <location filename="downloadmanager.cpp" line="884"/> <source>Please select the source game code for %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="907"/> + <location filename="downloadmanager.cpp" line="903"/> <source>VisitNexus: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="928"/> + <location filename="downloadmanager.cpp" line="924"/> <source>Nexus ID for this Mod is unknown</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="935"/> + <location filename="downloadmanager.cpp" line="931"/> <source>OpenFile: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="952"/> + <location filename="downloadmanager.cpp" line="948"/> <source>OpenFileInDownloadsFolder: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="988"/> + <location filename="downloadmanager.cpp" line="984"/> <source>get pending: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="997"/> + <location filename="downloadmanager.cpp" line="993"/> <source>get path: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1006"/> + <location filename="downloadmanager.cpp" line="1002"/> <source>Main</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1007"/> + <location filename="downloadmanager.cpp" line="1003"/> <source>Update</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1008"/> + <location filename="downloadmanager.cpp" line="1004"/> <source>Optional</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1009"/> + <location filename="downloadmanager.cpp" line="1005"/> <source>Old</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1010"/> + <location filename="downloadmanager.cpp" line="1006"/> <source>Misc</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1011"/> + <location filename="downloadmanager.cpp" line="1007"/> <source>Unknown</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1018"/> + <location filename="downloadmanager.cpp" line="1014"/> <source>display name: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1038"/> + <location filename="downloadmanager.cpp" line="1034"/> <source>file name: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1047"/> + <location filename="downloadmanager.cpp" line="1043"/> <source>file time: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1061"/> + <location filename="downloadmanager.cpp" line="1057"/> <source>file size: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1071"/> + <location filename="downloadmanager.cpp" line="1067"/> <source>progress: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1081"/> + <location filename="downloadmanager.cpp" line="1077"/> <source>state: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1091"/> + <location filename="downloadmanager.cpp" line="1087"/> <source>infocomplete: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1106"/> - <location filename="downloadmanager.cpp" line="1114"/> + <location filename="downloadmanager.cpp" line="1102"/> + <location filename="downloadmanager.cpp" line="1110"/> <source>mod id: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1122"/> + <location filename="downloadmanager.cpp" line="1118"/> <source>ishidden: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1131"/> + <location filename="downloadmanager.cpp" line="1127"/> <source>file info: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1141"/> + <location filename="downloadmanager.cpp" line="1137"/> <source>mark installed: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1186"/> + <location filename="downloadmanager.cpp" line="1182"/> <source>mark uninstalled: invalid download index %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1359"/> + <location filename="downloadmanager.cpp" line="1355"/> <source>Memory allocation error (in processing progress event).</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1369"/> + <location filename="downloadmanager.cpp" line="1365"/> <source>Memory allocation error (in processing downloaded data).</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1495"/> + <location filename="downloadmanager.cpp" line="1491"/> <source>Information updated</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1497"/> - <location filename="downloadmanager.cpp" line="1511"/> + <location filename="downloadmanager.cpp" line="1493"/> + <location filename="downloadmanager.cpp" line="1507"/> <source>No matching file found on Nexus! Maybe this file is no longer available or it was renamed?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1499"/> + <location filename="downloadmanager.cpp" line="1495"/> <source>No file on Nexus matches the selected file by name. Please manually choose the correct one.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1628"/> + <location filename="downloadmanager.cpp" line="1624"/> <source>No download server available. Please try again later.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1671"/> + <location filename="downloadmanager.cpp" line="1667"/> <source>Failed to request file info from nexus: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1698"/> + <location filename="downloadmanager.cpp" line="1694"/> <source>Warning: Content type is: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1703"/> + <location filename="downloadmanager.cpp" line="1699"/> <source>Download header content length: %1 downloaded file size: %2</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1705"/> + <location filename="downloadmanager.cpp" line="1701"/> <source>Download failed: %1 (%2)</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1727"/> + <location filename="downloadmanager.cpp" line="1723"/> <source>We were unable to download the file due to errors after four retries. There may be an issue with the Nexus servers.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1810"/> + <location filename="downloadmanager.cpp" line="1806"/> <source>failed to re-open %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="downloadmanager.cpp" line="1851"/> + <location filename="downloadmanager.cpp" line="1847"/> <source>Unable to write download to drive (return %1). Check the drive's available storage. |
