From: Kern Sibbald Date: Wed, 28 Mar 2007 17:32:55 +0000 (+0000) Subject: Rename bstack class and functions X-Git-Tag: Release-7.0.0~6680 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d5e6d91442b3de2e59965588ad09c8d70c270aa1;p=bacula%2Fbacula Rename bstack class and functions git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4445 91ce42f0-d328-0410-95d8-f526ca767f89 --- 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/batstack.cpp b/bacula/src/qt-console/batstack.cpp deleted file mode 100644 index 437796d3d0..0000000000 --- a/bacula/src/qt-console/batstack.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2000-2007 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. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark of John Walker. - The licensor of Bacula is the Free Software Foundation Europe - (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, - Switzerland, email:ftf@fsfeurope.org. -*/ -/* - * Version $Id: batstack.cpp 4230 2007-02-21 20:07:37Z kerns $ - * - * Dirk Bartley, March 2007 - */ - -#include "batstack.h" - -/* - * AddTostack - * This function is intended to be called from within the batstack class to pull - * a window from floating to in the stack widget. - */ - -void BatStack::AddTostack() -{ - /* These two lines are for making sure if it is being changed from a window - * that it has the proper window flag and parent. - */ - setWindowFlags(Qt::Widget); - setParent(m_parent); - - /* This was being done already */ - m_parent->addWidget(this); - - /* Set stacked flag */ - m_stacked=true; -} - -/* - * AddTostack - * This function is intended to be called from within the batstack class to put - * a window from the stack widget to a floating window. - */ - -void BatStack::RemoveFromstack() -{ - /* Change from a stacked widget to a normal window */ - m_parent->removeWidget(this); - setWindowFlags(Qt::Window); - showNormal(); - /* Clear stacked flag */ - m_stacked=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 - * it will take it from it's current state of floating or stacked and change it - * to the other. - */ - -void BatStack::Togglestack() -{ - if( m_stacked ){ - RemoveFromstack(); - } else { - AddTostack(); - } -} - -/* - * This function is because I wanted for some reason to keep it private but still - * give any subclasses the ability to find out if it is currently stacked or not. - */ - -bool BatStack::isStacked() -{ - return m_stacked; -} - -/* - * When a window is closed, this slot is called. The idea is to put it back in the - * stack here, and it works. I wanted to get it to the top of the stack so that the - * user immediately sees where his window went. Also, if he floats the window, then - * closes it with the tree item highlighted, it may be confusing that the highlighted - * treewidgetitem is not the stack item in the front. - */ - -void BatStack::closeEvent(QCloseEvent* /*event*/) -{ - /* A Widget was closed, lets toggle it back into the window, and set it in front. */ - AddTostack(); - -#ifdef xxx - /* FIXME Really having problems getting it to the front, - toggles back into the stack fine though */ - int stackindex=m_parent->indexOf( this ); - if( stackindex >= 0 ){ - show(); - m_parent->setCurrentIndex(stackindex); - - } -#endif -} - -/* - * The next two are virtual functions. The idea here is that each subclass will have the - * built in virtual function to override if the programmer wants to populate the window - * when it it is first clicked. - */ -void BatStack::PgSeltreeWidgetClicked(){ -} -void BatStack::PgSeltreeWidgetDoubleClicked(){ -} - -/* - * This function exists because I wanted to have an easy way for new programmers to understand - * exactly what values needed to be set in order to behave correctly in the interface. It can - * be called from the constructor, like with medialist or after being constructed, like with - * Console. - */ -void BatStack::SetPassedValues(QStackedWidget* passedStackedWidget, QTreeWidgetItem* passedTreeItem, int indexseq ) -{ - m_parent = passedStackedWidget; - m_treeItem = passedTreeItem; - m_treeItem->setData(0, Qt::UserRole, QVariant(indexseq)); -} diff --git a/bacula/src/qt-console/batstack.h b/bacula/src/qt-console/batstack.h deleted file mode 100644 index 0885b057b6..0000000000 --- a/bacula/src/qt-console/batstack.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef _BATSTACK_H_ -#define _BATSTACK_H_ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2000-2007 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. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark of John Walker. - The licensor of Bacula is the Free Software Foundation Europe - (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 - -/* - * The BatStack 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 - * in all of the subclasses to accomplish tasks such as pulling a window out - * of or into the stack. It also provides virtual functions placed called - * from in mainwin so that subclasses can contain functions to allow them - * to populate thier screens at the time of first viewing, (when clicked) as - * opposed to the first creation of the console connection. After all the - * console is not actually connected until after the page selector tree has been - * populated. - */ - -class BatStack : public QWidget -{ -public: - void AddTostack(); - void RemoveFromstack(); - void Togglestack(); - bool isStacked(); - QStackedWidget *m_parent; - QTreeWidgetItem *m_treeItem; - void SetPassedValues(QStackedWidget*, QTreeWidgetItem*, int ); - virtual void PgSeltreeWidgetClicked(); - virtual void PgSeltreeWidgetDoubleClicked(); - -public slots: - /* closeEvent is a virtual function inherited from QWidget */ - virtual void closeEvent(QCloseEvent* event); - -private: - bool m_stacked; -}; - -#endif /* _BATSTACK_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/pages.cpp b/bacula/src/qt-console/pages.cpp new file mode 100644 index 0000000000..ccccd12153 --- /dev/null +++ b/bacula/src/qt-console/pages.cpp @@ -0,0 +1,148 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 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. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ +/* + * Version $Id: batstack.cpp 4230 2007-02-21 20:07:37Z kerns $ + * + * Dirk Bartley, March 2007 + */ + +#include "pages.h" + +/* + * 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 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. + */ + setWindowFlags(Qt::Widget); + setParent(m_parent); + + /* This was being done already */ + m_parent->addWidget(this); + + /* Set docked flag */ + m_docked = true; +} + +/* + * 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 Pages::undockPage() +{ + /* Change from a stacked widget to a normal window */ + m_parent->removeWidget(this); + setWindowFlags(Qt::Window); + showNormal(); + /* 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 Pages. It is called + * it will take it from it's current state of floating or stacked and change it + * to the other. + */ + +void Pages::togglePageDocking() +{ + if (m_docked) { + undockPage(); + } else { + dockPage(); + } +} + +/* + * This function is because I wanted for some reason to keep it private but still + * give any subclasses the ability to find out if it is currently stacked or not. + */ + +bool Pages::isDocked() +{ + return m_docked; +} + +/* + * When a window is closed, this slot is called. The idea is to put it back in the + * stack here, and it works. I wanted to get it to the top of the stack so that the + * user immediately sees where his window went. Also, if he floats the window, then + * closes it with the tree item highlighted, it may be confusing that the highlighted + * treewidgetitem is not the stack item in the front. + */ + +void Pages::closeEvent(QCloseEvent* /*event*/) +{ + /* A Widget was closed, lets toggle it back into the window, and set it in front. */ + dockPage(); + +#ifdef xxx + /* FIXME Really having problems getting it to the front, + toggles back into the stack fine though */ + int stackindex=m_parent->indexOf( this ); + if( stackindex >= 0 ){ + show(); + m_parent->setCurrentIndex(stackindex); + + } +#endif +} + +/* + * The next two are virtual functions. The idea here is that each subclass will have the + * built in virtual function to override if the programmer wants to populate the window + * when it it is first clicked. + */ +void Pages::PgSeltreeWidgetClicked() +{ +} + +void Pages::PgSeltreeWidgetDoubleClicked() +{ +} + +/* + * This function exists because I wanted to have an easy way for new programmers to understand + * exactly what values needed to be set in order to behave correctly in the interface. It can + * be called from the constructor, like with medialist or after being constructed, like with + * Console. + */ +void Pages::SetPassedValues(QStackedWidget* passedStackedWidget, QTreeWidgetItem* passedTreeItem, int indexseq ) +{ + m_parent = passedStackedWidget; + m_treeItem = passedTreeItem; + m_treeItem->setData(0, Qt::UserRole, QVariant(indexseq)); +} diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h new file mode 100644 index 0000000000..48d9a18fc0 --- /dev/null +++ b/bacula/src/qt-console/pages.h @@ -0,0 +1,74 @@ +#ifndef _PAGES_H_ +#define _PAGES_H_ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 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. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (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 + +/* + * 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 + * in all of the subclasses to accomplish tasks such as pulling a window out + * of or into the stack. It also provides virtual functions placed called + * from in mainwin so that subclasses can contain functions to allow them + * to populate thier screens at the time of first viewing, (when clicked) as + * opposed to the first creation of the console connection. After all the + * console is not actually connected until after the page selector tree has been + * populated. + */ + +class Pages : public QWidget +{ +public: + void dockPage(); + void undockPage(); + void togglePageDocking(); + bool isDocked(); + QStackedWidget *m_parent; + QTreeWidgetItem *m_treeItem; + void SetPassedValues(QStackedWidget*, QTreeWidgetItem*, int ); + virtual void PgSeltreeWidgetClicked(); + virtual void PgSeltreeWidgetDoubleClicked(); + +public slots: + /* closeEvent is a virtual function inherited from QWidget */ + virtual void closeEvent(QCloseEvent* event); + +private: + bool m_docked; +}; + +#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: