]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/pages.cpp
dhb use the stack widget signal currentChanged to trigger function
[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
36 /*
37  * dockPage
38  * This function is intended to be called from within the Pages class to pull
39  * a window from floating to in the stack widget.
40  */
41
42 void Pages::dockPage()
43 {
44    /* These two lines are for making sure if it is being changed from a window
45     * that it has the proper window flag and parent.
46     */
47    setWindowFlags(Qt::Widget);
48    setParent(m_parent);
49
50    /* This was being done already */
51    m_parent->addWidget(this);
52
53    /* Set docked flag */
54    m_docked = true;
55 }
56
57 /*
58  * undockPage
59  * This function is intended to be called from within the Pages class to put
60  * a window from the stack widget to a floating window.
61  */
62
63 void Pages::undockPage()
64 {
65    /* Change from a stacked widget to a normal window */
66    m_parent->removeWidget(this);
67    setWindowFlags(Qt::Window);
68    show();
69    /* Clear docked flag */
70    m_docked = false;
71 }
72
73 /*
74  * This function is intended to be called with the subclasses.  When it is called
75  * the specific sublclass does not have to be known to Pages.  It is called 
76  * it will take it from it's current state of floating or stacked and change it
77  * to the other.
78  */
79
80 void Pages::togglePageDocking()
81 {
82    if (m_docked) {
83       undockPage();
84    } else {
85       dockPage();
86    }
87 }
88
89 /*
90  * This function is because I wanted for some reason to keep it private but still 
91  * give any subclasses the ability to find out if it is currently stacked or not.
92  */
93
94 bool Pages::isDocked()
95 {
96    return m_docked;
97 }
98
99 /*
100  * When a window is closed, this slot is called.  The idea is to put it back in the
101  * stack here, and it works.  I wanted to get it to the top of the stack so that the
102  * user immediately sees where his window went.  Also, if he undocks the window, then
103  * closes it with the tree item highlighted, it may be confusing that the highlighted
104  * treewidgetitem is not the stack item in the front.
105  */
106
107 void Pages::closeEvent(QCloseEvent* /*event*/)
108 {
109    /* A Widget was closed, lets toggle it back into the window, and set it in front. */
110    dockPage();
111
112 #ifdef xxx
113    /* FIXME Really having problems getting it to the front, 
114       toggles back into the stack fine though */
115    int stackindex=m_parent->indexOf( this );
116 printf("In Pages closeEvent a\n");
117    if( stackindex >= 0 ){
118 printf("In Pages closeEvent b\n");
119       m_parent->setCurrentIndex(0);
120       m_parent->setCurrentWidget(this);
121       show();
122       //m_parent->setCurrentIndex(stackindex);
123 //      m_parent->setCurrentWidget(this);
124 /*      m_parent->update();
125       update();
126       setUpdatesEnabled(true);
127       setVisible(true);
128       m_parent->show();
129       show();
130       m_parent->repaint();*/
131       repaint();
132       raise();
133    }
134 #endif
135 }
136
137 /*
138  * The next three are virtual functions.  The idea here is that each subclass will have the
139  * built in virtual function to override if the programmer wants to populate the window
140  * when it it is first clicked.
141  */
142 void Pages::PgSeltreeWidgetClicked()
143 {
144 }
145
146 void Pages::PgSeltreeWidgetDoubleClicked()
147 {
148 }
149
150 /*
151  *  * Virtual function which is called when this page is visible on the stack
152  */
153 void Pages::currentStackItem()
154 {
155 }
156
157 /*
158  * This function exists because to have an easy way for programmers adding new features to understand
159  * exactly what values needed to be set in order to behave correctly in the interface.  It can
160  * be called from the constructor, like with medialist or after being constructed, like with
161  * Console.
162  */
163 void Pages::SetPassedValues(QStackedWidget* passedStackedWidget, QTreeWidgetItem* passedTreeItem, int indexseq )
164 {
165    m_parent = passedStackedWidget;
166    m_treeItem = passedTreeItem;
167    m_treeItem->setData(0, Qt::UserRole, QVariant(indexseq));
168 }