From 3faac9b57729bcb756943019efa74fe190a9774a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 31 Jan 2007 12:55:53 +0000 Subject: [PATCH] Update git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4083 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/README | 12 ++++++++++ bacula/src/qt-console/console/console.cpp | 28 +++++++++++++---------- bacula/src/qt-console/console/console.h | 4 +++- bacula/src/qt-console/main.ui | 21 +++++++++++++++++ bacula/src/qt-console/mainwin.cpp | 20 +++++++++++++++- bacula/src/qt-console/mainwin.h | 1 + 6 files changed, 72 insertions(+), 14 deletions(-) diff --git a/bacula/src/qt-console/README b/bacula/src/qt-console/README index e6d6d8c242..84ced9ba22 100644 --- a/bacula/src/qt-console/README +++ b/bacula/src/qt-console/README @@ -72,4 +72,16 @@ Design decisions: - All signal/slots are connected by explict code (most all are done in the MainWin constructor), rather than using designer. +Major projects: +- Implement a restore page that does a directory tree restore selection + much like wx-console does. +- Implement other restore interfaces such as brestore ... +- Implement a database browser +- Implement graphical commands that allow updating most aspects of + the database (i.e. commands for label, update Volume, ...) +- Implement a resource (conf file) browser +- Implement a reports page -- e.g. something similar to bweb +- Implement Qt plugins to add new functionality to bat +- Implement a GUI configuration file editor (something like JBacula). +... diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 9472af502b..5af0c86096 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -117,12 +117,12 @@ void Console::connect() mainWin->set_status("Connection failed"); return; } else { + /* Update page selector to green to indicate that Console is connected */ mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/connected.png"))); QBrush greenBrush(Qt::green); m_consoleItem->setForeground(0, greenBrush); } - jcr.dir_bsock = m_sock; if (!authenticate_director(&jcr, m_dir, cons)) { @@ -152,13 +152,11 @@ void Console::connect() mainWin->set_status(_(" Connected")); return; } -#ifdef xxx - QByteArray bytes = m_Bash->readAllStandardOutput(); - QStringList lines = QString(bytes).split("\n"); - foreach (QString line, lines) { - m_Logw->append(line); - } -#endif + +void Console::status_dir() +{ + write_dir("status dir\n"); +} void Console::set_textf(const char *fmt, ...) { @@ -175,8 +173,6 @@ void Console::set_text(const QString buf) { m_cursor->movePosition(QTextCursor::End); m_cursor->insertText(buf); - m_textEdit->moveCursor(QTextCursor::End); - m_textEdit->ensureCursorVisible(); } @@ -184,11 +180,18 @@ void Console::set_text(const char *buf) { m_cursor->movePosition(QTextCursor::End); m_cursor->insertText(buf); +} + +/* Position cursor to end of screen */ +void Console::update_cursor() +{ + QApplication::restoreOverrideCursor(); m_textEdit->moveCursor(QTextCursor::End); m_textEdit->ensureCursorVisible(); } +/* Send a command to the Director */ void Console::write_dir(const char *msg) { if (m_sock) { @@ -206,6 +209,7 @@ void Console::write_dir(const char *msg) } } +/* Called by signal when the Director has output for us */ void Console::read_dir(int fd) { int stat; @@ -240,11 +244,11 @@ void Console::read_dir(int fd) if (m_sock->msglen == BNET_PROMPT) { m_at_prompt = true; mainWin->set_status(_(" At prompt waiting for input ...")); - QApplication::restoreOverrideCursor(); + update_cursor(); } if (m_sock->msglen == BNET_EOD) { mainWin->set_status_ready(); - QApplication::restoreOverrideCursor(); + update_cursor(); } return; } diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 1fcf095591..0d0304c44b 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -18,13 +18,15 @@ public: void set_text(const char *buf); void set_text(const QString buf); void set_textf(const char *fmt, ...); + void update_cursor(void); void write_dir(const char *buf); bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons); bool is_connected() { return m_sock != NULL; }; public slots: - void connect(); + void connect(void); void read_dir(int fd); + void status_dir(void); private: QTextEdit *m_textEdit; diff --git a/bacula/src/qt-console/main.ui b/bacula/src/qt-console/main.ui index 5dd1a13232..e84aced37b 100644 --- a/bacula/src/qt-console/main.ui +++ b/bacula/src/qt-console/main.ui @@ -50,6 +50,9 @@ 16777215 + + Page Selector + @@ -154,6 +157,9 @@ + + Qt::ScrollBarAsNeeded + @@ -281,6 +287,7 @@ + @@ -422,6 +429,20 @@ Run a Job + + + images/status.png + + + StatusDir + + + status dir + + + Status of Director + + diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index ebe975d103..79f1cfbb6d 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -57,9 +57,12 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) SLOT(treeItemClicked(QTreeWidgetItem *, int))); connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); + connect(treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, + SLOT(treeItemDoubleClicked(QTreeWidgetItem *, int))); + connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows())); connect(actionConnect, SIGNAL(triggered()), m_console, SLOT(connect())); - + connect(actionStatusDir, SIGNAL(triggered()), m_console, SLOT(status_dir())); } void MainWin::treeItemClicked(QTreeWidgetItem *item, int column) @@ -71,6 +74,21 @@ void MainWin::treeItemClicked(QTreeWidgetItem *item, int column) } } +/* + * ***FIXME*** + * If item is a Console, then connect it + */ +void MainWin::treeItemDoubleClicked(QTreeWidgetItem *item, int column) +{ + (void)column; + int index = item->text(1).toInt(); + /* ***FIXME**** make this automatic */ + if (index >= 0 && index < 2) { + stackedWidget->setCurrentIndex(index); + } +} + + /* * The user just finished typing a line in the command line edit box diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 67d7b81acf..eed58b2185 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -54,6 +54,7 @@ public slots: void input_line(); void about(); void treeItemClicked(QTreeWidgetItem *item, int column); + void treeItemDoubleClicked(QTreeWidgetItem *item, int column); private: QString m_UserInput; -- 2.39.5