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(currentIndexChanged(
const QString &)),
this,
45 connect(
m_form.workspace, SIGNAL(emptied()),
this, SLOT(
clearGUI()));
47 connect(
m_form.btnAddColumn, SIGNAL(clicked()),
this, SLOT(
addColumn()));
58 QStringList ascending;
62 for (
int i = 0; i <
n; ++i) {
63 auto itemColumn =
m_form.columnsLayout->itemAtPosition(i, 1);
64 auto itemAscending =
m_form.columnsLayout->itemAtPosition(i, 2);
65 if (!itemColumn || !itemColumn->widget() || !itemAscending || !itemAscending->widget()) {
66 throw std::logic_error(
"Logic error in SortTableWorkspaceDialog: internal inconsistency.");
69 auto name =
dynamic_cast<QComboBox *
>(itemColumn->widget())->currentText();
70 auto ia =
dynamic_cast<QComboBox *
>(itemAscending->widget())->currentIndex();
72 ascending << QString::number(ia == 0 ? 1 : 0);
85 QStringList allowedTypes;
86 allowedTypes <<
"TableWorkspace";
87 m_form.workspace->setWorkspaceTypes(allowedTypes);
90 if (!
m_form.workspace->currentText().isEmpty()) {
102 m_form.output->setText(wsName);
105 if (wsName.isEmpty())
114 auto columnNames = ws->getColumnNames();
115 for (
auto &columnName : columnNames) {
122 m_form.btnAddColumn->setEnabled(
false);
124 m_form.btnAddColumn->setEnabled(
true);
138 m_form.lblColumnName->setText(
"Column");
139 m_form.cbColumnName->clear();
140 m_form.cbAscending->setCurrentIndex(0);
141 m_form.btnAddColumn->setEnabled(
false);
142 m_form.btnRemoveColumn->setEnabled(
false);
144 auto nRows =
m_form.columnsLayout->rowCount();
145 for (
auto row = nRows - 1; row > 0; --row) {
146 for (
int col = 0; col < 3; ++col) {
147 auto item =
m_form.columnsLayout->itemAtPosition(row, col);
149 auto index =
m_form.columnsLayout->indexOf(item->widget());
151 item->widget()->deleteLater();
165 m_form.lblColumnName->setText(
"Column 1");
169 QLabel *label =
new QLabel(QString(
"Column %1").arg(newRow + 1));
170 auto *columnName =
new QComboBox();
172 columnName->setToolTip(
m_form.cbColumnName->toolTip());
173 connect(columnName, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changedColumnName(
int)));
174 auto *ascending =
new QComboBox();
175 ascending->addItem(
"Ascending");
176 ascending->addItem(
"Descending");
177 ascending->setToolTip(
m_form.cbAscending->toolTip());
179 m_form.columnsLayout->addWidget(label, newRow, 0);
180 m_form.columnsLayout->addWidget(columnName, newRow, 1);
181 m_form.columnsLayout->addWidget(ascending, newRow, 2);
183 QWidget::setTabOrder(
m_form.columnsLayout->itemAtPosition(newRow - 1, 2)->widget(), columnName);
184 QWidget::setTabOrder(columnName, ascending);
188 QString newColumnName;
191 columnName->setItemText(-1, name);
199 m_form.btnAddColumn->setEnabled(
false);
201 m_form.btnRemoveColumn->setEnabled(
true);
210 for (
int i = 0; i <
n; ++i) {
211 auto item =
m_form.columnsLayout->itemAtPosition(i, 1);
212 if (!item || !item->widget() || !
dynamic_cast<QComboBox *
>(item->widget())) {
213 throw std::logic_error(
"Logic error in SortTableWorkspaceDialog: internal inconsistency.");
216 auto name =
dynamic_cast<QComboBox *
>(item->widget())->currentText();
229 for (
int col = 0; col < 3; ++col) {
230 auto item =
m_form.columnsLayout->itemAtPosition(row, col);
232 auto index =
m_form.columnsLayout->indexOf(item->widget());
234 item->widget()->deleteLater();
239 m_form.btnRemoveColumn->setEnabled(
false);
240 m_form.lblColumnName->setText(
"Column");
242 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 ...
Exception for when an item is not found in a collection.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...