| 268 | } |
| 269 | |
| 270 | void QtShowViewDialog::SaveState() |
| 271 | { |
| 272 | XMLMemento::Pointer memento = XMLMemento::CreateWriteRoot(TAG_SHOWVIEWDIALOG); |
| 273 | memento->PutString("filter", m_UserInterface->m_Filter->text()); |
| 274 | memento->PutBoolean("keywordFilter", m_UserInterface->m_KeywordFilter->isChecked()); |
| 275 | |
| 276 | // dialog geometry |
| 277 | QByteArray geom = this->saveGeometry(); |
| 278 | IMemento::Pointer geomChild = memento->CreateChild(TAG_GEOMETRY); |
| 279 | geomChild->PutTextData(geom.toBase64().constData()); |
| 280 | |
| 281 | // expanded categories |
| 282 | for (const QPersistentModelIndex &index : std::as_const(m_ExpandedCategories)) |
| 283 | { |
| 284 | if (index.isValid()) |
| 285 | { |
| 286 | QString id = index.data(ViewTreeModel::Id).toString(); |
| 287 | if (!id.isEmpty()) |
| 288 | { |
| 289 | memento->CreateChild(TAG_CATEGORY, id); |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | // we only record a single selected item. restoring a multi-selection might be |
| 295 | // confusing for the user |
| 296 | QModelIndexList selectedIndices = m_UserInterface->m_TreeView->selectionModel()->selectedIndexes(); |
| 297 | if (!selectedIndices.isEmpty()) |
| 298 | { |
| 299 | QString id = selectedIndices.back().data(ViewTreeModel::Id).toString(); |
| 300 | if (!id.isEmpty()) |
| 301 | { |
| 302 | memento->CreateChild(TAG_SELECTION, id); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | std::stringstream ss; |
| 307 | memento->Save(ss); |
| 308 | |
| 309 | auto* prefs = WorkbenchPlugin::GetDefault()->GetPreferences(); |
| 310 | prefs->Put(TAG_SHOWVIEWDIALOG.toStdString(), ss.str()); |
| 311 | prefs->Flush(); |
| 312 | } |
| 313 | |
| 314 | void QtShowViewDialog::done(int r) |
| 315 | { |
no test coverage detected