| 81 | } |
| 82 | |
| 83 | void FlattenColumnsDialog::setColumns(const QVector<Column*>& columns) { |
| 84 | m_columns = columns; |
| 85 | |
| 86 | // names of reference columns - columns that are not in the current selection in the spreadsheet |
| 87 | const auto& allColumns = m_spreadsheet->children<Column>(); |
| 88 | for (auto* column : allColumns) { |
| 89 | if (m_columns.indexOf(column) == -1) |
| 90 | m_referenceColumnNames << column->name(); |
| 91 | } |
| 92 | |
| 93 | if (!m_referenceColumnNames.isEmpty()) { |
| 94 | // add all other columns in the spreadsheet that were not selected as reference columns |
| 95 | for (int i = 0; i < m_referenceColumnNames.count(); ++i) |
| 96 | addReferenceColumn(); |
| 97 | } else |
| 98 | m_buttonNew->setEnabled(false); |
| 99 | |
| 100 | // resize the dialog to have the minimum height |
| 101 | layout()->activate(); |
| 102 | resize(QSize(this->width(), 0).expandedTo(minimumSize())); |
| 103 | } |
| 104 | |
| 105 | void FlattenColumnsDialog::addReferenceColumn() { |
| 106 | const int index = m_columnComboBoxes.size(); |