| 136 | } |
| 137 | |
| 138 | void ImportDialog::newDataContainer(QAction* action) { |
| 139 | DEBUG(Q_FUNC_INFO); |
| 140 | QString name = selectedObject(); |
| 141 | if (name.isEmpty()) |
| 142 | name = action->iconText(); |
| 143 | int actionIndex = m_newDataContainerMenu->actions().indexOf(action); |
| 144 | QString addText, nameText; |
| 145 | if (actionIndex == 0) { |
| 146 | addText = i18n("Add a new Workbook"); |
| 147 | nameText = i18n("Workbook name:"); |
| 148 | } else if (actionIndex == 1) { |
| 149 | addText = i18n("Add a new Spreadsheet"); |
| 150 | nameText = i18n("Spreadsheet name:"); |
| 151 | } else { |
| 152 | addText = i18n("Add a new Matrix"); |
| 153 | nameText = i18n("Matrix name:"); |
| 154 | } |
| 155 | |
| 156 | bool ok; |
| 157 | // child widgets can't have own icons |
| 158 | auto* dlg = new QInputDialog(this); |
| 159 | name = dlg->getText(this, addText, nameText, QLineEdit::Normal, name, &ok); |
| 160 | if (ok) { |
| 161 | AbstractAspect* aspect; |
| 162 | if (actionIndex == 0) |
| 163 | aspect = new Workbook(name); |
| 164 | else if (actionIndex == 1) |
| 165 | aspect = new Spreadsheet(name); |
| 166 | else |
| 167 | aspect = new Matrix(name); |
| 168 | |
| 169 | m_mainWin->addAspectToProject(aspect); |
| 170 | QDEBUG(Q_FUNC_INFO << ", cbAddTo->setCurrentModelIndex() to " << m_mainWin->model()->modelIndexOfAspect(aspect)); |
| 171 | cbAddTo->setCurrentModelIndex(m_mainWin->model()->modelIndexOfAspect(aspect)); |
| 172 | checkOkButton(); |
| 173 | |
| 174 | // select "Replace" since this is the most common case when importing into a newly created container |
| 175 | cbPosition->setCurrentIndex(2); |
| 176 | } |
| 177 | |
| 178 | delete dlg; |
| 179 | } |
| 180 | |
| 181 | void ImportDialog::newDataContainerMenu() { |
| 182 | m_newDataContainerMenu->exec(tbNewDataContainer->mapToGlobal(tbNewDataContainer->rect().bottomLeft())); |
nothing calls this directly
no test coverage detected