From d5e6d91442b3de2e59965588ad09c8d70c270aa1 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 28 Mar 2007 17:32:55 +0000 Subject: [PATCH] Rename bstack class and functions git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4445 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/bat.pro | 6 +- bacula/src/qt-console/console/console.cpp | 3 + bacula/src/qt-console/console/console.h | 5 +- bacula/src/qt-console/joblist/joblist.cpp | 7 ++- bacula/src/qt-console/joblist/joblist.h | 3 +- bacula/src/qt-console/mainwin.cpp | 52 ++++++++--------- bacula/src/qt-console/mainwin.h | 11 ++-- bacula/src/qt-console/mediaedit/mediaedit.cpp | 7 ++- bacula/src/qt-console/mediaedit/mediaedit.h | 5 ++ bacula/src/qt-console/medialist/medialist.cpp | 56 +++++++++---------- bacula/src/qt-console/medialist/medialist.h | 5 +- .../qt-console/{batstack.cpp => pages.cpp} | 49 ++++++++-------- bacula/src/qt-console/{batstack.h => pages.h} | 20 +++---- bacula/src/qt-console/restore/brestore.cpp | 4 ++ bacula/src/qt-console/restore/restore.h | 5 +- 15 files changed, 132 insertions(+), 106 deletions(-) rename bacula/src/qt-console/{batstack.cpp => pages.cpp} (80%) rename bacula/src/qt-console/{batstack.h => pages.h} (90%) diff --git a/bacula/src/qt-console/bat.pro b/bacula/src/qt-console/bat.pro index 9e9de1a147..df4c673183 100644 --- a/bacula/src/qt-console/bat.pro +++ b/bacula/src/qt-console/bat.pro @@ -48,9 +48,9 @@ SOURCES += run/run.cpp run/runcmd.cpp HEADERS += select/select.h SOURCES += select/select.cpp -## BatStack -HEADERS += batstack.h -SOURCES += batstack.cpp +## Pages +HEADERS += pages.h +SOURCES += pages.cpp ## MediaList HEADERS += medialist/medialist.h diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index d161f25dde..90d5fe1469 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -56,7 +56,10 @@ Console::Console(QStackedWidget *parent) // m_timer = new QTimer(this); // QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(poll_messages())); // m_timer->start(5000); +} +Console::~Console() +{ } void Console::poll_messages() diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index c434d9064b..9faaba4d79 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -34,10 +34,10 @@ */ #include +#include "pages.h" #include "ui_console.h" #include "restore.h" #include "select.h" -#include "batstack.h" #ifndef MAX_NAME_LENGTH #define MAX_NAME_LENGTH 128 @@ -65,12 +65,13 @@ class BSOCK; class JCR; class CONRES; -class Console : public BatStack, public Ui::ConsoleForm +class Console : public Pages, public Ui::ConsoleForm { Q_OBJECT public: Console(QStackedWidget *parent); + ~Console(); void display_text(const char *buf); void display_text(const QString buf); void display_textf(const char *fmt, ...); diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 15c8a5bbea..fab223fd01 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -25,11 +25,16 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Version $Id: joblist.h 4230 2007-02-21 20:07:37Z kerns $ + * + * Dirk Bartley, March 2007 + */ #include +#include #include "bat.h" #include "joblist.h" -#include JobList::JobList(Console *console, QString &medianame) { diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index 23f8fe4aea..cddee16de3 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -30,13 +30,12 @@ /* * Version $Id: joblist.h 4230 2007-02-21 20:07:37Z kerns $ * - * Kern Sibbald, January 2007 + * Dirk Bartley, March 2007 */ #include #include "ui_joblist.h" #include "console.h" -#include "batstack.h" class JobList : public QWidget, public Ui::JobListForm { diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 46551b987e..9390850fdf 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -36,7 +36,6 @@ */ #include "bat.h" -#include "medialist/medialist.h" MainWin::MainWin(QWidget *parent) : QMainWindow(parent) { @@ -86,8 +85,8 @@ void MainWin::createPages() item = createPage("Console", topItem); m_console->SetPassedValues(stackedWidget, item, m_pages++ ); - /* Append to bstacklist */ - m_bstacklist.append(m_console); + /* Append to pageslist */ + m_pageslist.append(m_console); /* Set BatStack m_treeItem */ QBrush redBrush(Qt::red); @@ -103,17 +102,18 @@ void MainWin::createPages() */ /* brestore */ - m_bstacklist.append(new bRestore(stackedWidget, - createPage("brestore", topItem), m_pages++ )); + m_pageslist.append(new bRestore(stackedWidget, + createPage("brestore", topItem), m_pages++ )); + /* lastly for now, the medialist */ - m_bstacklist.append(new MediaList(stackedWidget, m_console, + m_pageslist.append(new MediaList(stackedWidget, m_console, createPage("Storage Tree", topItem ), m_pages++)); /* Iterate through and add to the stack */ - for (QList::iterator bstackItem = m_bstacklist.begin(); - bstackItem != m_bstacklist.end(); ++bstackItem ) { - (*bstackItem)->AddTostack(); + for (QList::iterator pagesItem = m_pageslist.begin(); + pagesItem != m_pageslist.end(); ++pagesItem ) { + (*pagesItem)->dockPage(); } treeWidget->expandItem(topItem); @@ -196,7 +196,7 @@ void MainWin::createConnections() connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelDialogClicked())); connect(actionRun, SIGNAL(triggered()), this, SLOT(runDialogClicked())); connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreDialogClicked())); - connect(actionPullWindowOut, SIGNAL(triggered()), this, SLOT(floatWindowButton())); + connect(actionPullWindowOut, SIGNAL(triggered()), this, SLOT(undockWindowButton())); } /* @@ -238,13 +238,13 @@ void MainWin::treeItemClicked(QTreeWidgetItem *item, int column) { /* Use tree item's Qt::UserRole to get treeindex */ int treeindex = item->data(column, Qt::UserRole).toInt(); - int stackindex=stackedWidget->indexOf(m_bstacklist[treeindex]); + int stackindex=stackedWidget->indexOf(m_pageslist[treeindex]); if( stackindex >= 0 ){ stackedWidget->setCurrentIndex(stackindex); } /* run the virtual function in case this class overrides it */ - m_bstacklist[treeindex]->PgSeltreeWidgetClicked(); + m_pageslist[treeindex]->PgSeltreeWidgetClicked(); } /* @@ -256,20 +256,20 @@ void MainWin::treeItemDoubleClicked(QTreeWidgetItem *item, int column) int treeindex = item->data(column, Qt::UserRole).toInt(); /* Use tree item's Qt::UserRole to get treeindex */ - if ( m_bstacklist[treeindex]->isStacked() == true ){ - m_bstackpophold=m_bstacklist[treeindex]; + if (m_pageslist[treeindex]->isDocked()) { + m_pagespophold = m_pageslist[treeindex]; /* Create a popup menu before floating window */ QMenu *popup = new QMenu( treeWidget ); - connect(popup->addAction("Float Window"), SIGNAL(triggered()), this, - SLOT(floatWindow())); + connect(popup->addAction("Undock Window"), SIGNAL(triggered()), this, + SLOT(undockWindow())); popup->exec(QCursor::pos()); } else { /* Just pull it back in without prompting */ - m_bstacklist[treeindex]->Togglestack(); + m_pageslist[treeindex]->togglePageDocking(); } /* Here is the virtual function so that different classes can do different things */ - m_bstacklist[treeindex]->PgSeltreeWidgetDoubleClicked(); + m_pageslist[treeindex]->PgSeltreeWidgetDoubleClicked(); } void MainWin::labelDialogClicked() @@ -337,21 +337,21 @@ void MainWin::set_status(const char *buf) statusBar()->showMessage(buf); } -void MainWin::floatWindow() +void MainWin::undockWindow() { - m_bstackpophold->Togglestack(); + m_pagespophold->togglePageDocking(); } -void MainWin::floatWindowButton() +void MainWin::undockWindowButton() { int curindex = stackedWidget->currentIndex(); - QList::iterator bstackItem = m_bstacklist.begin(); + QList::iterator pagesItem = m_pageslist.begin(); - while ((bstackItem != m_bstacklist.end())){ - if (curindex == stackedWidget->indexOf(*bstackItem)) { - (*bstackItem)->Togglestack(); + while ((pagesItem != m_pageslist.end())){ + if (curindex == stackedWidget->indexOf(*pagesItem)) { + (*pagesItem)->togglePageDocking(); break; } - ++bstackItem; + ++pagesItem; } } diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 322a7508ee..1f0a900e02 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -39,6 +39,7 @@ #include #include +#include "pages.h" #include "ui_main.h" #include "label/label.h" #include "run/run.h" @@ -69,8 +70,8 @@ public slots: void labelDialogClicked(); void runDialogClicked(); void restoreDialogClicked(); - void floatWindow(); - void floatWindowButton(); + void undockWindow(); + void undockWindowButton(); protected: void closeEvent(QCloseEvent *event); @@ -84,9 +85,9 @@ private: private: Console *m_console; - BatStack *m_bstackpophold; - QList m_bstacklist; - QList m_bstackindex; + Pages *m_pagespophold; + QList m_pageslist; + QList m_pagesindex; QStringList m_cmd_history; int m_cmd_last; int m_pages; diff --git a/bacula/src/qt-console/mediaedit/mediaedit.cpp b/bacula/src/qt-console/mediaedit/mediaedit.cpp index 3519660487..9a3eebb1b0 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.cpp +++ b/bacula/src/qt-console/mediaedit/mediaedit.cpp @@ -25,11 +25,16 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Version $Id: batstack.h 4230 2007-02-21 20:07:37Z kerns $ + * + * Dirk Bartley, March 2007 + */ #include +#include #include "bat.h" #include "mediaedit.h" -#include MediaEdit::MediaEdit(Console *console, QString &medianame) { diff --git a/bacula/src/qt-console/mediaedit/mediaedit.h b/bacula/src/qt-console/mediaedit/mediaedit.h index ed4f4c481d..ad6906c4f4 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.h +++ b/bacula/src/qt-console/mediaedit/mediaedit.h @@ -27,6 +27,11 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Version $Id: batstack.h 4230 2007-02-21 20:07:37Z kerns $ + * + * Dirk Bartley, March 2007 + */ #include #include "ui_mediaedit.h" diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index a58fc5385d..592da0525d 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -31,16 +31,16 @@ * * MediaList Class * - * Kern Sibbald, January MMVI + * Dirk Bartley, March 2007 * */ #include +#include #include "bat.h" #include "medialist.h" #include "mediaedit/mediaedit.h" #include "joblist/joblist.h" -#include MediaList::MediaList(QStackedWidget *parent, Console *console, QTreeWidgetItem *treeItem, int indexseq) { @@ -100,24 +100,24 @@ void MediaList::populateTree() int recorditemcnter=0; /* Iterate through items in the record */ QString mediarecorditem; - foreach( mediarecorditem, recorditemlist ){ - QString trimmeditem = mediarecorditem.trimmed(); - if( trimmeditem != "" ){ - if ( recorditemcnter == 0 ){ - if ( currentpool != trimmeditem.toUtf8().data() ){ - currentpool = trimmeditem.toUtf8().data(); - pooltreeitem = new QTreeWidgetItem(topItem); - pooltreeitem->setText(0, trimmeditem.toUtf8().data()); - pooltreeitem->setData(0, Qt::UserRole, 1); - pooltreeitem->setExpanded( true ); - } - mediatreeitem = new QTreeWidgetItem(pooltreeitem); - } else { - mediatreeitem->setData(recorditemcnter-1, Qt::UserRole, 2); - mediatreeitem->setText(recorditemcnter-1, trimmeditem.toUtf8().data()); + foreach( mediarecorditem, recorditemlist ){ + QString trimmeditem = mediarecorditem.trimmed(); + if( trimmeditem != "" ){ + if ( recorditemcnter == 0 ){ + if ( currentpool != trimmeditem.toUtf8().data() ){ + currentpool = trimmeditem.toUtf8().data(); + pooltreeitem = new QTreeWidgetItem(topItem); + pooltreeitem->setText(0, trimmeditem.toUtf8().data()); + pooltreeitem->setData(0, Qt::UserRole, 1); + pooltreeitem->setExpanded( true ); + } + mediatreeitem = new QTreeWidgetItem(pooltreeitem); + } else { + mediatreeitem->setData(recorditemcnter-1, Qt::UserRole, 2); + mediatreeitem->setText(recorditemcnter-1, trimmeditem.toUtf8().data()); } - recorditemcnter+=1; - } + recorditemcnter+=1; + } } recordcounter+=1; } @@ -126,9 +126,9 @@ void MediaList::populateTree() void MediaList::createConnections() { connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this, - SLOT(treeItemClicked(QTreeWidgetItem *, int))); + SLOT(treeItemClicked(QTreeWidgetItem *, int))); connect(treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, - SLOT(treeItemDoubleClicked(QTreeWidgetItem *, int))); + SLOT(treeItemDoubleClicked(QTreeWidgetItem *, int))); } void MediaList::treeItemClicked(QTreeWidgetItem *item, int column) @@ -137,14 +137,14 @@ void MediaList::treeItemClicked(QTreeWidgetItem *item, int column) QString text = item->text(0); switch (treedepth){ case 1: - break; + break; case 2: - /* Can't figure out how to make a right button do this --- Qt::LeftButton, Qt::RightButton, Qt::MidButton */ - *m_popupmedia = text; - QMenu *popup = new QMenu( m_treeWidget ); - connect(popup->addAction("Edit Properties"), SIGNAL(triggered()), this, SLOT(editMedia())); - connect(popup->addAction("Show Jobs On Media"), SIGNAL(triggered()), this, SLOT(showJobs())); - popup->exec(QCursor::pos()); + /* Can't figure out how to make a right button do this --- Qt::LeftButton, Qt::RightButton, Qt::MidButton */ + *m_popupmedia = text; + QMenu *popup = new QMenu( m_treeWidget ); + connect(popup->addAction("Edit Properties"), SIGNAL(triggered()), this, SLOT(editMedia())); + connect(popup->addAction("Show Jobs On Media"), SIGNAL(triggered()), this, SLOT(showJobs())); + popup->exec(QCursor::pos()); } } diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index 1e07e3dae8..b9d09d55d7 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -30,16 +30,15 @@ /* * Version $Id: medialist.h 4230 2007-02-21 20:07:37Z kerns $ * - * Kern Sibbald, January 2007 + * Dirk Bentley, March 2007 */ #include #include "ui_medialist.h" #include "console.h" #include -#include "batstack.h" -class MediaList : public BatStack, public Ui::MediaListForm +class MediaList : public Pages, public Ui::MediaListForm { Q_OBJECT diff --git a/bacula/src/qt-console/batstack.cpp b/bacula/src/qt-console/pages.cpp similarity index 80% rename from bacula/src/qt-console/batstack.cpp rename to bacula/src/qt-console/pages.cpp index 437796d3d0..ccccd12153 100644 --- a/bacula/src/qt-console/batstack.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -31,15 +31,15 @@ * Dirk Bartley, March 2007 */ -#include "batstack.h" +#include "pages.h" /* - * AddTostack - * This function is intended to be called from within the batstack class to pull + * dockPage + * This function is intended to be called from within the Pages class to pull * a window from floating to in the stack widget. */ -void BatStack::AddTostack() +void Pages::dockPage() { /* These two lines are for making sure if it is being changed from a window * that it has the proper window flag and parent. @@ -50,39 +50,39 @@ void BatStack::AddTostack() /* This was being done already */ m_parent->addWidget(this); - /* Set stacked flag */ - m_stacked=true; + /* Set docked flag */ + m_docked = true; } /* - * AddTostack - * This function is intended to be called from within the batstack class to put + * undockPage + * This function is intended to be called from within the Pages class to put * a window from the stack widget to a floating window. */ -void BatStack::RemoveFromstack() +void Pages::undockPage() { /* Change from a stacked widget to a normal window */ m_parent->removeWidget(this); setWindowFlags(Qt::Window); showNormal(); - /* Clear stacked flag */ - m_stacked=false; + /* Clear docked flag */ + m_docked = false; } /* * This function is intended to be called with the subclasses. When it is called - * the specific sublclass does not have to be known to BatStack. It is called + * the specific sublclass does not have to be known to Pages. It is called * it will take it from it's current state of floating or stacked and change it * to the other. */ -void BatStack::Togglestack() +void Pages::togglePageDocking() { - if( m_stacked ){ - RemoveFromstack(); + if (m_docked) { + undockPage(); } else { - AddTostack(); + dockPage(); } } @@ -91,9 +91,9 @@ void BatStack::Togglestack() * give any subclasses the ability to find out if it is currently stacked or not. */ -bool BatStack::isStacked() +bool Pages::isDocked() { - return m_stacked; + return m_docked; } /* @@ -104,10 +104,10 @@ bool BatStack::isStacked() * treewidgetitem is not the stack item in the front. */ -void BatStack::closeEvent(QCloseEvent* /*event*/) +void Pages::closeEvent(QCloseEvent* /*event*/) { /* A Widget was closed, lets toggle it back into the window, and set it in front. */ - AddTostack(); + dockPage(); #ifdef xxx /* FIXME Really having problems getting it to the front, @@ -126,9 +126,12 @@ void BatStack::closeEvent(QCloseEvent* /*event*/) * built in virtual function to override if the programmer wants to populate the window * when it it is first clicked. */ -void BatStack::PgSeltreeWidgetClicked(){ +void Pages::PgSeltreeWidgetClicked() +{ } -void BatStack::PgSeltreeWidgetDoubleClicked(){ + +void Pages::PgSeltreeWidgetDoubleClicked() +{ } /* @@ -137,7 +140,7 @@ void BatStack::PgSeltreeWidgetDoubleClicked(){ * be called from the constructor, like with medialist or after being constructed, like with * Console. */ -void BatStack::SetPassedValues(QStackedWidget* passedStackedWidget, QTreeWidgetItem* passedTreeItem, int indexseq ) +void Pages::SetPassedValues(QStackedWidget* passedStackedWidget, QTreeWidgetItem* passedTreeItem, int indexseq ) { m_parent = passedStackedWidget; m_treeItem = passedTreeItem; diff --git a/bacula/src/qt-console/batstack.h b/bacula/src/qt-console/pages.h similarity index 90% rename from bacula/src/qt-console/batstack.h rename to bacula/src/qt-console/pages.h index 0885b057b6..48d9a18fc0 100644 --- a/bacula/src/qt-console/batstack.h +++ b/bacula/src/qt-console/pages.h @@ -1,5 +1,5 @@ -#ifndef _BATSTACK_H_ -#define _BATSTACK_H_ +#ifndef _PAGES_H_ +#define _PAGES_H_ /* Bacula® - The Network Backup Solution @@ -37,7 +37,7 @@ #include /* - * The BatStack Class + * The Pages Class * * This class is inherited by all widget windows which are on the stack * It is for the purpos of having a conistant set of functions and properties @@ -50,13 +50,13 @@ * populated. */ -class BatStack : public QWidget +class Pages : public QWidget { public: - void AddTostack(); - void RemoveFromstack(); - void Togglestack(); - bool isStacked(); + void dockPage(); + void undockPage(); + void togglePageDocking(); + bool isDocked(); QStackedWidget *m_parent; QTreeWidgetItem *m_treeItem; void SetPassedValues(QStackedWidget*, QTreeWidgetItem*, int ); @@ -68,7 +68,7 @@ public slots: virtual void closeEvent(QCloseEvent* event); private: - bool m_stacked; + bool m_docked; }; -#endif /* _BATSTACK_H_ */ +#endif /* _PAGES_H_ */ diff --git a/bacula/src/qt-console/restore/brestore.cpp b/bacula/src/qt-console/restore/brestore.cpp index d2ca3e95a1..bfe4fdc210 100644 --- a/bacula/src/qt-console/restore/brestore.cpp +++ b/bacula/src/qt-console/restore/brestore.cpp @@ -44,3 +44,7 @@ bRestore::bRestore(QStackedWidget *parent, QTreeWidgetItem *treeItem, int indexs (void)parent; setupUi(this); } + +bRestore::~bRestore() +{ +} diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 2b67940a15..5822ee2494 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -35,10 +35,10 @@ */ #include +#include "pages.h" #include "ui_brestore.h" #include "ui_restore.h" #include "ui_prerestore.h" -#include "batstack.h" class Console; @@ -92,12 +92,13 @@ private: }; -class bRestore : public BatStack, public Ui::bRestoreForm +class bRestore : public Pages, public Ui::bRestoreForm { Q_OBJECT public: bRestore(QStackedWidget *parent, QTreeWidgetItem *treeItem, int indexseq); + ~bRestore(); public slots: -- 2.39.5