diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-09 04:14:46 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-18 17:23:48 -0500 |
| commit | 3db95eb4043b8da20e99dd7476bc82468a4609fb (patch) | |
| tree | 257af3a4acd74b09713420cf184dffa77f6ab68d /src | |
| parent | 0c62a26e09fc293d7ab3a6ac8527c067d85f7773 (diff) | |
customizable columns for mod and plugin lists
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 32 | ||||
| -rw-r--r-- | src/mainwindow.h | 3 | ||||
| -rw-r--r-- | src/modlist.cpp | 10 | ||||
| -rw-r--r-- | src/modlist.h | 6 | ||||
| -rw-r--r-- | src/modlistview.cpp | 2 | ||||
| -rw-r--r-- | src/organizercore.cpp | 2 | ||||
| -rw-r--r-- | src/pluginlistview.cpp | 2 |
7 files changed, 5 insertions, 52 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0efb043b..3e03c52d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5818,38 +5818,6 @@ void MainWindow::extractBSATriggered() } } - -void MainWindow::displayColumnSelection(const QPoint &pos) -{ - QMenu menu; - - // display a list of all headers as checkboxes - QAbstractItemModel *model = ui->modList->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(!ui->modList->header()->isSectionHidden(i)); - QWidgetAction *checkableAction = new QWidgetAction(&menu); - checkableAction->setDefaultWidget(checkBox); - menu.addAction(checkableAction); - } - menu.exec(pos); - - // 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) { - ui->modList->header()->setSectionHidden(i, !checkBox->isChecked()); - } - } - ++i; - } -} - void MainWindow::on_bsaList_customContextMenuRequested(const QPoint &pos) { m_ContextItem = ui->bsaList->itemAt(pos); diff --git a/src/mainwindow.h b/src/mainwindow.h index 1016c061..6530d8ad 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -153,9 +153,6 @@ public: ModInfo::Ptr previousModInList(); public slots: - - void displayColumnSelection(const QPoint &pos); - void modorder_changed(); void esplist_changed(); void refresher_progress(int percent); diff --git a/src/modlist.cpp b/src/modlist.cpp index 31eb8387..afc1b65f 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -1434,15 +1434,7 @@ bool ModList::toggleSelection(QAbstractItemView *itemView) bool ModList::eventFilter(QObject *obj, QEvent *event) { - if (event->type() == QEvent::ContextMenu) { - QContextMenuEvent *contextEvent = static_cast<QContextMenuEvent*>(event); - QWidget *object = qobject_cast<QWidget*>(obj); - if ((object != nullptr) && (contextEvent->reason() == QContextMenuEvent::Mouse)) { - emit requestColumnSelect(object->mapToGlobal(contextEvent->pos())); - - return true; - } - } else if ((event->type() == QEvent::KeyPress) && (m_Profile != nullptr)) { + if ((event->type() == QEvent::KeyPress) && (m_Profile != nullptr)) { QAbstractItemView *itemView = qobject_cast<QAbstractItemView*>(obj); QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); diff --git a/src/modlist.h b/src/modlist.h index 9a44b761..7452b28b 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -202,12 +202,6 @@ signals: void resizeHeaders();
/**
- * @brief requestColumnSelect is emitted whenever the user requested a menu to select visible columns
- * @param pos the position to display the menu at
- */
- void requestColumnSelect(QPoint pos);
-
- /**
* @brief emitted to remove a file origin
* @param name name of the orign to remove
*/
diff --git a/src/modlistview.cpp b/src/modlistview.cpp index fe2d3e57..c6dbc6ea 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -1,4 +1,5 @@ #include "modlistview.h"
+#include <widgetutility.h>
#include <QUrl>
#include <QMimeData>
#include <QProxyStyle>
@@ -39,6 +40,7 @@ ModListView::ModListView(QWidget *parent) , m_Scrollbar(new ViewMarkingScrollBar(this->model(), this))
{
setVerticalScrollBar(m_Scrollbar);
+ MOBase::setCustomizableColumns(this);
}
void ModListView::dragEnterEvent(QDragEnterEvent *event)
diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 04d78ca8..8124be1d 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -234,8 +234,6 @@ void OrganizerCore::setUserInterface(IUserInterface* ui) SLOT(removeMod_clicked())); connect(&m_ModList, SIGNAL(clearOverwrite()), w, SLOT(clearOverwrite())); - connect(&m_ModList, SIGNAL(requestColumnSelect(QPoint)), w, - SLOT(displayColumnSelection(QPoint))); connect(&m_ModList, SIGNAL(fileMoved(QString, QString, QString)), w, SLOT(fileMoved(QString, QString, QString))); connect(&m_ModList, SIGNAL(modorder_changed()), w, diff --git a/src/pluginlistview.cpp b/src/pluginlistview.cpp index 0fcf8183..4217971d 100644 --- a/src/pluginlistview.cpp +++ b/src/pluginlistview.cpp @@ -1,4 +1,5 @@ #include "pluginlistview.h" +#include <widgetutility.h> #include <QUrl> #include <QMimeData> #include <QProxyStyle> @@ -40,6 +41,7 @@ PluginListView::PluginListView(QWidget *parent) , m_Scrollbar(new ViewMarkingScrollBar(this->model(), this)) { setVerticalScrollBar(m_Scrollbar); + MOBase::setCustomizableColumns(this); } void PluginListView::dragEnterEvent(QDragEnterEvent *event) |
