From: Dirk H Bartley Date: Sat, 21 Apr 2007 03:26:13 +0000 (+0000) Subject: Multiple directors are working. Still more todo. See TODO file. X-Git-Tag: Release-7.0.0~6553 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=80d44ae9cd16c00704c0fb56b5c82e42db54c6d4;p=bacula%2Fbacula Multiple directors are working. Still more todo. See TODO file. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4575 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index e76b5d7e57..a1aa414e6e 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -1,7 +1,36 @@ -Broken with multiple directors: -- If you click on the second director, it will probably open, but -none of the pages that are defined below it will be able to talk -to it. They will most likely talk to the first director. +dhb +==================================================== +Low priority item: +move behavior of: + MainWin::setContextMenuDockText + MainWin::setTreeWidgetItemDockColor +to the pages class + +Add context sensitive options for most commands + +Re-add class for storage, I accidentally reverted because I left +it on my laptop. This is why I like committing often. + +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. + +Fix bug in myt 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 +and about not populating until the tree widget is clicked etc... + +A Tree widget context sensitive from anywhere a job is listed for +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. +======================================================== - Possibly some other things I didn't think of. @@ -9,6 +38,55 @@ 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 +for the console, though some color blind people may have +problems. + +Another idea for what you have implemented: +- I think that the dynamic pages that you create on the fly +should be nested under the item that creates them more like a +directory tree. + +For example: Jobs on Volume xxx, probably should be shown under +"All Jobs" (or Media if that is what created it) and "Jobs of +Client Rufus" probably should be shown under "Clients". I base +this on looking at the Select page list after I have brought up 3 +or 4 dynamic pages. Once there are a good number, I get a bit +confused where they came from. This would also permit selecting +multipe Volumes then displaying multiple pages, one for each +Volume selected. If they are nested, then that nested level can +be expanded or collapsed, which would be pretty cool at keeping +information, but getting it out of the way, sort of like what +happens for a directory tree. + +dhb: ref above +My original concept was to put these in a tabbed widget. Your Idea may +make for a cleaner user experience. I like it. It could save the +effort of getting a tabbed widget to work. + +=========================================================== +NOT SURE +=========================================================== + +I'm not sure about this one?? Things seem to work and I did not do a +thing to make it happen: the "dir" is a member of Console + +- We also must somehow make the low level I/O routines know which +director/console to use. Currently they always use the single +global one defined in the mainWin class (if I remember right). + + +============================================================ +DONE: +============================================================ + +Broken with multiple directors: +- If you click on the second director, it will probably open, but +none of the pages that are defined below it will be able to talk +to it. They will most likely talk to the first director. + - When any console is clicked we need to set it as the current console (m_console) and also set its director as the current director (m_topItem). These are in the mainwin class. @@ -17,29 +95,27 @@ director (m_topItem). These are in the mainwin class. director (m_topItem) and current console (m_console) that this page is connected to. -- We currently have a concept of the current or global console -(and Director), and I think we must keep this because the tool -bar buttons and menu items can only work with one -Director/console. - -- 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 -for the console, though some color blind people may have -problems. +dhb: +m_topItem has been changed to Console::directorTreeItem() +m_currentConsole->directorTreeItem(); returns disired treeWidgetItem - We also need a concept of a "local" director/console for each page, so the page knows who it is talking to -- this doesn't currently exist, so I think we must pass the director and console to each page widget constructor. + +dhb: +m_currentConsole is saved in each page subclass's m_console. This value +is set by all but the console class calling Pages::pgInitialie() in it's +constructor -- We also must somehow make the low level I/O routines know which -director/console to use. Currently they always use the single -global one defined in the mainWin class (if I remember right). In short, there is a lot of work to be done to make multiple simultaneous directors work. +dhb: +this may be moot: + If the above prooves to be too much, we might consider to only have a single director at a time, and simply let the user select which director he wants to connect to (one at a time, but @@ -47,20 +123,3 @@ dynamically). In the end, this may be the best thing to do, so any user who wishes to connect to multiple directors would run two instances of bat. I am a bit unsure now, but the above list of things to do is much bigger than I thought it was going to be. - -Another idea for what you have implemented: -- I think that the dynamic pages that you create on the fly -should be nested under the item that creates them more like a -directory tree. - -For example: Jobs on Volume xxx, probably should be shown under -"All Jobs" (or Media if that is what created it) and "Jobs of -Client Rufus" probably should be shown under "Clients". I base -this on looking at the Select page list after I have brought up 3 -or 4 dynamic pages. Once there are a good number, I get a bit -confused where they came from. This would also permit selecting -multipe Volumes then displaying multiple pages, one for each -Volume selected. If they are nested, then that nested level can -be expanded or collapsed, which would be pretty cool at keeping -information, but getting it out of the way, sort of like what -happens for a directory tree. diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index 1fca13c053..6d9baac6df 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.cpp @@ -40,13 +40,12 @@ #include "bat.h" #include "clients/clients.h" -Clients::Clients(QStackedWidget *parent, Console *console) +Clients::Clients() { setupUi(this); + pgInitialize(); /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_client.h */ - mp_console = console; - m_parent = parent; m_populated = false; m_checkcurwidget = true; m_closeable = false; @@ -81,7 +80,7 @@ void Clients::populateTree() /* This could be a log item */ //printf("In Clients::populateTree()\n"); - foreach(QString clientName, mp_console->client_list){ + foreach(QString clientName, m_console->client_list){ clientItem = new QTreeWidgetItem(topItem); clientItem->setText(0, clientName); clientItem->setData(0, Qt::UserRole, 1); @@ -97,8 +96,8 @@ void Clients::populateTree() QStringList results; /* This could be a log item */ - //printf("Clients query cmd : %s\n",query.toUtf8().data()); - if (mp_console->sql_cmd(query, results)) { + printf("Clients query cmd : %s\n",query.toUtf8().data()); + if (m_console->sql_cmd(query, results)) { int resultCount = results.count(); if (resultCount == 1){ QString resultline; @@ -188,8 +187,7 @@ void Clients::createContextMenu() void Clients::showJobs() { QString emptymedia(""); - mainWin->createPageJobList(emptymedia, m_currentlyselected, - mainWin->topItem(), mainWin->console()); + mainWin->createPageJobList(emptymedia, m_currentlyselected); } /* @@ -208,3 +206,12 @@ void Clients::currentStackItem() m_populated=true; } } + +/* + * Virtual Function to return the name for the medialist tree widget + */ +void Clients::treeWidgetName(QString &name) +{ + name = "Clients"; +} + diff --git a/bacula/src/qt-console/clients/clients.h b/bacula/src/qt-console/clients/clients.h index 7a7d274de0..12fa98b675 100644 --- a/bacula/src/qt-console/clients/clients.h +++ b/bacula/src/qt-console/clients/clients.h @@ -44,10 +44,11 @@ class Clients : public Pages, public Ui::ClientForm Q_OBJECT public: - Clients(QStackedWidget *parent, Console *console); + Clients(); ~Clients(); virtual void PgSeltreeWidgetClicked(); virtual void currentStackItem(); + void treeWidgetName(QString &); public slots: void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); @@ -58,9 +59,6 @@ private slots: private: void createContextMenu(); - -private: - Console *mp_console; QString m_currentlyselected; bool m_populated; bool m_checkcurwidget; diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 4e431a410a..618d5a7b42 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -43,6 +43,7 @@ Console::Console(QStackedWidget *parent) QFont font; m_parent = parent; m_closeable = false; + m_console = this; (void)parent; setupUi(this); @@ -119,7 +120,8 @@ void Console::connect() /* 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); + QTreeWidgetItem *item = mainWin->getFromHash(this); + item->setForeground(0, greenBrush); } jcr.dir_bsock = m_sock; @@ -417,7 +419,8 @@ void Console::write_dir(const char *msg) mainWin->set_status(" Director not connected. Click on connect button."); mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png"))); QBrush redBrush(Qt::red); - m_consoleItem->setForeground(0, redBrush); + QTreeWidgetItem *item = mainWin->getFromHash(this); + item->setForeground(0, redBrush); m_at_prompt = false; } } @@ -571,7 +574,8 @@ int Console::read() m_sock = NULL; mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png"))); QBrush redBrush(Qt::red); - m_consoleItem->setForeground(0, redBrush); + QTreeWidgetItem *item = mainWin->getFromHash(this); + item->setForeground(0, redBrush); m_notifier->setEnabled(false); delete m_notifier; m_notifier = NULL; @@ -611,9 +615,9 @@ void Console::notify(bool enable) m_notifier->setEnabled(enable); } -void Console::setTreeItem(QTreeWidgetItem *item) +void Console::setDirectorTreeItem(QTreeWidgetItem *item) { - m_consoleItem = item; + m_directorTreeItem = item; } void Console::setDirRes(DIRRES *dir) diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index e3274359f4..fcf02b0316 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -94,8 +94,9 @@ public: void beginNewCommand(); void displayToPrompt(); void discardToPrompt(); - void setTreeItem(QTreeWidgetItem *item); + void setDirectorTreeItem(QTreeWidgetItem *); void setDirRes(DIRRES *dir); + QTreeWidgetItem *directorTreeItem() { return m_directorTreeItem; }; QStringList job_list; QStringList client_list; @@ -124,7 +125,7 @@ private: bool m_at_prompt; QSocketNotifier *m_notifier; QTextCursor *m_cursor; - QTreeWidgetItem *m_consoleItem; + QTreeWidgetItem *m_directorTreeItem; bool m_api_set; bool m_messages_pending; QTimer *m_timer; diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 587d0912f9..06fcc53501 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -40,15 +40,12 @@ /* * Constructor for the class */ -JobList::JobList(QStackedWidget *parent, Console *console, QString &medianame, - QString &clientname) +JobList::JobList(QString &medianame, QString &clientname) { setupUi(this); - /* Store passed variables in member variables */ - mp_console = console; - m_parent = parent; m_medianame = medianame; m_clientname = clientname; + pgInitialize(); m_resultCount = 0; m_populated = false; m_closeable = false; @@ -97,7 +94,7 @@ void JobList::populateTable() /* This could be a user preference debug message?? */ printf("Query cmd : %s\n",query.toUtf8().data()); - if (mp_console->sql_cmd(query, results)) { + if (m_console->sql_cmd(query, results)) { m_resultCount = results.count(); QTableWidgetItem* p_tableitem; @@ -154,3 +151,21 @@ void JobList::currentStackItem() m_populated=true; } } + +/* + * Virtual Function to return the name for the medialist tree widget + */ +void JobList::treeWidgetName(QString &desc) +{ + if ((m_medianame == "") && (m_clientname == "")) { + desc = "All Jobs"; + } else { + desc = "Jobs "; + if (m_medianame != "" ) { + desc += "on Volume " + m_medianame; + } + if (m_clientname != "" ) { + desc += "of Client " + m_clientname; + } + } +} diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index 03b5d128fd..f779dec030 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -43,16 +43,16 @@ class JobList : public Pages, public Ui::JobListForm Q_OBJECT public: - JobList(QStackedWidget *parent, Console *console, QString &medianame, QString &clientname); + JobList(QString &medianame, QString &clientname); virtual void PgSeltreeWidgetClicked(); virtual void currentStackItem(); int m_resultCount; public slots: void populateTable(); + virtual void treeWidgetName(QString &); private: - Console *mp_console; QString m_medianame; QString m_clientname; bool m_populated; diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 4478d2c42d..8ce49cbbe2 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -58,118 +58,91 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) readSettings(); - m_console->connect(); + foreach(Console *console, m_consoleList){ + console->connect(); + } } void MainWin::createPages() { DIRRES *dir; QTreeWidgetItem *item, *topItem; - Console *console; LockRes(); foreach_res(dir, R_DIRECTOR) { /* Create console tree stacked widget item */ - console = new Console(stackedWidget); - console->setDirRes(dir); + m_currentConsole = new Console(stackedWidget); + m_consoleList.append(m_currentConsole); + m_currentConsole->setDirRes(dir); /* The top tree item representing the director */ topItem = createTopPage(dir->name()); topItem->setIcon(0, QIcon(QString::fromUtf8("images/server.png"))); + m_currentConsole->setDirectorTreeItem(topItem); /* Create Tree Widget Item */ item = createPage("Console", topItem); - console->setTreeItem(item); /* insert the cosole and tree widget item into the hashes */ - hashInsert(item, console); + hashInsert(item, m_currentConsole); /* Set Color of treeWidgetItem for the console * It will be set to green in the console class if the connection is made. */ QBrush redBrush(Qt::red); item->setForeground(0, redBrush); - console->dockPage(); + m_currentConsole->dockPage(); /* create instances of the rest of the classes that will by default exist * under each director */ - createPagebRestore(topItem, console); - createPageMediaList(topItem, console); + createPagebRestore(); + createPageMediaList(); QString emptymedia(""), emptyclient(""); - createPageJobList(emptymedia, emptyclient, topItem, console); - createPageClients(topItem, console); + createPageJobList(emptymedia, emptyclient); + createPageClients(); treeWidget->expandItem(topItem); - stackedWidget->setCurrentWidget(console); - - /* - * Set the first console as current console - * - * ***FIXME**** note, to make this work correctly, we need a - * list of consoles, so that we can save/restore the settings - * for all consoles, and we need to figure out some way to - * set the current console and the current topItem (actually Director) - * when a page within a given console is clicked. We also need - * to redo the connections (signals/slots) that use m_console. - */ - if (!m_console) { - m_console = console; - m_topItem = topItem; - } + stackedWidget->setCurrentWidget(m_currentConsole); } UnlockRes(); + m_currentConsole = m_consoleList[0]; + item = getFromHash(m_currentConsole); + treeWidget->setCurrentItem(item); } /* * create an instance of the the brestore class on the stack */ -void MainWin::createPagebRestore(QTreeWidgetItem *parent, Console * /*console*/) +void MainWin::createPagebRestore() { - QTreeWidgetItem *item=createPage("brestore", parent); - bRestore* brestore = new bRestore(stackedWidget); - hashInsert(item, brestore); + bRestore* brestore = new bRestore(); brestore->dockPage(); } /* * create an instance of the the medialist class on the stack */ -void MainWin::createPageMediaList(QTreeWidgetItem *parent, Console *console) +void MainWin::createPageMediaList() { - QTreeWidgetItem *item=createPage("Media", parent); - MediaList* medialist = new MediaList(stackedWidget, console); - hashInsert(item, medialist); + MediaList* medialist = new MediaList(); medialist->dockPage(); } /* * create an instance of the the joblist class on the stack */ -void MainWin::createPageJobList(QString &media, QString &client, - QTreeWidgetItem *parent, Console *console) +void MainWin::createPageJobList(QString &media, QString &client) { QTreeWidgetItem *item, *holdItem; + /* save current tree widget item in case query produces no results */ holdItem = treeWidget->currentItem(); - if ((media == "") && (client == "")) { - item = createPage("All Jobs", parent); - } else { - QString desc("Jobs "); - if (media != "" ) { - desc += "on Volume " + media; - } - if (client != "" ) { - desc += "of Client " + client; - } - item = createPage(desc.toUtf8().data(), parent); - } - JobList* joblist = new JobList(stackedWidget, console, media, client); - hashInsert(item, joblist); + JobList* joblist = new JobList(media, client); joblist->dockPage(); /* If this is a query of jobs on a specific media */ if ((media != "") || (client != "")) { - stackedWidget->setCurrentWidget(joblist); + item = getFromHash(joblist); treeWidget->setCurrentItem(item); /* did query produce results, if not close window and set back to hold */ if (joblist->m_resultCount == 0) { @@ -182,11 +155,9 @@ void MainWin::createPageJobList(QString &media, QString &client, /* * create an instance of the the Clients class on the stack */ -void MainWin::createPageClients(QTreeWidgetItem *parent, Console *console) +void MainWin::createPageClients() { - QTreeWidgetItem *item=createPage("Clients", parent); - Clients* clients = new Clients(stackedWidget, console); - hashInsert(item, clients); + Clients* clients = new Clients(); clients->dockPage(); } @@ -266,9 +237,11 @@ void MainWin::createConnections() this, SLOT(stackItemChanged(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())); - connect(actionSelectFont, SIGNAL(triggered()), m_console, SLOT(set_font())); + 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())); @@ -283,8 +256,10 @@ void MainWin::createConnections() void MainWin::closeEvent(QCloseEvent *event) { writeSettings(); - m_console->writeSettings(); - m_console->terminate(); + foreach(Console *console, m_consoleList){ + console->writeSettings(); + console->terminate(); + } event->accept(); foreach(Pages *page, m_pagehash) { if (!page->isDocked()) @@ -365,7 +340,10 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre /* 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 */ + m_currentConsole = page->console(); int stackindex = stackedWidget->indexOf(page); /* Is this page currently on the stack */ @@ -392,21 +370,19 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre void MainWin::labelDialogClicked() { - new labelDialog(m_console); + new labelDialog(m_currentConsole); } void MainWin::runDialogClicked() { - new runDialog(m_console); + new runDialog(m_currentConsole); } void MainWin::restoreDialogClicked() { - new prerestoreDialog(m_console); + new prerestoreDialog(m_currentConsole); } - - /* * The user just finished typing a line in the command line edit box */ @@ -414,9 +390,9 @@ void MainWin::input_line() { QString cmdStr = lineEdit->text(); /* Get the text */ lineEdit->clear(); /* clear the lineEdit box */ - if (m_console->is_connected()) { - m_console->display_text(cmdStr + "\n"); - m_console->write_dir(cmdStr.toUtf8().data()); /* send to dir */ + if (m_currentConsole->is_connected()) { + m_currentConsole->display_text(cmdStr + "\n"); + m_currentConsole->write_dir(cmdStr.toUtf8().data()); /* send to dir */ } else { set_status("Director not connected. Click on connect button."); } diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index c0cabd3b07..98dbfd0161 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -38,10 +38,10 @@ #include #include -#include "pages.h" #include "ui_main.h" #include "label/label.h" #include "run/run.h" +#include "pages.h" #include "restore/restore.h" #include "medialist/medialist.h" #include "joblist/joblist.h" @@ -68,16 +68,17 @@ public: void hashInsert(QTreeWidgetItem *, Pages *); void hashRemove(Pages *); void hashRemove(QTreeWidgetItem *, Pages *); - QTreeWidgetItem *topItem() { return m_topItem; }; - Console *console() { return m_console; }; + QTreeWidgetItem *currentTopItem() { return m_currentConsole->directorTreeItem(); }; + Console *currentConsole() { return m_currentConsole; }; Pages* getFromHash(QTreeWidgetItem *); QTreeWidgetItem* getFromHash(Pages *); /* This hash is to get the page when the page selector widget is known */ QHash m_pagehash; /* This hash is to get the page selector widget when the page is known */ QHash m_widgethash; - void createPageJobList(QString &, QString &, QTreeWidgetItem *parent, - Console *console); + /* This is a list of consoles */ + QList m_consoleList; + void createPageJobList(QString &, QString &); public slots: void input_line(); @@ -102,13 +103,12 @@ private: void createPages(); QTreeWidgetItem *createTopPage(char *name); QTreeWidgetItem *createPage(char *name, QTreeWidgetItem *parent); - void createPagebRestore(QTreeWidgetItem *parent, Console *console); - void createPageMediaList(QTreeWidgetItem *parent, Console *console); - void createPageClients(QTreeWidgetItem *parent, Console *console); + void createPagebRestore(); + void createPageMediaList(); + void createPageClients(); private: - Console *m_console; - QTreeWidgetItem *m_topItem; + Console *m_currentConsole; Pages *m_pagespophold; QStringList m_cmd_history; int m_cmd_last; diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index ce1a53830b..40085457d1 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -42,13 +42,12 @@ #include "mediaedit/mediaedit.h" #include "joblist/joblist.h" -MediaList::MediaList(QStackedWidget *parent, Console *console) +MediaList::MediaList() { setupUi(this); + pgInitialize(); /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_medialist.h */ - mp_console = console; - m_parent = parent; createConnections(); m_populated = false; m_checkcurwidget = true; @@ -70,11 +69,12 @@ void MediaList::populateTree() QString resultline; QStringList results; const char *query = - "SELECT p.Name,m.VolumeName,m.MediaId,m.VolStatus,m.Enabled,m.VolBytes," - "m.VolFiles,m.VolJobs,m.VolRetention,m.MediaType,m.LastWritten" - " FROM Media m,Pool p" - " WHERE m.PoolId=p.PoolId" - " ORDER BY p.Name"; + "SELECT Pool.Name AS Pool, Media.VolumeName AS Media, Media.MediaId AS Id, Media.VolStatus AS VolStatus," + " Media.Enabled AS Enabled, Media.VolBytes AS Bytes, Media.VolFiles AS FileCount, Media.VolJobs AS JobCount," + " Media.VolRetention AS VolumeRetention, Media.MediaType AS MediaType, Media.LastWritten AS LastWritten" + " FROM Media, Pool" + " WHERE Media.PoolId=Pool.PoolId" + " ORDER BY Pool"; QStringList headerlist = (QStringList() << "Pool Name" << "Volume Name" << "Media Id" << "Volume Status" << "Enabled" << "Volume Bytes" << "Volume Files" << "Volume Jobs" << "Volume Retention" @@ -91,8 +91,9 @@ void MediaList::populateTree() mp_treeWidget->setHeaderLabels(headerlist); + /* FIXME Make this a user configurable loggin action and dont use printf */ //printf("MediaList query cmd : %s\n",query); - if (mp_console->sql_cmd(query, results)) { + if (m_console->sql_cmd(query, results)) { QString field; QStringList fieldlist; @@ -157,7 +158,7 @@ void MediaList::treeItemDoubleClicked(QTreeWidgetItem * /*item*/, int /*column*/ */ void MediaList::editMedia() { - MediaEdit* edit = new MediaEdit(mp_console, m_currentlyselected); + MediaEdit* edit = new MediaEdit(m_console, m_currentlyselected); edit->show(); } @@ -167,8 +168,7 @@ void MediaList::editMedia() void MediaList::showJobs() { QString emptyclient(""); - mainWin->createPageJobList(m_currentlyselected, emptyclient, - mainWin->topItem(), mainWin->console()); + mainWin->createPageJobList(m_currentlyselected, emptyclient); } /* @@ -258,3 +258,11 @@ void MediaList::currentStackItem() m_populated=true; } } + +/* + * Virtual Function to return the name for the medialist tree widget + */ +void MediaList::treeWidgetName(QString &name) +{ + name = "Media"; +} diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index d28b3560e3..0ce75b636e 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -43,7 +43,7 @@ class MediaList : public Pages, public Ui::MediaListForm Q_OBJECT public: - MediaList(QStackedWidget *parent, Console *console); + MediaList(); ~MediaList(); virtual void PgSeltreeWidgetClicked(); virtual void PgSeltreeWidgetDoubleClicked(); @@ -55,6 +55,7 @@ public slots: void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); void editMedia(); void showJobs(); + virtual void treeWidgetName(QString &); private slots: void populateTree(); @@ -64,7 +65,6 @@ private: void createContextMenu(); private: - Console *mp_console; QString m_currentlyselected; bool m_populated; bool m_checkcurwidget; diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 53683dd836..29ad450556 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -176,3 +176,28 @@ void Pages::closeStackPage() /* remove this */ delete this; } + +/* + * Function to set members from the external mainwin + */ +void Pages::pgInitialize() +{ + m_parent = mainWin->stackedWidget; + m_console = mainWin->currentConsole(); + QTreeWidgetItem *parentTreeWidgetItem = m_console->directorTreeItem(); + + QTreeWidgetItem *item = new QTreeWidgetItem(parentTreeWidgetItem); + QString name; + treeWidgetName(name); + item->setText(0, name); + mainWin->hashInsert(item, this); +} + +/* + * Virtual Function to return a name + * All subclasses should override this function + */ +void Pages::treeWidgetName(QString &name) +{ + name = "Default Page Name"; +} diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index 7698344f8d..e5732bc481 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -50,6 +50,8 @@ * populated. */ +class Console; + class Pages : public QWidget { public: @@ -64,14 +66,18 @@ public: virtual void PgSeltreeWidgetDoubleClicked(); virtual void currentStackItem(); void closeStackPage(); + Console *console() { return m_console; }; public slots: /* closeEvent is a virtual function inherited from QWidget */ virtual void closeEvent(QCloseEvent* event); protected: + void pgInitialize(); bool m_closeable; bool m_docked; + virtual void treeWidgetName(QString &); + Console *m_console; }; #endif /* _PAGES_H_ */ diff --git a/bacula/src/qt-console/restore/brestore.cpp b/bacula/src/qt-console/restore/brestore.cpp index 33678e35e5..5636df864c 100644 --- a/bacula/src/qt-console/restore/brestore.cpp +++ b/bacula/src/qt-console/restore/brestore.cpp @@ -38,14 +38,21 @@ #include "bat.h" #include "restore.h" -bRestore::bRestore(QStackedWidget *parent) +bRestore::bRestore() { - m_parent = parent; - m_closeable = true; - (void)parent; setupUi(this); + pgInitialize(); + m_closeable = true; } bRestore::~bRestore() { } + +/* + * Virtual Function to return the name for the medialist tree widget + */ +void bRestore::treeWidgetName(QString &name) +{ + name = "bRestore"; +} diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 4bbe1fcbb1..b07426cc9b 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -97,8 +97,9 @@ class bRestore : public Pages, public Ui::bRestoreForm Q_OBJECT public: - bRestore(QStackedWidget *parent); + bRestore(); ~bRestore(); + virtual void treeWidgetName(QString &); public slots: