]> git.sur5r.net Git - bacula/bacula/commitdiff
This will store in settings the expanded state of the storage tree.
authorDirk H Bartley <dbartley@schupan.com>
Sat, 31 May 2008 23:15:04 +0000 (23:15 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sat, 31 May 2008 23:15:04 +0000 (23:15 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7077 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/storage/storage.cpp
bacula/src/qt-console/storage/storage.h

index 3a33e28a8edd2198fc33cae73dbe9ab509ee492f..019ad781c8267963b6d86ce3297fb12fa4b28e05 100644 (file)
@@ -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; cnt<childcount; cnt++) {
+      QTreeWidgetItem *item = m_topItem->child(cnt);
+      settings.setValue(item->text(0), item->isExpanded());
+   }
+   settings.endGroup();
+}
index 173bd03a4e28866a665f120e68c955559fd8065a..3faafd7dcd0ee64f10944785615a5d371e7e3897 100644 (file)
@@ -69,6 +69,8 @@ private:
    int m_currentAutoChanger;
    bool m_populated;
    bool m_checkcurwidget;
+   void writeExpandedSettings();
+   QTreeWidgetItem *m_topItem;
 };
 
 #endif /* _STORAGE_H_ */