From: Dirk H Bartley Date: Sat, 31 May 2008 23:15:04 +0000 (+0000) Subject: This will store in settings the expanded state of the storage tree. X-Git-Tag: Release-3.0.0~1356 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=52a49e32a13a7351f7617d5efb871aefe86e1a72;p=bacula%2Fbacula This will store in settings the expanded state of the storage tree. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7077 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp index 3a33e28a8e..019ad781c8 100644 --- a/bacula/src/qt-console/storage/storage.cpp +++ b/bacula/src/qt-console/storage/storage.cpp @@ -65,6 +65,8 @@ Storage::Storage() Storage::~Storage() { + if (m_populated) + writeExpandedSettings(); } /* @@ -73,11 +75,12 @@ Storage::~Storage() */ void Storage::populateTree() { - QTreeWidgetItem *topItem; - if (!m_console->preventInUseConnect()) return; + if (m_populated) + writeExpandedSettings(); + m_checkcurwidget = false; mp_treeWidget->clear(); m_checkcurwidget = true; @@ -86,18 +89,25 @@ void Storage::populateTree() << tr("Changer") << tr("Slot") << tr("Status") << tr("Enabled") << tr("Pool") << tr("Media Type") ); - topItem = new QTreeWidgetItem(mp_treeWidget); - topItem->setText(0, tr("Storage")); - topItem->setData(0, Qt::UserRole, 0); - topItem->setExpanded(true); + m_topItem = new QTreeWidgetItem(mp_treeWidget); + m_topItem->setText(0, tr("Storage")); + m_topItem->setData(0, Qt::UserRole, 0); + m_topItem->setExpanded(true); mp_treeWidget->setColumnCount(headerlist.count()); mp_treeWidget->setHeaderLabels(headerlist); + QSettings settings(m_console->m_dir->name(), "bat"); + settings.beginGroup("StorageTreeExpanded"); + foreach(QString storageName, m_console->storage_list){ - TreeItemFormatter storageItem(*topItem, 1); + TreeItemFormatter storageItem(*m_topItem, 1); storageItem.setTextFld(0, storageName); - storageItem.widget()->setExpanded(true); + if(settings.contains(storageName)) { + storageItem.widget()->setExpanded(settings.value(storageName).toBool()); + } else { + storageItem.widget()->setExpanded(true); + } /* Set up query QString and header QStringList */ QString query("SELECT StorageId AS ID, AutoChanger AS Changer" @@ -203,7 +213,7 @@ void Storage::PgSeltreeWidgetClicked() if(!m_populated) { populateTree(); createContextMenu(); - m_populated=true; + m_populated = true; } } @@ -309,7 +319,7 @@ void Storage::currentStackItem() populateTree(); /* Create the context menu for the storage tree */ createContextMenu(); - m_populated=true; + m_populated = true; } } @@ -385,3 +395,18 @@ void Storage::statusStorageWindow() QTreeWidgetItem *parentItem = mainWin->getFromHash(this); new StorStat(m_currentStorage, parentItem); } + +/* + * Write settings to save expanded states of the pools + */ +void Storage::writeExpandedSettings() +{ + QSettings settings(m_console->m_dir->name(), "bat"); + settings.beginGroup("StorageTreeExpanded"); + int childcount = m_topItem->childCount(); + for (int cnt=0; cntchild(cnt); + settings.setValue(item->text(0), item->isExpanded()); + } + settings.endGroup(); +} diff --git a/bacula/src/qt-console/storage/storage.h b/bacula/src/qt-console/storage/storage.h index 173bd03a4e..3faafd7dcd 100644 --- a/bacula/src/qt-console/storage/storage.h +++ b/bacula/src/qt-console/storage/storage.h @@ -69,6 +69,8 @@ private: int m_currentAutoChanger; bool m_populated; bool m_checkcurwidget; + void writeExpandedSettings(); + QTreeWidgetItem *m_topItem; }; #endif /* _STORAGE_H_ */