]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/mainwin.cpp
kes Reduce bconsole help to fit in 80 columns
[bacula/bacula] / bacula / src / qt-console / mainwin.cpp
index e41793171aef6472b454f587125fe826463fb9c2..a1352c742960cb8944970e4cf55bfec931aa8a30 100644 (file)
@@ -66,7 +66,10 @@ void message_callback(int /* type */, char *msg)
 
 MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
 {
+   app->setOverrideCursor(QCursor(Qt::WaitCursor));
    m_isClosing = false;
+   m_waitState = false;
+   m_doConnect = false;
    m_dtformat = "yyyy-MM-dd HH:mm:ss";
    mainWin = this;
    setupUi(this);                     /* Setup UI defined by main.ui (designer) */
@@ -79,9 +82,7 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
 
    createPages();
 
-   resetFocus();
-
-   createConnections();
+   resetFocus(); /* lineEdit->setFocus() */
 
 #ifndef HAVE_QWT
    actionJobPlot->setEnabled(false);
@@ -92,11 +93,10 @@ 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);
-   m_currentConsole->setCurrent();
+   QTimer::singleShot(750, this, SLOT(popLists()));
    if (m_miscDebug) {
       QString directoryResourceName;
       m_currentConsole->getDirResName(directoryResourceName);
@@ -104,6 +104,17 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
    }
 }
 
+void MainWin::popLists()
+{
+   foreach(Console *console, m_consoleHash)
+      console->populateLists(true);
+   app->restoreOverrideCursor();
+   m_doConnect = true;
+   connectConsoleSignals();
+   connectSignals();
+   m_currentConsole->setCurrent();
+}
+
 void MainWin::createPages()
 {
    DIRRES *dir;
@@ -230,7 +241,7 @@ void MainWin::keyPressEvent(QKeyEvent *event)
    lineEdit->setText(m_cmd_history[m_cmd_last]);
 }
 
-void MainWin::createConnections()
+void MainWin::connectSignals()
 {
    /* Connect signals to slots */
    connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
@@ -253,9 +264,10 @@ void MainWin::createConnections()
    connect(actionToggleDock, SIGNAL(triggered()), this,  SLOT(toggleDockContextWindow()));
    connect(actionClosePage, SIGNAL(triggered()), this,  SLOT(closePage()));
    connect(actionPreferences, SIGNAL(triggered()), this,  SLOT(setPreferences()));
+   connect(actionRepopLists, SIGNAL(triggered()), this,  SLOT(repopLists()));
 }
 
-void MainWin::disconnectConnections()
+void MainWin::disconnectSignals()
 {
    /* Connect signals to slots */
    disconnect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
@@ -278,6 +290,7 @@ void MainWin::disconnectConnections()
    disconnect(actionToggleDock, SIGNAL(triggered()), this,  SLOT(toggleDockContextWindow()));
    disconnect(actionClosePage, SIGNAL(triggered()), this,  SLOT(closePage()));
    disconnect(actionPreferences, SIGNAL(triggered()), this,  SLOT(setPreferences()));
+   disconnect(actionRepopLists, SIGNAL(triggered()), this,  SLOT(repopLists()));
 }
 
 /*
@@ -285,8 +298,18 @@ void MainWin::disconnectConnections()
  */
 void MainWin::waitEnter()
 {
+   if (m_waitState){ 
+      if (mainWin->m_connDebug)
+         Pmsg0(000, "Should Never Get Here DANGER DANGER, for now I'll return\n");
+      return;
+   }
+   m_waitState = true;
+   if (mainWin->m_connDebug)
+      Pmsg0(000, "Entering Wait State\n");
    app->setOverrideCursor(QCursor(Qt::WaitCursor));
-   disconnectConnections();
+   disconnectSignals();
+   disconnectConsoleSignals(m_currentConsole);
+   m_waitTreeItem = treeWidget->currentItem();
 }
 
 /*
@@ -294,8 +317,37 @@ void MainWin::waitEnter()
  */
 void MainWin::waitExit()
 {
+   m_waitState = false;
+   if (mainWin->m_connDebug)
+      Pmsg0(000, "Exiting Wait State\n");
    app->restoreOverrideCursor();
-   createConnections();
+   if (m_waitTreeItem != treeWidget->currentItem())
+      treeWidget->setCurrentItem(m_waitTreeItem);
+   if (m_doConnect) {
+      connectSignals();
+      connectConsoleSignals();
+   }
+}
+
+void MainWin::connectConsoleSignals()
+{
+   connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect_dir()));
+   connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font()));
+   connect(actionStatusDir, SIGNAL(triggered()), m_currentConsole, SLOT(status_dir()));
+   connect(actionMessages, SIGNAL(triggered()), m_currentConsole, SLOT(messages()));
+}
+
+void MainWin::disconnectConsoleSignals(Console *console)
+{
+   disconnect(actionConnect, SIGNAL(triggered()), console, SLOT(connect_dir()));
+   disconnect(actionStatusDir, SIGNAL(triggered()), console, SLOT(status_dir()));
+   disconnect(actionMessages, SIGNAL(triggered()), console, SLOT(messages()));
+   disconnect(actionSelectFont, SIGNAL(triggered()), console, SLOT(set_font()));
+}
+
+void MainWin::repopLists()
+{
+   m_currentConsole->populateLists(false);
 }
 
 /* 
@@ -415,10 +467,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre
       if ((previousPage) || (previousConsole)) {
          if (nextConsole != previousConsole) {
             /* remove connections to the current console */
-            disconnect(actionConnect, SIGNAL(triggered()), previousConsole, SLOT(connect_dir()));
-            disconnect(actionStatusDir, SIGNAL(triggered()), previousConsole, SLOT(status_dir()));
-            disconnect(actionMessages, SIGNAL(triggered()), previousConsole, SLOT(messages()));
-            disconnect(actionSelectFont, SIGNAL(triggered()), previousConsole, SLOT(set_font()));
+            disconnectConsoleSignals(previousConsole);
             QTreeWidgetItem *dirItem = previousConsole->directorTreeItem();
             QBrush greyBrush(Qt::lightGray);
             dirItem->setBackground(0, greyBrush);
@@ -432,10 +481,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre
       if (nextConsole != previousConsole) {
          /* make connections to the current console */
          m_currentConsole = nextConsole;
-         connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect_dir()));
-         connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font()));
-         connect(actionStatusDir, SIGNAL(triggered()), m_currentConsole, SLOT(status_dir()));
-         connect(actionMessages, SIGNAL(triggered()), m_currentConsole, SLOT(messages()));
+         connectConsoleSignals();
          setMessageIcon();
          /* Set director's tree widget background to magenta for ease of identification */
          QTreeWidgetItem *dirItem = m_currentConsole->directorTreeItem();
@@ -525,8 +571,8 @@ void MainWin::input_line()
    QString cmdStr = lineEdit->text();    /* Get the text */
    lineEdit->clear();                    /* clear the lineEdit box */
    if (m_currentConsole->is_connected()) {
-      /* Use consoleInput to allow typing anything */
-      m_currentConsole->consoleInput(cmdStr);
+      /* Use consoleCommand to allow typing anything */
+      m_currentConsole->consoleCommand(cmdStr);
    } else {
       set_status(tr("Director not connected. Click on connect button."));
    }
@@ -679,6 +725,7 @@ Console *MainWin::currentConsole()
 {
    return m_currentConsole;
 }
+
 /* Quick function to return the tree item for the director */
 QTreeWidgetItem *MainWin::currentTopItem()
 {