X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fqt-console%2Fmainwin.cpp;h=a1352c742960cb8944970e4cf55bfec931aa8a30;hb=afd4ac31e0f65357c5264c04b804e86b2095a304;hp=a03e22102598e6afffd38d5ecc7db045ca44eedc;hpb=a1771fe927e48beecbc8c81406bb4156e92136a8;p=bacula%2Fbacula diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index a03e221025..a1352c7429 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2007-2008 Free Software Foundation Europe e.V. + Copyright (C) 2007-2009 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. @@ -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,19 +241,15 @@ 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())); connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about())); connect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help())); - connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, - SLOT(treeItemClicked(QTreeWidgetItem *, int))); - connect(treeWidget, SIGNAL( - currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); - connect(stackedWidget, SIGNAL(currentChanged(int)), - this, SLOT(stackItemChanged(int))); + connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); + connect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + connect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int))); connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows())); connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked())); connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked())); @@ -257,6 +264,90 @@ 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::disconnectSignals() +{ + /* Connect signals to slots */ + disconnect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line())); + disconnect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about())); + disconnect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help())); + disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); + disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + disconnect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int))); + disconnect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows())); + disconnect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked())); + disconnect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked())); + disconnect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked())); + disconnect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked())); + disconnect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked())); +#ifdef HAVE_QWT + disconnect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked())); +#endif + disconnect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked())); + disconnect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton())); + 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())); +} + +/* + * Enter wait state + */ +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)); + disconnectSignals(); + disconnectConsoleSignals(m_currentConsole); + m_waitTreeItem = treeWidget->currentItem(); +} + +/* + * Leave wait state + */ +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(); + } +} + +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); } /* @@ -376,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); @@ -393,10 +481,8 @@ 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(); QBrush magentaBrush(Qt::magenta); @@ -485,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.")); } @@ -639,6 +725,7 @@ Console *MainWin::currentConsole() { return m_currentConsole; } + /* Quick function to return the tree item for the director */ QTreeWidgetItem *MainWin::currentTopItem() { @@ -650,6 +737,7 @@ void MainWin::setPreferences() { prefsDialog prefs; prefs.commDebug->setCheckState(m_commDebug ? Qt::Checked : Qt::Unchecked); + prefs.connDebug->setCheckState(m_connDebug ? Qt::Checked : Qt::Unchecked); prefs.displayAll->setCheckState(m_displayAll ? Qt::Checked : Qt::Unchecked); prefs.sqlDebug->setCheckState(m_sqlDebug ? Qt::Checked : Qt::Unchecked); prefs.commandDebug->setCheckState(m_commandDebug ? Qt::Checked : Qt::Unchecked); @@ -705,6 +793,7 @@ void prefsDialog::accept() { this->hide(); mainWin->m_commDebug = this->commDebug->checkState() == Qt::Checked; + mainWin->m_connDebug = this->connDebug->checkState() == Qt::Checked; mainWin->m_displayAll = this->displayAll->checkState() == Qt::Checked; mainWin->m_sqlDebug = this->sqlDebug->checkState() == Qt::Checked; mainWin->m_commandDebug = this->commandDebug->checkState() == Qt::Checked; @@ -745,6 +834,7 @@ void prefsDialog::accept() QSettings settings("www.bacula.org", "bat"); settings.beginGroup("Debug"); settings.setValue("commDebug", mainWin->m_commDebug); + settings.setValue("connDebug", mainWin->m_connDebug); settings.setValue("displayAll", mainWin->m_displayAll); settings.setValue("sqlDebug", mainWin->m_sqlDebug); settings.setValue("commandDebug", mainWin->m_commandDebug); @@ -783,9 +873,6 @@ void prefsDialog::accept() settings.setValue("rtRestore2Debug", mainWin->m_rtRestore2Debug); settings.setValue("rtRestore3Debug", mainWin->m_rtRestore3Debug); settings.endGroup(); - foreach(Console *console, mainWin->m_consoleHash) { - console->startTimer(); - } } void prefsDialog::reject() @@ -800,6 +887,7 @@ void MainWin::readPreferences() QSettings settings("www.bacula.org", "bat"); settings.beginGroup("Debug"); m_commDebug = settings.value("commDebug", false).toBool(); + m_connDebug = settings.value("connDebug", false).toBool(); m_displayAll = settings.value("displayAll", false).toBool(); m_sqlDebug = settings.value("sqlDebug", false).toBool(); m_commandDebug = settings.value("commandDebug", false).toBool(); @@ -841,3 +929,11 @@ void MainWin::readPreferences() m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool(); settings.endGroup(); } + +void MainWin::setMessageIcon() +{ + if (m_currentConsole->is_messagesPending()) + actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-pending.png"))); + else + actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-new.png"))); +}