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_treeindex.insert(item, m_console);
+ hashInsert(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_treeindex.insert(item, brestore);
+ hashInsert(item, brestore);
/* lastly for now, the medialist */
item=createPage("Media", topItem );
MediaList* medialist=new MediaList(stackedWidget, m_console);
- m_treeindex.insert(item, medialist);
+ hashInsert(item, medialist);
/* Iterate through and add to the stack */
- foreach(Pages *page, m_treeindex.m_pagehash)
+ foreach(Pages *page, m_pagehash)
page->dockPage();
treeWidget->expandItem(topItem);
m_console->writeSettings();
m_console->terminate();
event->accept();
- foreach(Pages *page, m_treeindex.m_pagehash){
+ foreach(Pages *page, m_pagehash){
if( !page->isDocked() )
page->close();
}
void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
{
/* Is this one of the first level pages */
- if( m_treeindex.value(item) ){
- Pages* page = m_treeindex.value(item);
+ if( getFromHash(item) ){
+ Pages* page = getFromHash(item);
int stackindex=stackedWidget->indexOf(page);
if( stackindex >= 0 ){
if ( previousitem ){
/* Is this one of the first level pages */
- if( m_treeindex.value(previousitem) ){
- Pages* page = m_treeindex.value(previousitem);
+ if( getFromHash(previousitem) ){
+ Pages* page = getFromHash(previousitem);
treeWidget->removeAction(actionToggleDock);
foreach( QAction* pageaction, page->m_contextActions ){
treeWidget->removeAction(pageaction);
}
/* Is this one of the first level pages */
- if( m_treeindex.value(currentitem) ){
- Pages* page = m_treeindex.value(currentitem);
+ if( getFromHash(currentitem) ){
+ Pages* page = getFromHash(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_treeindex.value(currentitem) ){
- Pages* page = m_treeindex.value(currentitem);
+ if( getFromHash(currentitem) ){
+ Pages* page = getFromHash(currentitem);
page->togglePageDocking();
if ( page->isDocked() ){
stackedWidget->setCurrentWidget(page);
QTreeWidgetItem *currentitem = treeWidget->currentItem();
/* Is this one of the first level pages */
- if( m_treeindex.value(currentitem) ){
- Pages* page = m_treeindex.value(currentitem);
+ if( getFromHash(currentitem) ){
+ Pages* page = getFromHash(currentitem);
setContextMenuDockText(page, currentitem);
}
}
*/
void MainWin::setTreeWidgetItemDockColor(Pages* page)
{
- QTreeWidgetItem* item = m_treeindex.value(page);
+ QTreeWidgetItem* item = getFromHash(page);
if( item ){
setTreeWidgetItemDockColor(page, item);
}
/* run the virtual function in case this class overrides it */
page->currentStackItem();
}
+
+/*
+ * Function to simplify insertion of QTreeWidgetItem <-> Page association
+ * into a double direction hash.
+ */
+void MainWin::hashInsert(QTreeWidgetItem *item, Pages *page)
+{
+ m_pagehash.insert(item, page);
+ m_widgethash.insert(page, item);
+}
+
+/*
+ * Function to retrieve a Page* when the item in the page selector's tree is
+ * known.
+ */
+Pages* MainWin::getFromHash(QTreeWidgetItem *item)
+{
+ return m_pagehash.value(item);
+}
+
+/*
+ * Function to retrieve the page selectors tree widget item when the page is
+ * known.
+ */
+QTreeWidgetItem* MainWin::getFromHash(Pages *page)
+{
+ return m_widgethash.value(page);
+}
#include "run/run.h"
#include "restore/restore.h"
#include "medialist/medialist.h"
-#include "pagehash.h"
class Console;
void setContextMenuDockText(Pages *, QTreeWidgetItem *);
void setTreeWidgetItemDockColor(Pages *, QTreeWidgetItem *);
void setTreeWidgetItemDockColor(Pages *);
+ void hashInsert(QTreeWidgetItem *, Pages *);
+ Pages* getFromHash(QTreeWidgetItem *);
+ QTreeWidgetItem* getFromHash(Pages *);
+ /* This hash is to get the page when the page selector widget is known */
+ QHash<QTreeWidgetItem*,Pages*> m_pagehash;
+ /* This hash is to get the page selector widget when the page is known */
+ QHash<Pages*,QTreeWidgetItem*> m_widgethash;
public slots:
void input_line();
private:
Console *m_console;
Pages *m_pagespophold;
- PageHash m_treeindex;
-// QHash<QTreeWidgetItem*,Pages*> m_pagehash;
-// QHash<Pages*,QTreeWidgetItem*> m_widgethash;
QStringList m_cmd_history;
int m_cmd_last;
};
</rect>
</property>
<property name="windowTitle" >
- <string>Console</string>
+ <string>Media Tree</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
+++ /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* value(QTreeWidgetItem *);
- QTreeWidgetItem* value(Pages *);
- QHash<QTreeWidgetItem*,Pages*> m_pagehash;
- QHash<Pages*,QTreeWidgetItem*> m_widgethash;
-};
-
-#endif /* _PAGEHASH_H_ */