From 5a287f32d49b5e2e6430f52e20a6da05ba51cfe4 Mon Sep 17 00:00:00 2001
From: past-due <30942300+past-due@users.noreply.github.com>
Date: Fri, 18 Aug 2023 14:00:46 -0400
Subject: [PATCH] Add Deselect/Select All buttons to export dialog
---
src/ui/ExportDialog.cpp | 25 ++++++++++++++++++++++++-
src/ui/ExportDialog.h | 9 +++++++++
src/ui/ExportDialog.ui | 27 +++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/src/ui/ExportDialog.cpp b/src/ui/ExportDialog.cpp
index f756fda..2a0bd05 100644
--- a/src/ui/ExportDialog.cpp
+++ b/src/ui/ExportDialog.cpp
@@ -52,10 +52,33 @@ PieExportDialog::PieExportDialog(const PieCaps &caps, QWidget* parent)
"Note that you do not have to deselect directives that are not present in current model. "
"E.g. normal map will not be exported unless it was assigned and is allowed."));
- auto model = new PieContentModel(m_caps, ui->tvExportCaps);
+ model = new PieContentModel(m_caps, ui->tvExportCaps);
ui->tvExportCaps->setModel(model);
ui->tvExportCaps->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tvExportCaps->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
+
+ connect(ui->pushButton_deselect_all, SIGNAL(clicked()), this, SLOT(actionDeselectAll()));
+ connect(ui->pushButton_select_all, SIGNAL(clicked()), this, SLOT(actionSelectAll()));
+}
+
+void PieExportDialog::changeSelectAll(bool selected)
+{
+ if (!model) { return; }
+ int rowCount = model->rowCount();
+ for (int row = 0; row < rowCount; ++row)
+ {
+ model->setData(model->index(row, 1), selected, Qt::CheckStateRole);
+ }
+}
+
+void PieExportDialog::actionDeselectAll()
+{
+ changeSelectAll(false);
+}
+
+void PieExportDialog::actionSelectAll()
+{
+ changeSelectAll(true);
}
PieContentModel::PieContentModel(PieCaps &caps, QObject *parent): QAbstractTableModel(parent),
diff --git a/src/ui/ExportDialog.h b/src/ui/ExportDialog.h
index 74b6210..c503cc7 100644
--- a/src/ui/ExportDialog.h
+++ b/src/ui/ExportDialog.h
@@ -68,8 +68,17 @@ class PieExportDialog : public ExportDialog
PieExportDialog(const PieCaps& caps, QWidget* parent = nullptr);
const PieCaps& getCaps() const {return m_caps;}
+
+private:
+ void changeSelectAll(bool selected);
+
+private slots:
+ void actionDeselectAll();
+ void actionSelectAll();
+
private:
PieCaps m_caps;
+ PieContentModel *model;
};
#endif // EXPORTDIALOG_HPP
diff --git a/src/ui/ExportDialog.ui b/src/ui/ExportDialog.ui
index 76571c8..8fd0368 100644
--- a/src/ui/ExportDialog.ui
+++ b/src/ui/ExportDialog.ui
@@ -27,6 +27,33 @@
+ -
+
+
+ 15
+
+
+ 50
+
+
+ 50
+
+
-
+
+
+ Deselect All
+
+
+
+ -
+
+
+ Select All
+
+
+
+
+
-