HEADERS += pages.h
SOURCES += pages.cpp
+## PageHash
+HEADERS += pagehash.h
+SOURCES += pagehash.cpp
+
## MediaList
HEADERS += medialist/medialist.h
SOURCES += medialist/medialist.cpp
*/
#include "bat.h"
+#include "pagehash.h"
MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
{
m_console->setTreeItem(item);
/* Append to pagelist */
- m_pagehash.insert(item, m_console);
- m_widgethash.insert(m_console, item);
+ m_treeindex.insert(item, m_console);
/* Set Color of treeWidgetItem for the console
* It will be set to gree in the console class if the connection is made.
/* brestore */
item=createPage("brestore", topItem);
bRestore* brestore=new bRestore(stackedWidget);
- m_pagehash.insert(item, brestore);
- m_widgethash.insert(brestore, item);
+ m_treeindex.insert(item, brestore);
/* lastly for now, the medialist */
item=createPage("Media", topItem );
MediaList* medialist=new MediaList(stackedWidget, m_console);
- m_pagehash.insert(item, medialist);
- m_widgethash.insert(medialist, item);
+ m_treeindex.insert(item, medialist);
/* Iterate through and add to the stack */
- foreach(Pages *page, m_pagehash)
+ foreach(Pages *page, m_treeindex.m_pagehash)
page->dockPage();
treeWidget->expandItem(topItem);
m_console->writeSettings();
m_console->terminate();
event->accept();
- foreach(Pages *page, m_pagehash){
+ foreach(Pages *page, m_treeindex.m_pagehash){
if( !page->isDocked() )
page->close();
}
void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
{
/* Is this one of the first level pages */
- if( m_pagehash.value(item) ){
- Pages* page = m_pagehash.value(item);
+ if( m_treeindex.value(item) ){
+ Pages* page = m_treeindex.value(item);
int stackindex=stackedWidget->indexOf(page);
if( stackindex >= 0 ){
if ( previousitem ){
/* Is this one of the first level pages */
- if( m_pagehash.value(previousitem) ){
- Pages* page = m_pagehash.value(previousitem);
+ if( m_treeindex.value(previousitem) ){
+ Pages* page = m_treeindex.value(previousitem);
treeWidget->removeAction(actionToggleDock);
foreach( QAction* pageaction, page->m_contextActions ){
treeWidget->removeAction(pageaction);
}
/* Is this one of the first level pages */
- if( m_pagehash.value(currentitem) ){
- Pages* page = m_pagehash.value(currentitem);
+ if( m_treeindex.value(currentitem) ){
+ Pages* page = m_treeindex.value(currentitem);
int stackindex = stackedWidget->indexOf(page);
/* Is this page currently on the stack */
QTreeWidgetItem *currentitem = treeWidget->currentItem();
/* Is this one of the first level pages */
- if( m_pagehash.value(currentitem) ){
- Pages* page = m_pagehash.value(currentitem);
+ if( m_treeindex.value(currentitem) ){
+ Pages* page = m_treeindex.value(currentitem);
page->togglePageDocking();
if ( page->isDocked() ){
stackedWidget->setCurrentWidget(page);
QTreeWidgetItem *currentitem = treeWidget->currentItem();
/* Is this one of the first level pages */
- if( m_pagehash.value(currentitem) ){
- Pages* page = m_pagehash.value(currentitem);
+ if( m_treeindex.value(currentitem) ){
+ Pages* page = m_treeindex.value(currentitem);
setContextMenuDockText(page, currentitem);
}
}
* Function to set the text of the toggle dock context menu when page and
* widget item are known. This is the more commonly used.
*/
-void MainWin::setContextMenuDockText( Pages* page, QTreeWidgetItem* item )
+void MainWin::setContextMenuDockText(Pages* page, QTreeWidgetItem* item)
{
QString docktext("");
if( page->isDocked() ){
* Function to set the color of the tree widget item based on whether it is
* docked or not.
*/
-void MainWin::setTreeWidgetItemDockColor( Pages* page, QTreeWidgetItem* item )
+void MainWin::setTreeWidgetItemDockColor(Pages* page, QTreeWidgetItem* item)
{
if( item->text(0) != "Console" ){
if( page->isDocked() ){
}
}
+/*
+ * Overload of previous function, use treeindex to get item from page
+ * This is called when an undocked window is closed.
+ */
+void MainWin::setTreeWidgetItemDockColor(Pages* page)
+{
+ QTreeWidgetItem* item = m_treeindex.value(page);
+ if( item ){
+ setTreeWidgetItemDockColor(page, item);
+ }
+}
+
+/*
+ * This function is called when the stack item is changed. Call
+ * the virtual function here. Avoids a window being undocked leaving
+ * a window at the top of the stack unpopulated.
+ */
void MainWin::stackItemChanged(int)
{
Pages* page = (Pages*)stackedWidget->currentWidget();
#include "run/run.h"
#include "restore/restore.h"
#include "medialist/medialist.h"
+#include "pagehash.h"
class Console;
void setContextMenuDockText();
void setContextMenuDockText(Pages *, QTreeWidgetItem *);
void setTreeWidgetItemDockColor(Pages *, QTreeWidgetItem *);
+ void setTreeWidgetItemDockColor(Pages *);
public slots:
void input_line();
private:
Console *m_console;
Pages *m_pagespophold;
- QHash<QTreeWidgetItem*,Pages*> m_pagehash;
- QHash<Pages*,QTreeWidgetItem*> m_widgethash;
+ PageHash m_treeindex;
+// QHash<QTreeWidgetItem*,Pages*> m_pagehash;
+// QHash<Pages*,QTreeWidgetItem*> m_widgethash;
QStringList m_cmd_history;
int m_cmd_last;
};
--- /dev/null
+/*
+ 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 "pagehash.h"
+
+PageHash::PageHash()
+{
+}
+
+void PageHash::insert(QTreeWidgetItem *item, Pages *page)
+{
+ m_pagehash.insert(item, page);
+ m_widgethash.insert(page, item);
+}
+
+Pages* PageHash::value(QTreeWidgetItem *item)
+{
+ return m_pagehash.value(item);
+}
+
+QTreeWidgetItem* PageHash::value(Pages *page)
+{
+ return m_widgethash.value(page);
+}
--- /dev/null
+#ifndef _PAGEHASH_H_
+#define _PAGEHASH_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 <QtGui>
+#include <QHash>
+#include "pages.h"
+
+/*
+ * The Page Hash Class
+ */
+
+class PageHash
+{
+public:
+ PageHash();
+ void insert(QTreeWidgetItem *, Pages *);
+ Pages* PageHash::value(QTreeWidgetItem *);
+ QTreeWidgetItem* PageHash::value(Pages *);
+ QHash<QTreeWidgetItem*,Pages*> m_pagehash;
+ QHash<Pages*,QTreeWidgetItem*> m_widgethash;
+};
+
+#endif /* _PAGEHASH_H_ */
{
/* A Widget was closed, lets toggle it back into the window, and set it in front. */
dockPage();
+ /* in case the current widget is the one which represents this, lets set the context
+ * menu to undock */
mainWin->setContextMenuDockText();
-// setTreeWidgetItemDockColor(page, item);
-// foreach(Pages *page, m_pagehash){
-// if
-// }
+ /* in case the current widget is not the one which represents this, lets set the
+ * color back to black */
+ mainWin->setTreeWidgetItemDockColor(this);
#ifdef xxx
/* FIXME Really having problems getting it to the front,