MCPcopy Create free account
hub / github.com/MITK/MITK / SaveState

Method SaveState

Plugins/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.cpp:270–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void 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
314void QtShowViewDialog::done(int r)
315{

Callers 1

doneMethod · 0.95

Calls 13

GetDefaultFunction · 0.85
PutStringMethod · 0.80
textMethod · 0.80
PutBooleanMethod · 0.80
CreateChildMethod · 0.80
PutTextDataMethod · 0.80
backMethod · 0.80
toStringMethod · 0.45
dataMethod · 0.45
SaveMethod · 0.45
GetPreferencesMethod · 0.45
PutMethod · 0.45

Tested by

no test coverage detected