From: Dirk H Bartley Date: Sat, 24 Mar 2007 15:14:18 +0000 (+0000) Subject: dhb This may be a way to fix the issues of windows that can X-Git-Tag: Release-7.0.0~6719 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6900a2c8125e2f11434d6f83145615bf631f509f;p=bacula%2Fbacula dhb This may be a way to fix the issues of windows that can be removed from the main window. Not finished yet, but a double click can bring a window out. I think the trigger of double click should change in the near future. The elegance of the changes needs to be improved for future add ons of many stacked windows. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4406 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/bat.pro b/bacula/src/qt-console/bat.pro index f4c77c9b4a..9e9de1a147 100644 --- a/bacula/src/qt-console/bat.pro +++ b/bacula/src/qt-console/bat.pro @@ -48,6 +48,10 @@ SOURCES += run/run.cpp run/runcmd.cpp HEADERS += select/select.h SOURCES += select/select.cpp +## BatStack +HEADERS += batstack.h +SOURCES += batstack.cpp + ## MediaList HEADERS += medialist/medialist.h SOURCES += medialist/medialist.cpp diff --git a/bacula/src/qt-console/batstack.cpp b/bacula/src/qt-console/batstack.cpp new file mode 100644 index 0000000000..d144ea4b32 --- /dev/null +++ b/bacula/src/qt-console/batstack.cpp @@ -0,0 +1,66 @@ +/* + 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 $ + * + * Kern Sibbald, January 2007 + */ + +#include "batstack.h" + +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; +} + +void BatStack::RemoveFromstack() +{ + /* Change from a stacked widget to a normal window */ + /* FIXME Will need to make it so that window cannot be closed */ + m_parent->removeWidget(this); + setWindowFlags(Qt::Window); + showNormal(); + /* Clear stacked flag */ + m_stacked=false; +} + +void BatStack::Togglestack() +{ + if( m_stacked ){ + RemoveFromstack(); + } else { + AddTostack(); + } +} diff --git a/bacula/src/qt-console/batstack.h b/bacula/src/qt-console/batstack.h new file mode 100644 index 0000000000..beb086d469 --- /dev/null +++ b/bacula/src/qt-console/batstack.h @@ -0,0 +1,53 @@ +#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 $ + * + * Kern Sibbald, January 2007 + */ + +#include + +class BatStack : public QWidget +{ +// Q_OBJECT + +public: + void AddTostack(); + void RemoveFromstack(); + void Togglestack(); + QStackedWidget *m_parent; +// BatStack(); + +private: + bool m_stacked; +// int m_PgSelTreeIndex; +}; +#endif /* _BATSTACK_H_ */ diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 4181064220..6b05aab67b 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -41,6 +41,7 @@ Console::Console(QStackedWidget *parent) { QFont font; + m_parent=parent; (void)parent; setupUi(this); diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index e0a94a3d6e..a49ebcd82d 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -37,6 +37,7 @@ #include "ui_console.h" #include "restore.h" #include "select.h" +#include "batstack.h" #ifndef MAX_NAME_LENGTH #define MAX_NAME_LENGTH 128 @@ -64,7 +65,7 @@ class BSOCK; class JCR; class CONRES; -class Console : public QWidget, public Ui::ConsoleForm +class Console : public BatStack, public Ui::ConsoleForm { Q_OBJECT diff --git a/bacula/src/qt-console/main.ui b/bacula/src/qt-console/main.ui index ab91cc5955..f73a128833 100644 --- a/bacula/src/qt-console/main.ui +++ b/bacula/src/qt-console/main.ui @@ -6,7 +6,7 @@ 0 0 - 973 + 882 801 @@ -16,6 +16,15 @@ images/bat.png + + + + + Bacula Administration Tool + + + It's a Dock widget to allow page selection + @@ -43,6 +52,12 @@ Qt::StrongFocus + + + + + + -1 @@ -55,7 +70,7 @@ 0 0 - 973 + 882 28 @@ -146,6 +161,12 @@ Qt::StrongFocus + + + + + + false @@ -201,7 +222,10 @@ Qt::StrongFocus - Selects right panel + Selects panel window + + + Use items in this tree to select what window is in panel true @@ -212,8 +236,23 @@ + + Console Entry + + + Enter a bacula command + + + Cosole Command entry Dock Widget + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable|QDockWidget::NoDockWidgetFeatures + - Qt::BottomDockWidgetArea + Qt::BottomDockWidgetArea|Qt::NoDockWidgetArea|Qt::TopDockWidgetArea + + + Cosole Command Line Entry 8 @@ -242,7 +281,11 @@ - + + + Click here to enter command + + diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index dd67a27466..3009edf102 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -68,13 +68,13 @@ void MainWin::createPages() QTreeWidgetItem *item, *topItem; m_console = new Console(stackedWidget); - stackedWidget->addWidget(m_console); + m_console->AddTostack(); - bRestore *brestore = new bRestore(stackedWidget); - stackedWidget->addWidget(brestore); + m_brestore = new bRestore(stackedWidget); + m_brestore->AddTostack(); m_medialist = new MediaList(stackedWidget, m_console); - stackedWidget->addWidget(m_medialist); + m_medialist->AddTostack(); /* Just take the first Director */ LockRes(); @@ -91,13 +91,14 @@ void MainWin::createPages() item->setForeground(0, redBrush); item = createPage("brestore", topItem, true); - item = createPage("MediaList", topItem, true); + item = createPage("Storage Tree", topItem, true); treeWidget->expandItem(topItem); stackedWidget->setCurrentIndex(0); } +/* Create a root Tree Widget */ QTreeWidgetItem *MainWin::createTopPage(char *name, bool canDisplay) { QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget); @@ -110,6 +111,7 @@ QTreeWidgetItem *MainWin::createTopPage(char *name, bool canDisplay) return item; } +/* Create A Tree Widget Item Representing a Page */ QTreeWidgetItem *MainWin::createPage(char *name, QTreeWidgetItem *parent, bool canDisplay) { QTreeWidgetItem *item = new QTreeWidgetItem(parent); @@ -216,9 +218,21 @@ void MainWin::readSettings() void MainWin::treeItemClicked(QTreeWidgetItem *item, int column) { - int index = item->data(column, Qt::UserRole).toInt(); - if (index >= 0) { - stackedWidget->setCurrentIndex(index); + /* There just has to be a more elegant way of doing this + * as more and more pages get added, this could get realllly long */ + int treeindex = item->data(column, Qt::UserRole).toInt(); + int stackindex=-1; + if( treeindex == 0 ) { + stackindex=stackedWidget->indexOf( m_console ); + } + if( treeindex == 1 ) { + stackindex=stackedWidget->indexOf( m_brestore ); + } + if( treeindex == 2 ) { + stackindex=stackedWidget->indexOf( m_medialist ); + } + if( stackindex >= 0 ){ + stackedWidget->setCurrentIndex(stackindex); } } @@ -226,9 +240,17 @@ void MainWin::treeItemClicked(QTreeWidgetItem *item, int column) */ void MainWin::treeItemDoubleClicked(QTreeWidgetItem *item, int column) { - int index = item->data(column, Qt::UserRole).toInt(); - if (index >= 0) { - stackedWidget->setCurrentIndex(index); + /* There just has to be a more elegant way of doing this + * as more and more pages get added, this could get realllly long */ + int treeindex = item->data(column, Qt::UserRole).toInt(); + if( treeindex == 0 ) { + m_console->Togglestack(); + } + if( treeindex == 1 ) { + m_brestore->Togglestack(); + } + if( treeindex == 2 ) { + m_medialist->Togglestack(); } } diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 371f36a738..e44a54bc42 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -82,6 +82,7 @@ private: private: QString m_UserInput; Console *m_console; + bRestore *m_brestore; MediaList *m_medialist; 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 4a41cfdc42..9189855f00 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -46,13 +46,14 @@ MediaList::MediaList(QStackedWidget *parent, Console *console) { setupUi(this); - parent->addWidget(this); - poollist = new QStringList(); + m_parent=parent; +// AddTostack(); + m_poollist = new QStringList(); m_treeWidget = treeWidget; /* our medialist screen */ m_console = console; createConnections(); - popupmedia=""; + m_popupmedia=""; } void MediaList::populateTree() @@ -69,13 +70,13 @@ void MediaList::populateTree() //topItem->setSizeHint(0,QSize(1050,50)); /* Start with a list of pools */ - poollist->clear(); + m_poollist->clear(); QString *scmd = new QString(".pools\n"); m_console->write_dir(scmd->toUtf8().data()); while ((stat=m_console->read()) > 0) { - poollist->append(m_console->msg()); + m_poollist->append(m_console->msg()); } - for ( QStringList::Iterator poolitem = poollist->begin(); poolitem != poollist->end(); ++poolitem ) { + for ( QStringList::Iterator poolitem = m_poollist->begin(); poolitem != m_poollist->end(); ++poolitem ) { treeitem = new QTreeWidgetItem(topItem); m_console->setTreeItem(treeitem); poolitem->replace(QRegExp("\n"), ""); @@ -145,8 +146,8 @@ void MediaList::treeItemClicked(QTreeWidgetItem *item, int column) case 1: break; case 2: - /* Can't figure out how to make a right button do this her Qt::LeftButton, Qt::RightButton, Qt::MidButton */ - popupmedia = text; + /* 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())); @@ -163,12 +164,12 @@ void MediaList::treeItemDoubleClicked(QTreeWidgetItem *item, int column) void MediaList::editMedia() { - MediaEdit* edit = new MediaEdit(m_console, popupmedia); + MediaEdit* edit = new MediaEdit(m_console, m_popupmedia); edit->show(); } void MediaList::showJobs() { - JobList* joblist = new JobList(m_console, popupmedia); + JobList* joblist = new JobList(m_console, m_popupmedia); joblist->show(); } diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index f8229953c4..73a120b148 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -37,8 +37,9 @@ #include "ui_medialist.h" #include "console.h" #include +#include "batstack.h" -class MediaList : public QWidget, public Ui::MediaListForm +class MediaList : public BatStack, public Ui::MediaListForm { Q_OBJECT @@ -46,7 +47,6 @@ public: MediaList(QStackedWidget *parent,Console *console); void populateTree(); - public slots: void treeItemClicked(QTreeWidgetItem *item, int column); void treeItemDoubleClicked(QTreeWidgetItem *item, int column); @@ -59,8 +59,9 @@ private: private: Console *m_console; QTreeWidget *m_treeWidget; - QStringList *poollist; - QString popupmedia; + QStringList *m_poollist; + QString m_popupmedia; + //QStackedWidget *m_parent; }; #endif /* _MEDIALIST_H_ */ diff --git a/bacula/src/qt-console/restore/brestore.cpp b/bacula/src/qt-console/restore/brestore.cpp index ada44b6eb2..5c339756a2 100644 --- a/bacula/src/qt-console/restore/brestore.cpp +++ b/bacula/src/qt-console/restore/brestore.cpp @@ -42,5 +42,5 @@ bRestore::bRestore(QStackedWidget *parent) { (void)parent; setupUi(this); -// parent->addWidget(this); + m_parent=parent; } diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 499a316d03..a2c585e4b8 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -38,6 +38,7 @@ #include "ui_brestore.h" #include "ui_restore.h" #include "ui_prerestore.h" +#include "batstack.h" class Console; @@ -91,7 +92,7 @@ private: }; -class bRestore : public QWidget, public Ui::bRestoreForm +class bRestore : public BatStack, public Ui::bRestoreForm { Q_OBJECT