]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/pages.cpp
dhb Create a class to be a two way hash. This way it is easy to insert a
[bacula/bacula] / bacula / src / qt-console / pages.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation plus additions
11    that are listed in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of John Walker.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  *   Version $Id: batstack.cpp 4230 2007-02-21 20:07:37Z kerns $
30  *
31  *   Dirk Bartley, March 2007
32  */
33
34 #include "pages.h"
35 #include "bat.h"
36
37 /*
38  * dockPage
39  * This function is intended to be called from within the Pages class to pull
40  * a window from floating to in the stack widget.
41  */
42
43 void Pages::dockPage()
44 {
45    /* These two lines are for making sure if it is being changed from a window
46     * that it has the proper window flag and parent.
47     */
48    setWindowFlags(Qt::Widget);
49    setParent(m_parent);
50
51    /* This was being done already */
52    m_parent->addWidget(this);
53
54    /* Set docked flag */
55    m_docked = true;
56 }
57
58 /*
59  * undockPage
60  * This function is intended to be called from within the Pages class to put
61  * a window from the stack widget to a floating window.
62  */
63
64 void Pages::undockPage()
65 {
66    /* Change from a stacked widget to a normal window */
67    m_parent->removeWidget(this);
68    setWindowFlags(Qt::Window);
69    show();
70    /* Clear docked flag */
71    m_docked = false;
72 }
73
74 /*
75  * This function is intended to be called with the subclasses.  When it is called
76  * the specific sublclass does not have to be known to Pages.  It is called 
77  * it will take it from it's current state of floating or stacked and change it
78  * to the other.
79  */
80
81 void Pages::togglePageDocking()
82 {
83    if (m_docked) {
84       undockPage();
85    } else {
86       dockPage();
87    }
88 }
89
90 /*
91  * This function is because I wanted for some reason to keep it private but still 
92  * give any subclasses the ability to find out if it is currently stacked or not.
93  */
94
95 bool Pages::isDocked()
96 {
97    return m_docked;
98 }
99
100 /*
101  * When a window is closed, this slot is called.  The idea is to put it back in the
102  * stack here, and it works.  I wanted to get it to the top of the stack so that the
103  * user immediately sees where his window went.  Also, if he undocks the window, then
104  * closes it with the tree item highlighted, it may be confusing that the highlighted
105  * treewidgetitem is not the stack item in the front.
106  */
107
108 void Pages::closeEvent(QCloseEvent* /*event*/)
109 {
110    /* A Widget was closed, lets toggle it back into the window, and set it in front. */
111    dockPage();
112    /* in case the current widget is the one which represents this, lets set the context
113     * menu to undock */
114    mainWin->setContextMenuDockText();
115    /* in case the current widget is not the one which represents this, lets set the
116     * color back to black */
117    mainWin->setTreeWidgetItemDockColor(this);
118
119 #ifdef xxx
120    /* FIXME Really having problems getting it to the front, 
121       toggles back into the stack fine though */
122    int stackindex=m_parent->indexOf( this );
123 printf("In Pages closeEvent a\n");
124    if( stackindex >= 0 ){
125 printf("In Pages closeEvent b\n");
126       m_parent->setCurrentIndex(0);
127       m_parent->setCurrentWidget(this);
128       show();
129       //m_parent->setCurrentIndex(stackindex);
130 //      m_parent->setCurrentWidget(this);
131 /*      m_parent->update();
132       update();
133       setUpdatesEnabled(true);
134       setVisible(true);
135       m_parent->show();
136       show();
137       m_parent->repaint();*/
138       repaint();
139       raise();
140    }
141 #endif
142 }
143
144 /*
145  * The next three are virtual functions.  The idea here is that each subclass will have the
146  * built in virtual function to override if the programmer wants to populate the window
147  * when it it is first clicked.
148  */
149 void Pages::PgSeltreeWidgetClicked()
150 {
151 }
152
153 void Pages::PgSeltreeWidgetDoubleClicked()
154 {
155 }
156
157 /*
158  *  * Virtual function which is called when this page is visible on the stack
159  */
160 void Pages::currentStackItem()
161 {
162 }