]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/storage/storage.cpp
On vacation I am having a little fun !!
[bacula/bacula] / bacula / src / qt-console / storage / storage.cpp
index 8484ae12d66ae71a802a6b4dd3d75bfd4cc3b7d6..d76c8e9e0708019752a4169759b206a14aa7ffeb 100644 (file)
@@ -53,6 +53,7 @@ Storage::Storage()
 
    /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_storage.h */
    m_populated = false;
+   m_firstpopulation = true;
    m_checkcurwidget = true;
    m_closeable = false;
    m_currentStorage = "";
@@ -132,6 +133,10 @@ void Storage::populateTree()
          foreach (QString resultline, results) {
             fieldlist = resultline.split("\t");
             storageName = fieldlist.takeFirst();
+            if (m_firstpopulation) {
+               m_firstpopulation = false;
+               settingsOpenStatus(storageName);
+            }
             TreeItemFormatter storageItem(*m_topItem, 1);
             storageItem.setTextFld(0, storageName);
             if(settings.contains(storageName))
@@ -404,8 +409,20 @@ void Storage::consoleRelease()
  */
 void Storage::statusStorageWindow()
 {
-   QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
-   new StorStat(m_currentStorage, parentItem);
+   /* if one exists, then just set it current */
+   bool found = false;
+   foreach(Pages *page, mainWin->m_pagehash) {
+      if (mainWin->currentConsole() == page->console()) {
+         if (page->name() == tr("Storage Status %1").arg(m_currentStorage)) {
+            found = true;
+            page->setCurrent();
+         }
+      }
+   }
+   if (!found) {
+      QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+      new StorStat(m_currentStorage, parentItem);
+   }
 }
 
 /*
@@ -422,3 +439,24 @@ void Storage::writeExpandedSettings()
    }
    settings.endGroup();
 }
+
+/*
+ * If first time, then check to see if there were status pages open the last time closed
+ * if so open
+ */
+void Storage::settingsOpenStatus(QString &storage)
+{
+   QSettings settings(m_console->m_dir->name(), "bat");
+
+   settings.beginGroup("OpenOnExit");
+   QString toRead = "StorageStatus_" + storage;
+   if (settings.value(toRead) == 1) {
+      Pmsg1(000, "Do open Storage Status window for : %s\n", storage.toUtf8().data());
+      new StorStat(storage, mainWin->getFromHash(this));
+      setCurrent();
+      mainWin->getFromHash(this)->setExpanded(true);
+   } else {
+      Pmsg1(000, "Do NOT open Storage Status window for : %s\n", storage.toUtf8().data());
+   }
+   settings.endGroup();
+}