]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/mainwin.cpp
Fix bat bug that consumes connections + add braces on ifs + rename subroutines
[bacula/bacula] / bacula / src / qt-console / mainwin.cpp
index 43b70d54d624f405e152a84c2507858f85cd0763..e72cd7562a9feca423828a8d1f9e05eedf93adc8 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -27,7 +27,6 @@
 */
 
 /*
- *   Version $Id$
  *
  *  Main Window control for bat (qt-console)
  *
@@ -50,6 +49,7 @@
 #include "restore/restoretree.h"
 #include "help/help.h"
 #include "jobs/jobs.h"
+#include "medialist/mediaview.h"
 #ifdef HAVE_QWT
 #include "jobgraphs/jobplot.h"
 #endif
@@ -94,25 +94,28 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
 
    readSettings();
 
-   foreach(Console *console, m_consoleHash)
+   foreach(Console *console, m_consoleHash) {
       console->connect_dir();
+   }
    m_currentConsole = (Console*)getFromHash(m_firstItem);
-   QTimer::singleShot(750, this, SLOT(popLists()));
+   QTimer::singleShot(5000, this, SLOT(popLists()));
    if (m_miscDebug) {
       QString directoryResourceName;
       m_currentConsole->getDirResName(directoryResourceName);
       Pmsg1(100, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
    }
+   app->restoreOverrideCursor();
 }
 
 void MainWin::popLists()
 {
-   foreach(Console *console, m_consoleHash)
+   foreach(Console *console, m_consoleHash) {
       console->populateLists(true);
-   app->restoreOverrideCursor();
+   }
    m_doConnect = true;
    connectConsoleSignals();
    connectSignals();
+   app->restoreOverrideCursor();
    m_currentConsole->setCurrent();
 }
 
@@ -154,7 +157,6 @@ void MainWin::createPages()
       */
       QBrush redBrush(Qt::red);
       item->setForeground(0, redBrush);
-      m_currentConsole->dockPage();
 
       /*
        * Create instances in alphabetic order of the rest 
@@ -172,6 +174,7 @@ void MainWin::createPages()
          new JobPlot(NULL, pass);
 #endif
       new MediaList();
+      new MediaView();
       new Storage();
       if (m_openBrowser)
          new restoreTree();
@@ -180,6 +183,8 @@ void MainWin::createPages()
 
       treeWidget->expandItem(topItem);
       tabWidget->setCurrentWidget(m_currentConsole);
+      m_currentConsole->undockPage();
+      m_currentConsole->dockPage();
    }
    UnlockRes();
 }
@@ -322,13 +327,13 @@ void MainWin::waitExit()
 {
    m_waitState = false;
    if (mainWin->m_connDebug) Pmsg0(000, "Exiting Wait State\n");
-   app->restoreOverrideCursor();
    if (m_waitTreeItem != treeWidget->currentItem())
       treeWidget->setCurrentItem(m_waitTreeItem);
    if (m_doConnect) {
       connectSignals();
       connectConsoleSignals();
    }
+   app->restoreOverrideCursor();
 }
 
 void MainWin::connectConsoleSignals()
@@ -594,7 +599,7 @@ void MainWin::input_line()
    QString cmdStr = lineEdit->text();    /* Get the text */
    lineEdit->clear();                    /* clear the lineEdit box */
    if (m_currentConsole->is_connected()) {
-      if (m_currentConsole->currentDirComm(conn)) {
+      if (m_currentConsole->findDirComm(conn)) {
          m_currentConsole->consoleCommand(cmdStr, conn);
       } else {
          /* Use consoleCommand to allow typing anything */
@@ -686,6 +691,13 @@ void MainWin::stackItemChanged(int)
    Pages* page = (Pages*)tabWidget->currentWidget();
    /* run the virtual function in case this class overrides it */
    page->currentStackItem();
+   if (!m_waitState) {
+      disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+      disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+      treeWidget->setCurrentItem(getFromHash(page));
+      connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+      connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+   }
 }
 
 /*