From d06897890612881cfb772888040d4e24b9aa59b7 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sat, 21 Apr 2007 16:32:01 +0000 Subject: [PATCH] Removed pages virtual doubleclick from existence and all subclasses that used it. Resolved writing and reading settings for console fonts. now on a per console configuration basis. Capitolized "C"lient to work with mysql in clients class. Change consolelist to consolehash so that it can also be used when a director tree widget is selected in the page selector to make the conole the current console. On start, the first console is the selected widget in page selector. Have signals connecting to the console class be connected and disconnected in tree item changed. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4585 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/TODO | 21 +++-- bacula/src/qt-console/clients/clients.cpp | 4 +- bacula/src/qt-console/console/console.cpp | 6 +- bacula/src/qt-console/console/console.h | 1 + bacula/src/qt-console/joblist/joblist.cpp | 4 +- bacula/src/qt-console/mainwin.cpp | 84 ++++++++++--------- bacula/src/qt-console/mainwin.h | 3 +- bacula/src/qt-console/medialist/medialist.cpp | 20 ----- bacula/src/qt-console/medialist/medialist.h | 2 - bacula/src/qt-console/pages.cpp | 4 - bacula/src/qt-console/pages.h | 1 - 11 files changed, 66 insertions(+), 84 deletions(-) diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index a1aa414e6e..53005ff0d1 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -1,5 +1,8 @@ dhb ==================================================== +Must:: get page selector to follow undocked windows. Otherwise +current console won't be current. + Low priority item: move behavior of: MainWin::setContextMenuDockText @@ -15,9 +18,10 @@ Add class for FileSets Create list of what does not work. -Ask Kern about bRestore and what to do with it in terms of priorities. +Ask Kern about bRestore and what to do with it in terms of priorities. Should +that be working before an initial release. -Fix bug in myt box not working with .sql query="" command. +Fix bug in myth box not working with .sql query="" command. Create documentation for any other developers interested in creating new classes to add more pages. Explain how to use the pages class @@ -29,15 +33,13 @@ the ability to surf what's on the job. Think about good ways to clean up the Console creation part of the loop creating pages. -Remove DoubleClicking, not needed any more. +Font is being set on a per console basis, should it be. +Tried to get the settings to write for a second, but not coming up next time + ======================================================== - Possibly some other things I didn't think of. -Things to do: -- When any director is clicked, we need to set it as the current -director and set the current console as well. - - I think we need to make the current Director more explicit, by perhaps highlighting it in the page selector when it is current and unhighlighting it when it is not (we could use color as we do @@ -81,6 +83,11 @@ global one defined in the mainWin class (if I remember right). ============================================================ DONE: ============================================================ +Things to do: +- When any director is clicked, we need to set it as the current +director and set the current console as well. + +Remove DoubleClicking, From pages class not needed any more. Broken with multiple directors: - If you click on the second director, it will probably open, but diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index 6d9baac6df..7f380c6b13 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.cpp @@ -89,14 +89,14 @@ void Clients::populateTree() /* Set up query QString and header QStringList */ QString query(""); query += "SELECT FileRetention, JobRetention, AutoPrune, ClientId, Uname" - " FROM client" + " FROM Client" " WHERE "; query += " Name='" + clientName + "'"; query += " ORDER BY Name"; QStringList results; /* This could be a log item */ - printf("Clients query cmd : %s\n",query.toUtf8().data()); + //printf("Clients query cmd : %s\n",query.toUtf8().data()); if (m_console->sql_cmd(query, results)) { int resultCount = results.count(); if (resultCount == 1){ diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 618d5a7b42..128e4765d9 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -53,7 +53,6 @@ Console::Console(QStackedWidget *parent) m_cursor = new QTextCursor(m_textEdit->document()); mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png"))); - readSettings(); /* Check for messages every 5 seconds */ // m_timer = new QTimer(this); // QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(poll_messages())); @@ -310,8 +309,7 @@ void Console::writeSettings() { QFont font = get_font(); - QSettings settings("bacula.org", "bat"); - /* ***FIXME*** make console name unique */ + QSettings settings(m_dir->name(), "bat"); settings.beginGroup("Console"); settings.setValue("consoleFont", font.family()); settings.setValue("consolePointSize", font.pointSize()); @@ -326,7 +324,7 @@ void Console::readSettings() { QFont font = get_font(); - QSettings settings("bacula.org", "bat"); + QSettings settings(m_dir->name(), "bat"); settings.beginGroup("Console"); font.setFamily(settings.value("consoleFont", "Courier").value()); font.setPointSize(settings.value("consolePointSize", 10).toInt()); diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index fcf02b0316..b6a0638df6 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -97,6 +97,7 @@ public: void setDirectorTreeItem(QTreeWidgetItem *); void setDirRes(DIRRES *dir); QTreeWidgetItem *directorTreeItem() { return m_directorTreeItem; }; + DIRRES *getDirRes() { return m_dir; }; QStringList job_list; QStringList client_list; diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 06fcc53501..9d10be8756 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -92,8 +92,8 @@ void JobList::populateTable() mp_tableWidget->setColumnCount(headerlist.size()); mp_tableWidget->setHorizontalHeaderLabels(headerlist); - /* This could be a user preference debug message?? */ - printf("Query cmd : %s\n",query.toUtf8().data()); + /* This could be a user preference debug message?? */ + //printf("Query cmd : %s\n",query.toUtf8().data()); if (m_console->sql_cmd(query, results)) { m_resultCount = results.count(); diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 8ce49cbbe2..56b62a1126 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -58,31 +58,42 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) readSettings(); - foreach(Console *console, m_consoleList){ + bool first = true; + foreach(Console *console, m_consoleHash){ console->connect(); + if (first) { + m_currentConsole = console; + treeWidget->setCurrentItem(getFromHash(console)); + first = false; + } } } void MainWin::createPages() { DIRRES *dir; - QTreeWidgetItem *item, *topItem; + QTreeWidgetItem *item, *topItem, *firstItem; + firstItem = NULL; LockRes(); foreach_res(dir, R_DIRECTOR) { /* Create console tree stacked widget item */ m_currentConsole = new Console(stackedWidget); - m_consoleList.append(m_currentConsole); m_currentConsole->setDirRes(dir); + m_currentConsole->readSettings(); /* The top tree item representing the director */ topItem = createTopPage(dir->name()); topItem->setIcon(0, QIcon(QString::fromUtf8("images/server.png"))); m_currentConsole->setDirectorTreeItem(topItem); + m_consoleHash.insert(topItem, m_currentConsole); /* Create Tree Widget Item */ item = createPage("Console", topItem); + if (!firstItem){ + firstItem = item; + } /* insert the cosole and tree widget item into the hashes */ hashInsert(item, m_currentConsole); @@ -106,9 +117,6 @@ void MainWin::createPages() stackedWidget->setCurrentWidget(m_currentConsole); } UnlockRes(); - m_currentConsole = m_consoleList[0]; - item = getFromHash(m_currentConsole); - treeWidget->setCurrentItem(item); } /* @@ -219,29 +227,14 @@ void MainWin::createConnections() /* Connect signals to slots */ connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line())); connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about())); - -#ifdef xxx - connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this, - SLOT(treeItemClicked(QTreeWidgetItem *, int))); - connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this, - SLOT(treeItemClicked(QTreeWidgetItem *, int))); -#endif connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); - connect(treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, - SLOT(treeItemDoubleClicked(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())); - foreach(Console *console, m_consoleList){ - connect(actionConnect, SIGNAL(triggered()), console, SLOT(connect())); - connect(actionStatusDir, SIGNAL(triggered()), console, SLOT(status_dir())); - connect(actionSelectFont, SIGNAL(triggered()), console, SLOT(set_font())); - } connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelDialogClicked())); connect(actionRun, SIGNAL(triggered()), this, SLOT(runDialogClicked())); connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreDialogClicked())); @@ -256,7 +249,7 @@ void MainWin::createConnections() void MainWin::closeEvent(QCloseEvent *event) { writeSettings(); - foreach(Console *console, m_consoleList){ + foreach(Console *console, m_consoleHash){ console->writeSettings(); console->terminate(); } @@ -306,44 +299,55 @@ void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/) } } -/* - * This subroutine is called with an item in the Page Selection window - * is double clicked - */ -/* This could be removed from here and from pages and from medialist - * Do you agree dhb */ -void MainWin::treeItemDoubleClicked(QTreeWidgetItem *item, int /*column*/) -{ - Pages* page = getFromHash(item); - page->PgSeltreeWidgetDoubleClicked(); -} - /* * Called with a change of the highlighed tree widget item in the page selector. */ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *previousitem) { + Pages* page; + Console* console; /* The Previous item */ if (previousitem) { + /* knowing the treeWidgetItem, get the page from the hash */ + page = getFromHash(previousitem); + console = m_consoleHash.value(previousitem); + if (page) { + console = page->console(); + } else if (console) { + page = console; + } + /* make connections to the current console */ + disconnect(actionConnect, SIGNAL(triggered()), console, SLOT(connect())); + disconnect(actionStatusDir, SIGNAL(triggered()), console, SLOT(status_dir())); + disconnect(actionSelectFont, SIGNAL(triggered()), console, SLOT(set_font())); /* make sure the close window and toggle dock options are removed */ treeWidget->removeAction(actionClosePage); treeWidget->removeAction(actionToggleDock); /* Is this a page that has been inserted into the hash */ - if (getFromHash(previousitem)) { - Pages* page = getFromHash(previousitem); + if (page) { foreach(QAction* pageaction, page->m_contextActions) { treeWidget->removeAction(pageaction); } } } + /* knowing the treeWidgetItem, get the page from the hash */ + page = getFromHash(currentitem); + console = m_consoleHash.value(currentitem); /* Is this a page that has been inserted into the hash */ - if (getFromHash(currentitem)) { - /* knowing the treeWidgetItem, get the page from the hash */ - Pages* page = getFromHash(currentitem); - /* set the value for the currently active console */ + if (page) { m_currentConsole = page->console(); + } else if (console) { + m_currentConsole = console; + page = console; + } + if ((page) || (console)) { + /* make connections to the current console */ + connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect())); + connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font())); + connect(actionStatusDir, SIGNAL(triggered()), m_currentConsole, SLOT(status_dir())); + /* set the value for the currently active console */ int stackindex = stackedWidget->indexOf(page); /* Is this page currently on the stack */ diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 98dbfd0161..054e6be79f 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -77,14 +77,13 @@ public: /* This hash is to get the page selector widget when the page is known */ QHash m_widgethash; /* This is a list of consoles */ - QList m_consoleList; + QHash m_consoleHash; void createPageJobList(QString &, QString &); public slots: void input_line(); void about(); void treeItemClicked(QTreeWidgetItem *item, int column); - void treeItemDoubleClicked(QTreeWidgetItem *item, int column); void labelDialogClicked(); void runDialogClicked(); void restoreDialogClicked(); diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 40085457d1..38537ae669 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -135,8 +135,6 @@ void MediaList::createConnections() { connect(mp_treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); - connect(mp_treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, - SLOT(treeItemDoubleClicked(QTreeWidgetItem *, int))); } /* @@ -146,13 +144,6 @@ void MediaList::treeItemClicked(QTreeWidgetItem * /*item*/, int /*column*/) { } -/* - * Not being used currently, Should this be kept for possible future use. - */ -void MediaList::treeItemDoubleClicked(QTreeWidgetItem * /*item*/, int /*column*/) -{ -} - /* * Called from the signal of the context sensitive menu! */ @@ -184,17 +175,6 @@ void MediaList::PgSeltreeWidgetClicked() } } -/* - * When the treeWidgetItem in the page selector tree is doubleclicked, Use that - * As a signal to repopulate from a query of the database. - * Should this be from a context sensitive menu in either or both of the page selector - * or This widnow ??? - */ -void MediaList::PgSeltreeWidgetDoubleClicked() -{ - populateTree(); -} - /* * Added to set the context menu policy based on currently active treeWidgetItem * signaled by currentItemChanged diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index 0ce75b636e..378e88ab36 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -46,12 +46,10 @@ public: MediaList(); ~MediaList(); virtual void PgSeltreeWidgetClicked(); - virtual void PgSeltreeWidgetDoubleClicked(); virtual void currentStackItem(); public slots: void treeItemClicked(QTreeWidgetItem *item, int column); - void treeItemDoubleClicked(QTreeWidgetItem *item, int column); void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); void editMedia(); void showJobs(); diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 29ad450556..8858a76623 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -148,10 +148,6 @@ void Pages::PgSeltreeWidgetClicked() { } -void Pages::PgSeltreeWidgetDoubleClicked() -{ -} - /* * Virtual function which is called when this page is visible on the stack. * This will be overridden by classes that want to populate if they are on the diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index e5732bc481..a5616ddcb0 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -63,7 +63,6 @@ public: QStackedWidget *m_parent; QList m_contextActions; virtual void PgSeltreeWidgetClicked(); - virtual void PgSeltreeWidgetDoubleClicked(); virtual void currentStackItem(); void closeStackPage(); Console *console() { return m_console; }; -- 2.39.5