| 207 | } |
| 208 | |
| 209 | GrepOutputModel* GrepOutputView::renewModel(const GrepJobSettings& settings, const QString& description) |
| 210 | { |
| 211 | // clear oldest model |
| 212 | while(modelSelector->count() >= GrepOutputView::HISTORY_SIZE) { |
| 213 | QVariant var = modelSelector->itemData(GrepOutputView::HISTORY_SIZE - 1); |
| 214 | qvariant_cast<QObject*>(var)->deleteLater(); |
| 215 | modelSelector->removeItem(GrepOutputView::HISTORY_SIZE - 1); |
| 216 | } |
| 217 | |
| 218 | while(m_settingsHistory.count() >= GrepOutputView::HISTORY_SIZE) { |
| 219 | m_settingsHistory.removeFirst(); |
| 220 | } |
| 221 | |
| 222 | replacementCombo->clearEditText(); |
| 223 | |
| 224 | auto* newModel = new GrepOutputModel(resultsTreeView); |
| 225 | applyButton->setEnabled(false); |
| 226 | // text may be already present |
| 227 | newModel->setReplacement(replacementCombo->currentText()); |
| 228 | connect(newModel, &GrepOutputModel::rowsRemoved, |
| 229 | this, &GrepOutputView::rowsRemoved); |
| 230 | connect(resultsTreeView, &QTreeView::activated, newModel, &GrepOutputModel::activate); |
| 231 | connect(replacementCombo, &KComboBox::editTextChanged, newModel, &GrepOutputModel::setReplacement); |
| 232 | connect(newModel, &GrepOutputModel::rowsInserted, this, &GrepOutputView::expandElements); |
| 233 | connect(newModel, &GrepOutputModel::showErrorMessage, this, &GrepOutputView::showErrorMessage); |
| 234 | connect(m_plugin, &GrepViewPlugin::grepJobFinished, this, &GrepOutputView::updateScrollArea); |
| 235 | |
| 236 | // appends new model to history |
| 237 | modelSelector->insertItem(0, description, QVariant::fromValue<QObject*>(newModel)); |
| 238 | modelSelector->setCurrentIndex(0); |
| 239 | |
| 240 | m_settingsHistory.append(settings); |
| 241 | |
| 242 | updateCheckable(); |
| 243 | |
| 244 | return newModel; |
| 245 | } |
| 246 | |
| 247 | |
| 248 | GrepOutputModel* GrepOutputView::model() |
no test coverage detected