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