]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/fileset/fileset.cpp
Tweak FileSet
[bacula/bacula] / bacula / src / qt-console / fileset / fileset.cpp
index 567ca77b81b7b1d3368beee2ed2b459db7de9e15..ded84d15d64fda8c7b8e9f0fd93163c72c8c9cb6 100644 (file)
@@ -50,10 +50,12 @@ FileSet::FileSet()
    m_populated = false;
    m_checkcurwidget = true;
    m_closeable = false;
+   readSettings();
 }
 
 FileSet::~FileSet()
 {
+   writeSettings();
 }
 
 /*
@@ -64,8 +66,9 @@ void FileSet::populateTree()
 {
    QTreeWidgetItem *filesetItem, *topItem;
 
+   if (!m_console->preventInUseConnect())
+       return;
 
-   Dmsg0(000, "Populate fileset tree called.\n");
    m_checkcurwidget = false;
    mp_treeWidget->clear();
    m_checkcurwidget = true;
@@ -80,8 +83,6 @@ void FileSet::populateTree()
 
    mp_treeWidget->setColumnCount(headerlist.count());
    mp_treeWidget->setHeaderLabels(headerlist);
-   /* This could be a log item */
-   //printf("In FileSet::populateTree()\n");
 
    foreach(QString filesetName, m_console->fileset_list) {
       filesetItem = new QTreeWidgetItem(topItem);
@@ -98,8 +99,9 @@ void FileSet::populateTree()
       query += " ORDER BY FileSet";
 
       QStringList results;
-      /* This could be a log item */
-      //printf("FileSet query cmd : %s\n",query.toUtf8().data());
+      if (mainWin->m_sqlDebug) {
+         Pmsg1(000, "FileSet query cmd : %s\n",query.toUtf8().data());
+      }
       if (m_console->sql_cmd(query, results)) {
          int resultCount = results.count();
          if (resultCount == 1){
@@ -113,10 +115,10 @@ void FileSet::populateTree()
                /* Iterate through fields in the record */
                foreach (field, fieldlist) {
                   field = field.trimmed();  /* strip leading & trailing spaces */
-                  filesetItem->setData(index+1, Qt::UserRole, 1);
+                  filesetItem->setData(index, Qt::UserRole, 1);
                   /* Put media fields under the pool tree item */
-                  filesetItem->setData(index+1, Qt::UserRole, 1);
-                  filesetItem->setText(index+1, field);
+                  filesetItem->setData(index, Qt::UserRole, 1);
+                  filesetItem->setText(index, field);
                   index++;
                }
             }
@@ -124,7 +126,7 @@ void FileSet::populateTree()
       }
    }
    /* Resize the columns */
-   for(int cnter=1; cnter<headerlist.size(); cnter++) {
+   for (int cnter=1; cnter<headerlist.size(); cnter++) {
       mp_treeWidget->resizeColumnToContents(cnter);
    }
 
@@ -208,7 +210,7 @@ void FileSet::currentStackItem()
    if(!m_populated) {
       populateTree();
       /* add context sensitive menu items specific to this classto the page
-       * selector tree. m_m_contextActions is QList of QActions, so this is 
+       * selector tree. m_contextActions is QList of QActions, so this is 
        * only done once with the first population. */
       m_contextActions.append(actionRefreshFileSet);
       /* Create the context menu for the fileset tree */
@@ -216,3 +218,25 @@ void FileSet::currentStackItem()
       m_populated=true;
    }
 }
+
+/*
+ * Save user settings associated with this page
+ */
+void FileSet::writeSettings()
+{
+   QSettings settings(m_console->m_dir->name(), "bat");
+   settings.beginGroup("FileSet");
+   settings.setValue("geometry", saveGeometry());
+   settings.endGroup();
+}
+
+/*
+ * Read and restore user settings associated with this page
+ */
+void FileSet::readSettings()
+{ 
+   QSettings settings(m_console->m_dir->name(), "bat");
+   settings.beginGroup("FileSet");
+   restoreGeometry(settings.value("geometry").toByteArray());
+   settings.endGroup();
+}