Skip to content

Commit

Permalink
Add Deselect/Select All buttons to export dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Aug 18, 2023
1 parent 4c2cdad commit 8c3a77d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/ui/ExportDialog.cpp
Expand Up @@ -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),
Expand Down
9 changes: 9 additions & 0 deletions src/ui/ExportDialog.h
Expand Up @@ -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
27 changes: 27 additions & 0 deletions src/ui/ExportDialog.ui
Expand Up @@ -27,6 +27,33 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>15</number>
</property>
<property name="leftMargin">
<number>50</number>
</property>
<property name="rightMargin">
<number>50</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_deselect_all">
<property name="text">
<string>Deselect All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_select_all">
<property name="text">
<string>Select All</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableView" name="tvExportCaps"/>
</item>
Expand Down

0 comments on commit 8c3a77d

Please sign in to comment.