]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQMainWinDock.h
don't reset the changes file
[duncan/yast2-qt4.git] / src / YQMainWinDock.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQMainWinDock.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQMainWinDock_h
21 #define YQMainWinDock_h
22
23 #include <deque>
24 #include <qwidget.h>
25
26 class QWidgetStack;
27
28
29 /**
30  * Container window for YQDialogs of type YMainWindowDialog:
31  *
32  * This widget "swallows" any main dialogs it gets so only the topmost of them
33  * is visible at any given time. It acts as a window stack for main dialogs,
34  * making the next lower dialog on the stack visible as when the (previously)
35  * topmost main dialog is closed.
36  *
37  * This widget also handles its own visibility accordingly: It is visible if
38  * and only if it has a main dialog to display. It makes itself invisible when
39  * there is no more main dialog to display, and it makes itself visible again
40  * when a new main dialog appears.
41  *
42  * This widget can swallow an arbitrary number of main dialogs as they are
43  * opened as long as there is no popup dialog in between.
44  **/
45 class YQMainWinDock : public QWidget
46 {
47     Q_OBJECT
48
49 public:
50     /**
51      * Static method to access the singleton for this class.
52      *
53      * This creates the (one and only) instance of this class in the first
54      * call. Subsequent calls simply return this instance.
55      **/
56     static YQMainWinDock * mainWinDock();
57
58     /**
59      * Add a dialog (the widgetRep() of a YQDialog) to the MainWinDock (on top
60      * of its widget stack. The widget stack does not assume ownership of the
61      * widget.
62      *
63      * If the MainWinDock is not visible yet, this operation makes it visible.
64      **/
65     void add( QWidget * dialog );
66
67     /**
68      * Remove a dialog from the MainWinDock (if it belongs to the
69      * MainWinDock). If dialog is 0, this removes the topmost dialog from the
70      * MainWinDock.
71      *
72      * This can safely be called in the destructor of all dialogs, even those
73      * that were never added to the MainWinDock.
74      *
75      * If that was the last main dialog in the MainWinDock, the MainWinDock
76      * will be hidden (until another main dialog is added).
77      **/
78     void remove( QWidget * dialog = 0 );
79
80     /**
81      * Return the current topmost dialog (the widgetRep() of a YQDialog)
82      * or 0 if there is none.
83      **/
84     QWidget * topmostDialog() const;
85
86     /**
87      * Return 'true' if the next main dialog could be docked,
88      * i.e., if there is either no open dialog at all or only main dialogs.
89      **/
90     bool couldDock();
91
92     /**
93      * Show the widget (make it visible).
94      *
95      * Reimplemented from QWidget.
96      **/
97     virtual void show();
98
99     /**
100      * Window manager close event (Alt-F4):
101      * Send a YCancelEvent and let the application handle that event.
102      *
103      * Reimplemented from QWidget.
104      **/
105     virtual void closeEvent( QCloseEvent * event );
106
107
108 protected:
109     /**
110      * Constructor.
111      *
112      * Use the static mainWinDock() method to access the singleton for this
113      * class.
114      **/
115     YQMainWinDock();
116
117     /**
118      * Destructor.
119      **/
120     virtual ~YQMainWinDock();
121
122 protected:
123
124     /**
125      * Paint event.
126      *
127      * Reimplemented from QWidget.
128      **/
129     virtual void paintEvent( QPaintEvent * event );
130
131     /**
132      * Resize event.
133      *
134      * Reimplemented from QWidget.
135      **/
136     virtual void resizeEvent( QResizeEvent * event );
137
138     /**
139      * Resize the visible child to the current size of the dock.
140      **/
141     void resizeVisibleChild();
142
143
144 protected slots:
145
146     /**
147      * Show the current dialog.
148      **/
149     void showCurrentDialog();
150
151
152 private:
153
154     typedef std::deque<QWidget *> YQWidgetStack;
155
156     /**
157      * Return an iterator to the specified dialog in the internal
158      * widgetstack or _widgetStack::end() if not found.
159      **/
160     YQWidgetStack::iterator findInStack( QWidget * dialog );
161
162
163     YQWidgetStack _widgetStack;
164 };
165
166
167 #endif // YQMainWinDock_h
168
169