]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/pages.cpp
Fix bat bug that consumes connections + add braces on ifs + rename subroutines
[bacula/bacula] / bacula / src / qt-console / pages.cpp
index 1b99dbb13cf0dd653f49ae59eb5c5725ca2f1ef4..de0f2d3926d248192974ba713641f6c3e868f33e 100644 (file)
@@ -68,15 +68,29 @@ void Pages::dockPage()
     */
    setWindowFlags(Qt::Widget);
 
+   /* calculate the index that the tab should be inserted into */
+   int tabPos = 0;
+   QTreeWidgetItemIterator it(mainWin->treeWidget);
+   while (*it) {
+      Pages *somepage = mainWin->getFromHash(*it);
+      if (this == somepage) {
+         tabPos += 1;
+         break;
+      }
+      int pageindex = mainWin->tabWidget->indexOf(somepage);
+      if (pageindex != -1) { tabPos = pageindex; }
+      ++it;
+   }
+
    /* This was being done already */
-   m_parent->addTab(this, m_name);
+   m_parent->insertTab(tabPos, this, m_name);
 
    /* Set docked flag */
    m_docked = true;
+   m_onceDocked = true;
    mainWin->tabWidget->setCurrentWidget(this);
    /* lets set the page selectors action for docking or undocking */
    setContextMenuDockText();
-
 }
 
 /*
@@ -126,6 +140,17 @@ bool Pages::isDocked()
    return m_docked;
 }
 
+/*
+ * This function is because after the tabbed widget was added I could not tell
+ * from is docked if it had been docked yet.  To prevent status pages from requesting
+ * status from the director
+ */
+bool Pages::isOnceDocked()
+{
+   return m_onceDocked;
+}
+
+
 /*
  * To keep m_closeable protected as well
  */
@@ -207,6 +232,7 @@ void Pages::pgInitialize(const QString &name)
 void Pages::pgInitialize(const QString &tname, QTreeWidgetItem *parentTreeWidgetItem)
 {
    m_docked = false;
+   m_onceDocked = false;
    if (tname.size()) {
       m_name = tname;
    }
@@ -246,7 +272,7 @@ void Pages::consoleCommand(QString &command, bool setCurrent)
 {
    int conn;
    bool donotify = false;
-   if (m_console->availableDirComm(conn))  {
+   if (m_console->getDirComm(conn))  {
       if (m_console->is_notify_enabled(conn)) {
          donotify = true;
          m_console->notify(conn, false);