35 QWidget::setTabOrder(
m_form.groupBox,
m_form.cbColumnName);
36 QWidget::setTabOrder(
m_form.cbColumnName,
m_form.cbAscending);
39 m_form.btnRemoveColumn->setEnabled(
false);
40 m_form.btnAddColumn->setEnabled(
false);
43 connect(
m_form.workspace, SIGNAL(currentTextChanged(
const QString &)),
this, SLOT(
workspaceChanged(
const QString &)));
44 connect(
m_form.workspace, SIGNAL(emptied()),
this, SLOT(
clearGUI()));
46 connect(
m_form.btnAddColumn, SIGNAL(clicked()),
this, SLOT(
addColumn()));
57 QStringList ascending;
61 for (
int i = 0; i <
n; ++i) {
62 auto itemColumn =
m_form.columnsLayout->itemAtPosition(i, 1);
63 auto itemAscending =
m_form.columnsLayout->itemAtPosition(i, 2);
64 if (!itemColumn || !itemColumn->widget() || !itemAscending || !itemAscending->widget()) {
65 throw std::logic_error(
"Logic error in SortTableWorkspaceDialog: internal inconsistency.");
68 auto name =
dynamic_cast<QComboBox *
>(itemColumn->widget())->currentText();
69 auto ia =
dynamic_cast<QComboBox *
>(itemAscending->widget())->currentIndex();
71 ascending << QString::number(ia == 0 ? 1 : 0);
84 QStringList allowedTypes;
85 allowedTypes <<
"TableWorkspace";
86 m_form.workspace->setWorkspaceTypes(allowedTypes);
89 if (!
m_form.workspace->currentText().isEmpty()) {
101 m_form.output->setText(wsName);
104 if (wsName.isEmpty())
114 for (
const auto &columnName : columnNames) {
121 m_form.btnAddColumn->setEnabled(
false);
123 m_form.btnAddColumn->setEnabled(
true);
137 m_form.lblColumnName->setText(
"Column");
138 m_form.cbColumnName->clear();
139 m_form.cbAscending->setCurrentIndex(0);
140 m_form.btnAddColumn->setEnabled(
false);
141 m_form.btnRemoveColumn->setEnabled(
false);
143 auto nRows =
m_form.columnsLayout->rowCount();
144 for (
auto row = nRows - 1; row > 0; --row) {
145 for (
int col = 0; col < 3; ++col) {
146 auto item =
m_form.columnsLayout->itemAtPosition(row, col);
148 auto index =
m_form.columnsLayout->indexOf(item->widget());
150 item->widget()->deleteLater();
164 m_form.lblColumnName->setText(
"Column 1");
168 QLabel *label =
new QLabel(QString(
"Column %1").arg(newRow + 1));
169 auto *columnName =
new QComboBox();
171 columnName->setToolTip(
m_form.cbColumnName->toolTip());
172 connect(columnName, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changedColumnName(
int)));
173 auto *ascending =
new QComboBox();
174 ascending->addItem(
"Ascending");
175 ascending->addItem(
"Descending");
176 ascending->setToolTip(
m_form.cbAscending->toolTip());
178 m_form.columnsLayout->addWidget(label, newRow, 0);
179 m_form.columnsLayout->addWidget(columnName, newRow, 1);
180 m_form.columnsLayout->addWidget(ascending, newRow, 2);
182 QWidget::setTabOrder(
m_form.columnsLayout->itemAtPosition(newRow - 1, 2)->widget(), columnName);
183 QWidget::setTabOrder(columnName, ascending);
188 [&](
const auto &
name) { return !m_sortColumns.contains(name); });
190 columnName->setItemText(-1, *it);
196 m_form.btnAddColumn->setEnabled(
false);
198 m_form.btnRemoveColumn->setEnabled(
true);
207 for (
int i = 0; i <
n; ++i) {
208 auto item =
m_form.columnsLayout->itemAtPosition(i, 1);
209 if (!item || !item->widget() || !
dynamic_cast<QComboBox *
>(item->widget())) {
210 throw std::logic_error(
"Logic error in SortTableWorkspaceDialog: internal inconsistency.");
213 auto name =
dynamic_cast<QComboBox *
>(item->widget())->currentText();
226 for (
int col = 0; col < 3; ++col) {
227 auto item =
m_form.columnsLayout->itemAtPosition(row, col);
229 auto index =
m_form.columnsLayout->indexOf(item->widget());
231 item->widget()->deleteLater();
236 m_form.btnRemoveColumn->setEnabled(
false);
237 m_form.lblColumnName->setText(
"Column");
239 m_form.btnAddColumn->setEnabled(
true);
#define DECLARE_DIALOG(classname)
std::map< DeltaEMode::Type, std::string > index
This class should be the basis for all customised algorithm dialogs.
QLayout * createDefaultButtonLayout(const QString &helpText=QString("?"), const QString &loadText=QString("Run"), const QString &cancelText=QString("Close"), const QString &keepOpenText=QString("Keep Open"))
Create a row layout of buttons with specified text.
void storePropertyValue(const QString &name, const QString &value)
Adds a property (name,value) pair to the stored map.
QWidget * tie(QWidget *widget, const QString &property, QLayout *parent_layout=nullptr, bool readHistory=true)
Tie a widget to a property.
This class gives specialised dialog for the SortTableWorkspace algorithm.
void tieStaticWidgets(const bool readHistory)
Tie static widgets to their properties.
void addColumn()
Add GUI elements to set a new column as a sorting key.
QStringList m_columnNames
Names of the columns in the workspace.
void changedColumnName(int)
Sync the GUI after a sorting column name changes.
Ui::SortTableWorkspaceDialog m_form
Form.
void initLayout() override
Initialize the layout.
QStringList m_sortColumns
Names of columns used to sort the table.
void clearGUI()
Clear the GUI form the workspace specific data/elements.
void parseInput() override
Pass input from non-standard GUI elements to the algorithm.
void workspaceChanged(const QString &wsName)
Update GUI after workspace changes.
void removeColumn()
Remove a column to sort by.
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
virtual std::vector< std::string > getColumnNames() const =0
Returns a vector of all column names.
Exception for when an item is not found in a collection.