Isis 3 Programmer Reference
CnetEditorSortConfigDialog.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "CnetEditorSortConfigDialog.h"
10
11#include <limits>
12
13#include <QCheckBox>
14#include <QGridLayout>
15#include <QLabel>
16#include <QPushButton>
17#include <QSpinBox>
18#include <QtWidgets>
19
20#include "AbstractTableModel.h"
21#include "CnetEditorWidget.h"
22
23namespace Isis {
31 CnetEditorWidget *cnetWidget) : QDialog(cnetWidget) {
32 m_cnetWidget = cnetWidget;
33
34 setWindowTitle("Table Sorting");
35
36 QGridLayout *mainLayout = new QGridLayout;
37 mainLayout->setColumnMinimumWidth(0, 20);
38 setLayout(mainLayout);
39
40 // Settings area
41 int row = 0;
42 QLabel *pointTableLabel = new QLabel("<h3>Point Table</h3>");
43 mainLayout->addWidget(pointTableLabel, row, 0, 1, 3);
44 row++;
45
46 QLabel *pointSortEnableLabel = new QLabel("Sorting Enabled");
47 mainLayout->addWidget(pointSortEnableLabel, row, 1);
48
49 m_pointSortingCheckBox = new QCheckBox;
50 mainLayout->addWidget(m_pointSortingCheckBox, row, 2);
51 connect(m_pointSortingCheckBox, SIGNAL(stateChanged(int)),
52 this, SLOT(refreshWidgetStates()));
53 row++;
54
55 QLabel *pointLimitLabel = new QLabel("Table Size Limit");
56 mainLayout->addWidget(pointLimitLabel, row, 1);
57
59 m_pointTableLimitSpinBox->setRange(2, std::numeric_limits<int>::max());
60 mainLayout->addWidget(m_pointTableLimitSpinBox, row, 2);
61 row++;
62
63 m_pointTableWarningsLabel = new QLabel;
64 m_pointTableWarningsLabel->setVisible(false);
65 m_pointTableWarningsLabel->setWordWrap(true);
66 mainLayout->addWidget(m_pointTableWarningsLabel, row, 1, 1, 2);
67 row++;
68
69 QLabel *measureTableLabel = new QLabel("<h3>Measure Table</h3>");
70 mainLayout->addWidget(measureTableLabel, row, 0, 1, 3);
71 row++;
72
73 QLabel *measureSortEnableLabel = new QLabel("Sorting Enabled");
74 mainLayout->addWidget(measureSortEnableLabel, row, 1);
75
76 m_measureSortingCheckBox = new QCheckBox;
77 mainLayout->addWidget(m_measureSortingCheckBox, row, 2);
78 connect(m_measureSortingCheckBox, SIGNAL(stateChanged(int)),
79 this, SLOT(refreshWidgetStates()));
80 row++;
81
82 QLabel *measureLimitLabel = new QLabel("Table Size Limit");
83 mainLayout->addWidget(measureLimitLabel, row, 1);
84
86 m_measureTableLimitSpinBox->setRange(2, std::numeric_limits<int>::max());
87 mainLayout->addWidget(m_measureTableLimitSpinBox, row, 2);
88 row++;
89
90 m_measureTableWarningsLabel = new QLabel;
91 m_measureTableWarningsLabel->setVisible(false);
92 m_measureTableWarningsLabel->setWordWrap(true);
93 mainLayout->addWidget(m_measureTableWarningsLabel, row, 1, 1, 2);
94 row++;
95
96 // Now the buttons area
97 QHBoxLayout *buttonsAreaLayout = new QHBoxLayout;
98
99 buttonsAreaLayout->addStretch();
100
101 QPushButton *okayButton = new QPushButton("&Ok");
102 okayButton->setIcon(QIcon::fromTheme("dialog-ok"));
103 buttonsAreaLayout->addWidget(okayButton);
104 connect(okayButton, SIGNAL(clicked()),
105 this, SLOT(applySettings()));
106 connect(okayButton, SIGNAL(clicked()),
107 this, SLOT(accept()));
108
109 QPushButton *applyButton = new QPushButton("&Apply");
110 applyButton->setIcon(QIcon::fromTheme("dialog-ok-apply"));
111 buttonsAreaLayout->addWidget(applyButton);
112 connect(applyButton, SIGNAL(clicked()),
113 this, SLOT(applySettings()));
114
115 QPushButton *cancelButton = new QPushButton("&Cancel");
116 cancelButton->setIcon(QIcon::fromTheme("dialog-cancel"));
117 buttonsAreaLayout->addWidget(cancelButton);
118 connect(cancelButton, SIGNAL(clicked()),
119 this, SLOT(reject()));
120
121 QWidget *buttonsAreaWidget = new QWidget;
122 buttonsAreaWidget->setLayout(buttonsAreaLayout);
123 mainLayout->addWidget(buttonsAreaWidget, row, 0, 1, 3);
124
125 readSettings();
127 }
128
134
135
140 m_cnetWidget->setPointTableSortingEnabled(
141 m_pointSortingCheckBox->isChecked());
142 m_cnetWidget->setPointTableSortLimit(
143 m_pointTableLimitSpinBox->value());
144
145 m_cnetWidget->setMeasureTableSortingEnabled(
146 m_measureSortingCheckBox->isChecked());
147 m_cnetWidget->setMeasureTableSortLimit(
149
150 readSettings();
151 }
152
153
159 // Point Table
160 m_pointSortingCheckBox->setChecked(
161 m_cnetWidget->pointTableSortingEnabled());
162 m_pointTableLimitSpinBox->setValue(m_cnetWidget->pointTableSortLimit());
163
164 AbstractTableModel *pointModel = m_cnetWidget->pointTableModel();
165 QString disabledWarning = tr("<font color='red'>Sorting is currently disabled because the "
166 "number of visible rows (%L1) exceeds the applied table size limit option (%L2).</font>");
167
168 if (pointModel && m_pointSortingCheckBox->isChecked() &&
169 pointModel->sortLimit() < pointModel->getVisibleRowCount()) {
171 disabledWarning.arg(pointModel->getVisibleRowCount()).arg(pointModel->sortLimit()));
172
173 m_pointTableWarningsLabel->setVisible(true);
174 }
175 else {
176 m_pointTableWarningsLabel->setText(tr(""));
177 m_pointTableWarningsLabel->setVisible(false);
178 }
179
180 // Measure Table
181 m_measureSortingCheckBox->setChecked(
182 m_cnetWidget->measureTableSortingEnabled());
183 m_measureTableLimitSpinBox->setValue(m_cnetWidget->measureTableSortLimit());
184
185 AbstractTableModel *measureModel = m_cnetWidget->measureTableModel();
186 if (measureModel && m_measureSortingCheckBox->isChecked() &&
187 measureModel->sortLimit() < measureModel->getVisibleRowCount()) {
189 disabledWarning.arg(measureModel->getVisibleRowCount()).arg(measureModel->sortLimit()));
190
191 m_measureTableWarningsLabel->setVisible(true);
192 }
193 else {
194 m_measureTableWarningsLabel->setText(tr(""));
195 m_measureTableWarningsLabel->setVisible(false);
196 }
197
198 // Resize the dialog (for when warnings come and go, for example).
199 adjustSize();
200 }
201
202
212}
Translates the tree model into a table model.
CnetEditorSortConfigDialog(CnetEditorWidget *cnetWidget)
Create a config dialog that configures the given FeatureCnetEditorSort.
~CnetEditorSortConfigDialog()
Clean up allocated memory.
void refreshWidgetStates()
Enable or disable inputs based on what the user has selected for options so far.
QPointer< QCheckBox > m_pointSortingCheckBox
Enable sorting on the point table.
QPointer< QLabel > m_measureTableWarningsLabel
Say (very clearly) if sorting is disabled and why.
void readSettings()
Read the cneteditor widget's current settings and set the widget states to match.
QPointer< QCheckBox > m_measureSortingCheckBox
Enable sorting on the measure table.
QPointer< QLabel > m_pointTableWarningsLabel
Say (very clearly) if sorting is disabled and why.
QPointer< CnetEditorWidget > m_cnetWidget
The cneteditor widget we're configuring.
QPointer< QSpinBox > m_measureTableLimitSpinBox
When less than this number, sorting is enabled on the measure table.
void applySettings()
Apply the user's current settings to the cneteditor widget.
QPointer< QSpinBox > m_pointTableLimitSpinBox
When less than this number, sorting is enabled on the point table.
This widget provides full editing, filtering and viewing capabilities for the raw data in a control n...
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16