SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
formelementinformation.cpp
Go to the documentation of this file.
1// SedSAT3 – Sediment Source Assessment Tool, version 3
2// U.S. Geological Survey. See LICENSE.md and DISCLAIMER.md in the repository root.
3
5#include "ui_formelementinformation.h"
7#include <QSignalBlocker>
8#include <QHeaderView>
9
11 QWidget(parent),
13{
14 ui->setupUi(this);
15 // The label is fixed and the check state carries the meaning: checked
16 // means every element is included. (The label used to flip between
17 // "Include all" and "Exclude all", so a checked box read "Include all
18 // elements" while every element had just been excluded.)
19 ui->Include_Exclude_All_checkBox->setText(tr("Include all elements"));
20 connect(ui->Include_Exclude_All_checkBox,SIGNAL(stateChanged(int)),this,SLOT(OnIncludeAllToggled()));
21
22}
23
28
30{
31 return ui->tableView;
32}
33
35{
36 ui->tableView->setModel(model);
37 ui->tableView->horizontalHeader()->setStretchLastSection(true); // room for the notes
40}
41
43{
44 ElementTableModel* model = static_cast<ElementTableModel*>(table()->model());
45 if (model == nullptr || model->Data == nullptr)
46 return;
47
48 bool all_included = true;
49 for (const auto& element : *model->Data->GetElementInformation())
50 {
51 if (!element.second.include_in_analysis)
52 {
53 all_included = false;
54 break;
55 }
56 }
57
58 // Reflect the data without acting on it
59 QSignalBlocker blocker(ui->Include_Exclude_All_checkBox);
60 ui->Include_Exclude_All_checkBox->setChecked(all_included);
61}
62
64{
65 ElementTableModel* model = static_cast<ElementTableModel*>(table()->model());
66 if (model == nullptr || model->Data == nullptr)
67 return;
68
69 const bool include_all = (ui->Include_Exclude_All_checkBox->checkState() == Qt::CheckState::Checked);
70 model->Data->IncludeExcludeAllElements(include_all);
71 // Tell the view the "Include in analysis" column changed, so it shows the
72 // new values at once rather than when the table is next clicked
73 if (model->rowCount() > 0)
74 emit model->dataChanged(model->index(0, 4), model->index(model->rowCount() - 1, 4));
75 table()->viewport()->update();
76}
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void editCompleted(const QString &)
SourceSinkData * Data
void SyncIncludeAllCheckBox()
Checked exactly when every element is included.
void setModel(ElementTableModel *model)
Sets the table model and the check box state from it.
FormElementInformation(QWidget *parent=nullptr)
Ui::FormElementInformation * ui
map< string, element_information > * GetElementInformation()
Retrieves pointer to the element information map.
void IncludeExcludeAllElements(bool include_in_analysis)
Sets inclusion flag for all elements.