author | zecke <zecke> | 2003-09-02 21:28:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-02 21:28:27 (UTC) |
commit | 88d625d9695582d57852f94581f71bb18c00a8a1 (patch) (unidiff) | |
tree | c04adb455e19c160a755c50b9bdf95425bfd06e1 | |
parent | 3cf3fc001922a7ef34c7ff95751beb569809383b (diff) | |
download | opie-88d625d9695582d57852f94581f71bb18c00a8a1.zip opie-88d625d9695582d57852f94581f71bb18c00a8a1.tar.gz opie-88d625d9695582d57852f94581f71bb18c00a8a1.tar.bz2 |
New impressive example and test suite
Now OSplitter is almost done
-rw-r--r-- | libopie/big-screen/example/osplitter_mail.cpp | 70 | ||||
-rw-r--r-- | libopie/big-screen/example/osplitter_mail.h | 48 | ||||
-rw-r--r-- | libopie/big-screen/example/osplitter_mail.pro | 12 | ||||
-rw-r--r-- | libopie/big-screen/osplitter.cpp | 55 | ||||
-rw-r--r-- | libopie/big-screen/osplitter.h | 10 |
5 files changed, 176 insertions, 19 deletions
diff --git a/libopie/big-screen/example/osplitter_mail.cpp b/libopie/big-screen/example/osplitter_mail.cpp new file mode 100644 index 0000000..91442c8 --- a/dev/null +++ b/libopie/big-screen/example/osplitter_mail.cpp | |||
@@ -0,0 +1,70 @@ | |||
1 | |||
2 | #include <qstring.h> | ||
3 | #include <qlabel.h> | ||
4 | #include <qheader.h> | ||
5 | #include <qlayout.h> | ||
6 | |||
7 | #include <qpe/qpeapplication.h> | ||
8 | #include <opie/oapplicationfactory.h> | ||
9 | |||
10 | #include "../osplitter.h" | ||
11 | |||
12 | #include "osplitter_mail.h" | ||
13 | |||
14 | |||
15 | OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) | ||
16 | |||
17 | class Folder { | ||
18 | int dummy; | ||
19 | }; | ||
20 | |||
21 | // ----------------------------------------------------------------- | ||
22 | |||
23 | ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) | ||
24 | : QWidget( p, name, fl ) { | ||
25 | m_lstFolders.setAutoDelete( true ); | ||
26 | QHBoxLayout *lay = new QHBoxLayout(this); | ||
27 | |||
28 | m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" ); | ||
29 | lay->addWidget( m_splitter ); | ||
30 | connect(m_splitter, SIGNAL(sizeChange(bool, const QSize& ) ), | ||
31 | this, SLOT(slotSizeChange(bool, const QSize& ) ) ); | ||
32 | |||
33 | m_overview = new QListView( m_splitter ); | ||
34 | m_overview->header()->setClickEnabled( FALSE ); | ||
35 | m_overview->addColumn( tr("Folder") ); | ||
36 | m_overview->setMaximumWidth( 200 ); | ||
37 | m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") ); | ||
38 | m_splitter->setSizeChange( 300 ); | ||
39 | |||
40 | /* OSplitter starts with the small mode */ | ||
41 | m_messages = 0; | ||
42 | m_message = m_attach = 0; | ||
43 | |||
44 | splitti = new OSplitter( Vertical, m_splitter, "Splitti2" ); | ||
45 | splitti->setSizeChange( 300 ); | ||
46 | splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); | ||
47 | |||
48 | QLabel *lbl = new QLabel(splitti); | ||
49 | lbl->setTextFormat ( Qt::RichText ); | ||
50 | lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>"); | ||
51 | |||
52 | m_messages = new QListView( splitti ); | ||
53 | m_messages->addColumn(" Messages "); | ||
54 | |||
55 | folder1 = new QListView( splitti ); | ||
56 | folder1->addColumn( "Messages 2 " ); | ||
57 | |||
58 | splitti->addWidget(m_messages, "mail", tr("Mails") ); | ||
59 | splitti->addWidget(folder1, "folder", tr("Folder") ); | ||
60 | splitti->addWidget( lbl, "logo", tr("Label") ); | ||
61 | m_message = lbl; | ||
62 | |||
63 | m_splitter->addWidget( splitti ); | ||
64 | |||
65 | } | ||
66 | |||
67 | |||
68 | ListViews::~ListViews() { | ||
69 | |||
70 | } | ||
diff --git a/libopie/big-screen/example/osplitter_mail.h b/libopie/big-screen/example/osplitter_mail.h new file mode 100644 index 0000000..d76f264 --- a/dev/null +++ b/libopie/big-screen/example/osplitter_mail.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * You may use, modify and distribute this code without any limitation | ||
3 | */ | ||
4 | |||
5 | /* | ||
6 | * Header file for a more complete email client like | ||
7 | * layout | ||
8 | */ | ||
9 | |||
10 | #ifndef OPIE_SPLITTER_MAIL_EXAMPLE_H | ||
11 | #define OPIE_SPLITTER_MAIL_EXAMPLE_H | ||
12 | |||
13 | #include <qwidget.h> | ||
14 | #include <qlist.h> | ||
15 | #include <qlistview.h> | ||
16 | |||
17 | class Folder; | ||
18 | class QLabel; | ||
19 | |||
20 | class OSplitter; | ||
21 | class ListViews : public QWidget { | ||
22 | Q_OBJECT | ||
23 | public: | ||
24 | static QString appName() { return QString::fromLatin1("osplitter-mail"); } | ||
25 | ListViews( QWidget* parent, const char * name, WFlags fl ); | ||
26 | ~ListViews(); | ||
27 | |||
28 | private: | ||
29 | void initFolders(); | ||
30 | void initFolder( Folder *folder, unsigned int &count ); | ||
31 | |||
32 | QListView *m_messages, *m_overview; | ||
33 | QLabel *m_message, *m_attach; | ||
34 | QList<QListView> m_folders; // used in tab mode | ||
35 | QList<Folder> m_lstFolders; | ||
36 | bool m_mode : 1; // bitfield | ||
37 | OSplitter *m_splitter; | ||
38 | OSplitter *splitti; | ||
39 | QListView *folder1; | ||
40 | #if 0 | ||
41 | //private slots: | ||
42 | // void slotFolderChanged( QListViewItem* ); | ||
43 | // void slotMessageChanged(); | ||
44 | // void slotSizeChange( bool, const QSize& ); | ||
45 | #endif | ||
46 | }; | ||
47 | |||
48 | #endif | ||
diff --git a/libopie/big-screen/example/osplitter_mail.pro b/libopie/big-screen/example/osplitter_mail.pro new file mode 100644 index 0000000..ec6e626 --- a/dev/null +++ b/libopie/big-screen/example/osplitter_mail.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | CONFIG += qt warn_on | ||
2 | TEMPLATE = app | ||
3 | TARGET = osplitter-mail | ||
4 | |||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDSPATH += $(OPIEDIR)/include | ||
7 | |||
8 | HEADERS = osplitter_mail.h | ||
9 | SOURCES = osplitter_mail.cpp | ||
10 | |||
11 | LIBS += -lqpe -lopie | ||
12 | include ( $(OPIEDIR)/include.pro ) | ||
diff --git a/libopie/big-screen/osplitter.cpp b/libopie/big-screen/osplitter.cpp index d06568f..47f856d 100644 --- a/libopie/big-screen/osplitter.cpp +++ b/libopie/big-screen/osplitter.cpp | |||
@@ -1,560 +1,581 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qvaluelist.h> | 29 | #include <qvaluelist.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | 31 | ||
32 | #include <opie/otabwidget.h> | 32 | #include <opie/otabwidget.h> |
33 | 33 | ||
34 | #include "osplitter.h" | 34 | #include "osplitter.h" |
35 | 35 | ||
36 | 36 | ||
37 | /** | 37 | /** |
38 | * | 38 | * |
39 | * This is the constructor of OSplitter | 39 | * This is the constructor of OSplitter |
40 | * You might want to call setSizeChange to tell | 40 | * You might want to call setSizeChange to tell |
41 | * OSplitter to change its layout when a specefic | 41 | * OSplitter to change its layout when a specefic |
42 | * mark was crossed. OSplitter sets a default value. | 42 | * mark was crossed. OSplitter sets a default value. |
43 | * | 43 | * |
44 | * You cann add widget with addWidget to the OSplitter. | 44 | * You cann add widget with addWidget to the OSplitter. |
45 | * OSplitter supports also grouping of Splitters where they | 45 | * OSplitter supports also grouping of Splitters where they |
46 | * can share one OTabBar in small screen mode. This can be used | 46 | * can share one OTabBar in small screen mode. This can be used |
47 | * for email clients like vies but see the example. | 47 | * for email clients like vies but see the example. |
48 | * | 48 | * |
49 | * @param orient The orientation wether to layout horizontal or vertical | 49 | * @param orient The orientation wether to layout horizontal or vertical |
50 | * @param parent The parent of this widget | 50 | * @param parent The parent of this widget |
51 | * @param name The name passed on to QObject | 51 | * @param name The name passed on to QObject |
52 | * @param fl Additional widgets flags passed to QWidget | 52 | * @param fl Additional widgets flags passed to QWidget |
53 | * | 53 | * |
54 | * @short single c'tor of the OSplitter | 54 | * @short single c'tor of the OSplitter |
55 | */ | 55 | */ |
56 | OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) | 56 | OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) |
57 | : QFrame( parent, name, fl ) | 57 | : QFrame( parent, name, fl ) |
58 | { | 58 | { |
59 | m_orient = orient; | 59 | m_orient = orient; |
60 | m_hbox = 0; | 60 | m_hbox = 0; |
61 | m_size_policy = 330; | 61 | m_size_policy = 330; |
62 | setFontPropagation( AllChildren ); | 62 | setFontPropagation( AllChildren ); |
63 | setPalettePropagation( AllChildren ); | 63 | setPalettePropagation( AllChildren ); |
64 | 64 | ||
65 | /* start by default with the tab widget */ | 65 | /* start by default with the tab widget */ |
66 | m_tabWidget = 0; | 66 | m_tabWidget = 0; |
67 | m_parentTab = 0; | 67 | m_parentTab = 0; |
68 | changeTab(); | 68 | changeTab(); |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Destructor destructs this object and cleans up. All child | 74 | * Destructor destructs this object and cleans up. All child |
75 | * widgets will be deleted | 75 | * widgets will be deleted |
76 | * @see addWidget | 76 | * @see addWidget |
77 | */ | 77 | */ |
78 | OSplitter::~OSplitter() { | 78 | OSplitter::~OSplitter() { |
79 | qWarning("Deleted Splitter"); | ||
79 | m_splitter.setAutoDelete( true ); | 80 | m_splitter.setAutoDelete( true ); |
80 | m_splitter.clear(); | 81 | m_splitter.clear(); |
81 | 82 | ||
82 | delete m_hbox; | 83 | delete m_hbox; |
83 | delete m_tabWidget; | 84 | delete m_tabWidget; |
84 | } | 85 | } |
85 | 86 | ||
86 | 87 | ||
87 | /** | 88 | /** |
88 | * Sets the label for the Splitter. This label will be used | 89 | * Sets the label for the Splitter. This label will be used |
89 | * if a parent splitter is arranged as TabWidget but | 90 | * if a parent splitter is arranged as TabWidget but |
90 | * this splitter is in fullscreen mode. Then a tab with OSplitter::label() | 91 | * this splitter is in fullscreen mode. Then a tab with OSplitter::label() |
91 | * and iconName() gets added. | 92 | * and iconName() gets added. |
92 | * | 93 | * |
93 | * @param name The name of the Label | 94 | * @param name The name of the Label |
94 | */ | 95 | */ |
95 | void OSplitter::setLabel( const QString& name ) { | 96 | void OSplitter::setLabel( const QString& name ) { |
96 | m_name = name; | 97 | m_name = name; |
97 | } | 98 | } |
98 | 99 | ||
99 | /** | 100 | /** |
100 | * @see setLabel but this is for the icon retrieved by Resource | 101 | * @see setLabel but this is for the icon retrieved by Resource |
101 | * | 102 | * |
102 | * @param name The name of the icon in example ( "zoom" ) | 103 | * @param name The name of the icon in example ( "zoom" ) |
103 | */ | 104 | */ |
104 | void OSplitter::setIconName( const QString& name ) { | 105 | void OSplitter::setIconName( const QString& name ) { |
105 | m_icon = name; | 106 | m_icon = name; |
106 | } | 107 | } |
107 | 108 | ||
108 | 109 | ||
109 | /** | 110 | /** |
110 | * returns the iconName | 111 | * returns the iconName |
111 | * @see setIconName | 112 | * @see setIconName |
112 | */ | 113 | */ |
113 | QString OSplitter::iconName()const { | 114 | QString OSplitter::iconName()const { |
114 | return m_icon; | 115 | return m_icon; |
115 | } | 116 | } |
116 | 117 | ||
117 | /** | 118 | /** |
118 | * returns the label set with setLabel | 119 | * returns the label set with setLabel |
119 | * @see setLabel | 120 | * @see setLabel |
120 | */ | 121 | */ |
121 | QString OSplitter::label()const { | 122 | QString OSplitter::label()const { |
122 | return m_name; | 123 | return m_name; |
123 | } | 124 | } |
124 | 125 | ||
125 | /** | 126 | /** |
126 | * This function sets the size change policy of the splitter. | 127 | * This function sets the size change policy of the splitter. |
127 | * If this size marked is crossed the splitter will relayout. | 128 | * If this size marked is crossed the splitter will relayout. |
128 | * Note: that depending on the set Orientation it'll either look | 129 | * Note: that depending on the set Orientation it'll either look |
129 | * at the width or height. | 130 | * at the width or height. |
130 | * Note: If you want to from side to side view to tabbed view you need | 131 | * Note: If you want to from side to side view to tabbed view you need |
131 | * to make sure that the size you supply is not smaller than the minimum | 132 | * to make sure that the size you supply is not smaller than the minimum |
132 | * size of your added widgets. Note that if you use widgets like QComboBoxes | 133 | * size of your added widgets. Note that if you use widgets like QComboBoxes |
133 | * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy | 134 | * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy |
134 | * | 135 | * |
135 | * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. | 136 | * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. |
136 | * @return void | 137 | * @return void |
137 | */ | 138 | */ |
138 | void OSplitter::setSizeChange( int width_height ) { | 139 | void OSplitter::setSizeChange( int width_height ) { |
139 | m_size_policy = width_height; | 140 | m_size_policy = width_height; |
140 | QSize sz(width(), height() ); | 141 | QSize sz(width(), height() ); |
141 | QResizeEvent ev(sz, sz ); | 142 | QResizeEvent ev(sz, sz ); |
142 | resizeEvent(&ev); | 143 | resizeEvent(&ev); |
143 | } | 144 | } |
144 | 145 | ||
145 | /** | 146 | /** |
146 | * This functions allows to add another OSplitter and to share | 147 | * This functions allows to add another OSplitter and to share |
147 | * the OTabBar in small screen mode. The ownerships gets transfered. | 148 | * the OTabBar in small screen mode. The ownerships gets transfered. |
148 | * OSplitters are always added after normal widget items | 149 | * OSplitters are always added after normal widget items |
149 | */ | 150 | */ |
150 | void OSplitter::addWidget( OSplitter* split ) { | 151 | void OSplitter::addWidget( OSplitter* split ) { |
151 | m_splitter.append( split ); | 152 | m_splitter.append( split ); |
152 | 153 | ||
153 | /* | 154 | /* |
154 | * set tab widget | 155 | * set tab widget |
155 | */ | 156 | */ |
156 | if (m_tabWidget ) | 157 | if (m_tabWidget ) |
157 | split->setTabWidget( m_tabWidget ); | 158 | setTabWidget( m_parentTab ); |
158 | else{ | 159 | else{ |
159 | Opie::OSplitterContainer con; | 160 | Opie::OSplitterContainer con; |
160 | con.widget =split; | 161 | con.widget =split; |
161 | addToBox( con ); | 162 | addToBox( con ); |
162 | } | 163 | } |
163 | } | 164 | } |
164 | 165 | ||
165 | /* | 166 | /* |
166 | * If in a tab it should be removed | 167 | * If in a tab it should be removed |
167 | * and if in a hbox the reparent kills it too | 168 | * and if in a hbox the reparent kills it too |
168 | */ | 169 | */ |
169 | /** | 170 | /** |
170 | * This removes the splitter again. You currently need to call this | 171 | * This removes the splitter again. You currently need to call this |
171 | * before you delete or otherwise you can get mem corruption | 172 | * before you delete or otherwise you can get mem corruption |
172 | * or other weird behaviour. | 173 | * or other weird behaviour. |
173 | * Owner ship gets transfered back to you it's current parent | 174 | * Owner ship gets transfered back to you it's current parent |
174 | * is 0 | 175 | * is 0 |
175 | */ | 176 | */ |
176 | void OSplitter::removeWidget( OSplitter* split) { | 177 | void OSplitter::removeWidget( OSplitter* split) { |
177 | split->setTabWidget( 0 ); | 178 | split->setTabWidget( 0 ); |
178 | split->reparent( 0, 0, QPoint(0, 0) ); | 179 | split->reparent( 0, 0, QPoint(0, 0) ); |
179 | } | 180 | } |
180 | 181 | ||
181 | /** | 182 | /** |
182 | * Adds a widget to the Splitter. The widgets gets inserted | 183 | * Adds a widget to the Splitter. The widgets gets inserted |
183 | * at the end of either the Box or TabWidget. | 184 | * at the end of either the Box or TabWidget. |
184 | * Ownership gets transfered and the widgets gets reparented. | 185 | * Ownership gets transfered and the widgets gets reparented. |
185 | * Note: icon and label is only available on small screensizes | 186 | * Note: icon and label is only available on small screensizes |
186 | * if size is smaller than the mark | 187 | * if size is smaller than the mark |
187 | * Warning: No null checking of the widget is done. Only on debug | 188 | * Warning: No null checking of the widget is done. Only on debug |
188 | * a message will be outputtet | 189 | * a message will be outputtet |
189 | * | 190 | * |
190 | * @param wid The widget which will be added | 191 | * @param wid The widget which will be added |
191 | * @param icon The icon of the possible Tab | 192 | * @param icon The icon of the possible Tab |
192 | * @param label The label of the possible Tab | 193 | * @param label The label of the possible Tab |
193 | */ | 194 | */ |
194 | void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) { | 195 | void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) { |
195 | #ifdef DEBUG | 196 | #ifdef DEBUG |
196 | if (!wid ) { | 197 | if (!wid ) { |
197 | qWarning("Widget is not valid!"); | 198 | qWarning("Widget is not valid!"); |
198 | return; | 199 | return; |
199 | } | 200 | } |
200 | #endif | 201 | #endif |
201 | Opie::OSplitterContainer cont; | 202 | Opie::OSplitterContainer cont; |
202 | cont.widget = wid; | 203 | cont.widget = wid; |
203 | cont.icon =icon; | 204 | cont.icon =icon; |
204 | cont.name = label; | 205 | cont.name = label; |
205 | 206 | ||
206 | m_container.append( cont ); | 207 | m_container.append( cont ); |
207 | 208 | ||
208 | /* | 209 | /* |
209 | * | 210 | * |
210 | */ | 211 | */ |
211 | if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) | 212 | if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) |
212 | setTabWidget( m_parentTab ); | 213 | setTabWidget( m_parentTab ); |
213 | else { | 214 | else { |
214 | if (m_hbox ) | 215 | if (m_hbox ) |
215 | addToBox( cont ); | 216 | addToBox( cont ); |
216 | else | 217 | else |
217 | addToTab( cont ); | 218 | addToTab( cont ); |
218 | } | 219 | } |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | /** | 223 | /** |
223 | * Removes the widget from the tab widgets if necessary. | 224 | * Removes the widget from the tab widgets if necessary. |
224 | * OSplitter drops ownership of this widget and the widget | 225 | * OSplitter drops ownership of this widget and the widget |
225 | * will be reparented i tto 0. | 226 | * will be reparented i tto 0. |
226 | * The widget will not be deleted. | 227 | * The widget will not be deleted. |
227 | * | 228 | * |
228 | * @param w The widget to be removed | 229 | * @param w The widget to be removed |
229 | */ | 230 | */ |
230 | void OSplitter::removeWidget( QWidget* w) { | 231 | void OSplitter::removeWidget( QWidget* w) { |
231 | ContainerList::Iterator it; | 232 | ContainerList::Iterator it; |
232 | for ( it = m_container.begin(); it != m_container.end(); ++it ) | 233 | for ( it = m_container.begin(); it != m_container.end(); ++it ) |
233 | if ( (*it).widget == w ) | 234 | if ( (*it).widget == w ) |
234 | break; | 235 | break; |
235 | 236 | ||
236 | if (it == m_container.end() ) | 237 | if (it == m_container.end() ) |
237 | return; | 238 | return; |
238 | 239 | ||
239 | 240 | ||
240 | /* only tab needs to be removed.. box recognizes it */ | 241 | /* only tab needs to be removed.. box recognizes it */ |
241 | if ( !m_hbox ) | 242 | if ( !m_hbox ) |
242 | removeFromTab( w ); | 243 | removeFromTab( w ); |
243 | 244 | ||
244 | 245 | ||
245 | /* Find reparent it and remove it from our list */ | 246 | /* Find reparent it and remove it from our list */ |
246 | 247 | ||
247 | w->reparent( 0, 0, QPoint(0, 0)); | 248 | w->reparent( 0, 0, QPoint(0, 0)); |
248 | it = m_container.remove( it ); | 249 | it = m_container.remove( it ); |
249 | 250 | ||
250 | } | 251 | } |
251 | 252 | ||
252 | 253 | ||
253 | /** | 254 | /** |
254 | * This method will give focus to the widget. If in a tabwidget | 255 | * This method will give focus to the widget. If in a tabwidget |
255 | * the tabbar will be changed | 256 | * the tabbar will be changed |
256 | * | 257 | * |
257 | * @param w The widget which will be set the current one | 258 | * @param w The widget which will be set the current one |
258 | */ | 259 | */ |
259 | void OSplitter::setCurrentWidget( QWidget* w) { | 260 | void OSplitter::setCurrentWidget( QWidget* w) { |
260 | if (m_tabWidget ) | 261 | if (m_tabWidget ) |
261 | m_tabWidget->setCurrentTab( w ); | 262 | m_tabWidget->setCurrentTab( w ); |
262 | // else | 263 | // else |
263 | // m_hbox->setFocus( w ); | 264 | // m_hbox->setFocus( w ); |
264 | 265 | ||
265 | } | 266 | } |
266 | 267 | ||
267 | /** | 268 | /** |
268 | * This is an overloaded member function and only differs in the | 269 | * This is an overloaded member function and only differs in the |
269 | * argument it takes. | 270 | * argument it takes. |
270 | * Searches list of widgets for label. It'll pick the first label it finds | 271 | * Searches list of widgets for label. It'll pick the first label it finds |
271 | * | 272 | * |
272 | * @param label Label to look for. First match will be taken | 273 | * @param label Label to look for. First match will be taken |
273 | */ | 274 | */ |
274 | void OSplitter::setCurrentWidget( const QString& label ) { | 275 | void OSplitter::setCurrentWidget( const QString& label ) { |
275 | ContainerList::Iterator it; | 276 | ContainerList::Iterator it; |
276 | for (it = m_container.begin(); it != m_container.end(); ++it ) { | 277 | for (it = m_container.begin(); it != m_container.end(); ++it ) { |
277 | if ( (*it).name == label ) { | 278 | if ( (*it).name == label ) { |
278 | setCurrentWidget( (*it).widget ); | 279 | setCurrentWidget( (*it).widget ); |
279 | break; | 280 | break; |
280 | } | 281 | } |
281 | } | 282 | } |
282 | } | 283 | } |
283 | 284 | ||
284 | /** | 285 | /** |
285 | * This will only work when the TabWidget is active | 286 | * This will only work when the TabWidget is active |
286 | * If everything is visible this signal is kindly ignored | 287 | * If everything is visible this signal is kindly ignored |
287 | * @see OTabWidget::setCurrentTab(int) | 288 | * @see OTabWidget::setCurrentTab(int) |
288 | * | 289 | * |
289 | * @param tab The tab to make current | 290 | * @param tab The tab to make current |
290 | */ | 291 | */ |
291 | void OSplitter::setCurrentWidget( int tab ) { | 292 | void OSplitter::setCurrentWidget( int tab ) { |
292 | if (m_tabWidget ) | 293 | if (m_tabWidget ) |
293 | m_tabWidget->setCurrentTab( tab ); | 294 | m_tabWidget->setCurrentTab( tab ); |
294 | } | 295 | } |
295 | 296 | ||
296 | /** | 297 | /** |
297 | * return the currently activated widget if in tab widget mode | 298 | * return the currently activated widget if in tab widget mode |
298 | * or null because all widgets are visible | 299 | * or null because all widgets are visible |
299 | */ | 300 | */ |
300 | QWidget* OSplitter::currentWidget() const{ | 301 | QWidget* OSplitter::currentWidget() const{ |
301 | if (m_tabWidget) | 302 | if (m_tabWidget) |
302 | return m_tabWidget->currentWidget(); | 303 | return m_tabWidget->currentWidget(); |
303 | else if (m_parentTab ) | 304 | else if (m_parentTab ) |
304 | return m_parentTab->currentWidget(); | 305 | return m_parentTab->currentWidget(); |
305 | 306 | ||
306 | return 0l; | 307 | return 0l; |
307 | } | 308 | } |
308 | 309 | ||
309 | #if 0 | 310 | |
310 | /** | 311 | /** |
311 | * @reimplented for internal reasons | 312 | * @reimplented for internal reasons |
312 | * returns the sizeHint of one of its sub widgets | 313 | * returns the sizeHint of one of its sub widgets |
313 | */ | 314 | */ |
314 | QSize OSplitter::sizeHint()const { | 315 | QSize OSplitter::sizeHint()const { |
315 | return QSize(10, 10); | 316 | if (m_parentTab ) |
317 | return QFrame::sizeHint(); | ||
316 | 318 | ||
317 | if (m_hbox ) | 319 | if (m_hbox ) |
318 | return m_hbox->sizeHint(); | 320 | return m_hbox->sizeHint(); |
319 | else | 321 | else |
320 | return m_tabWidget->sizeHint(); | 322 | return m_tabWidget->sizeHint(); |
321 | } | 323 | } |
322 | 324 | ||
323 | QSize OSplitter::minimumSizeHint()const { | 325 | QSize OSplitter::minimumSizeHint()const { |
324 | return QSize(10, 10 ); | 326 | if (m_parentTab ) |
327 | return QFrame::minimumSizeHint(); | ||
328 | if (m_hbox) | ||
329 | return m_hbox->sizeHint(); | ||
330 | else | ||
331 | return m_tabWidget->sizeHint(); | ||
325 | } | 332 | } |
326 | #endif | 333 | |
327 | 334 | ||
328 | /** | 335 | /** |
329 | * @reimplemented for internal reasons | 336 | * @reimplemented for internal reasons |
330 | */ | 337 | */ |
331 | void OSplitter::resizeEvent( QResizeEvent* res ) { | 338 | void OSplitter::resizeEvent( QResizeEvent* res ) { |
332 | QFrame::resizeEvent( res ); | 339 | QFrame::resizeEvent( res ); |
333 | /* | 340 | /* |
334 | * | 341 | * |
335 | */ | 342 | */ |
336 | // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); | 343 | // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); |
337 | bool mode = true; | 344 | bool mode = true; |
338 | qWarning("New size is width = %d height = %d", res->size().width(), res->size().height() ); | 345 | qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); |
339 | if ( res->size().width() > m_size_policy && | 346 | if ( res->size().width() > m_size_policy && |
340 | m_orient == Horizontal ) { | 347 | m_orient == Horizontal ) { |
341 | changeHBox(); | 348 | changeHBox(); |
342 | mode = false; | 349 | mode = false; |
343 | }else if ( (res->size().width() <= m_size_policy && | 350 | }else if ( (res->size().width() <= m_size_policy && |
344 | m_orient == Horizontal ) || | 351 | m_orient == Horizontal ) || |
345 | (res->size().height() <= m_size_policy && | 352 | (res->size().height() <= m_size_policy && |
346 | m_orient == Vertical ) ) { | 353 | m_orient == Vertical ) ) { |
347 | changeTab(); | 354 | changeTab(); |
348 | }else if ( res->size().height() > m_size_policy && | 355 | }else if ( res->size().height() > m_size_policy && |
349 | m_size_policy == Vertical ) { | 356 | m_orient == Vertical ) { |
357 | qWarning("Changng to vbox %s", name() ); | ||
350 | changeVBox(); | 358 | changeVBox(); |
351 | mode = false; | 359 | mode = false; |
352 | } | 360 | } |
353 | 361 | ||
354 | emit sizeChanged(mode, m_orient ); | 362 | emit sizeChanged(mode, m_orient ); |
355 | } | 363 | } |
356 | 364 | ||
357 | /* | 365 | /* |
358 | * Adds a container to a tab either the parent tab | 366 | * Adds a container to a tab either the parent tab |
359 | * or our own | 367 | * or our own |
360 | */ | 368 | */ |
361 | void OSplitter::addToTab( const Opie::OSplitterContainer& con ) { | 369 | void OSplitter::addToTab( const Opie::OSplitterContainer& con ) { |
362 | QWidget *wid = con.widget; | 370 | QWidget *wid = con.widget; |
363 | // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); | 371 | // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); |
364 | if (m_parentTab ) | 372 | if (m_parentTab ) |
365 | m_parentTab->addTab( wid, con.icon, con.name ); | 373 | m_parentTab->addTab( wid, con.icon, con.name ); |
366 | else | 374 | else |
367 | m_tabWidget->addTab( wid, con.icon, con.name ); | 375 | m_tabWidget->addTab( wid, con.icon, con.name ); |
368 | } | 376 | } |
369 | 377 | ||
370 | 378 | ||
371 | /* | 379 | /* |
372 | * adds a container to the box | 380 | * adds a container to the box |
373 | */ | 381 | */ |
374 | void OSplitter::addToBox( const Opie::OSplitterContainer& con ) { | 382 | void OSplitter::addToBox( const Opie::OSplitterContainer& con ) { |
375 | QWidget* wid = con.widget; | 383 | QWidget* wid = con.widget; |
376 | wid->reparent(m_hbox, 0, QPoint(0, 0) ); | 384 | wid->reparent(m_hbox, 0, QPoint(0, 0) ); |
377 | } | 385 | } |
378 | 386 | ||
379 | 387 | ||
380 | /* | 388 | /* |
381 | * Removes a widget from the tab | 389 | * Removes a widget from the tab |
382 | */ | 390 | */ |
383 | void OSplitter::removeFromTab( QWidget* wid ) { | 391 | void OSplitter::removeFromTab( QWidget* wid ) { |
384 | if (m_parentTab ) | 392 | if (m_parentTab ) |
385 | m_parentTab->removePage( wid ); | 393 | m_parentTab->removePage( wid ); |
386 | else | 394 | else |
387 | m_tabWidget->removePage( wid ); | 395 | m_tabWidget->removePage( wid ); |
388 | } | 396 | } |
389 | 397 | ||
390 | /* | 398 | /* |
391 | * switches over to a OTabWidget layout | 399 | * switches over to a OTabWidget layout |
392 | * it is recursive | 400 | * it is recursive |
393 | */ | 401 | */ |
394 | void OSplitter::changeTab() { | 402 | void OSplitter::changeTab() { |
395 | /* if we're the owner of the tab widget */ | 403 | /* if we're the owner of the tab widget */ |
396 | if (m_tabWidget ) { | 404 | if (m_tabWidget ) { |
397 | m_tabWidget->setGeometry( frameRect() ); | 405 | m_tabWidget->setGeometry( frameRect() ); |
398 | return; | 406 | return; |
399 | } | 407 | } |
400 | 408 | ||
401 | qWarning(" New Tab Widget "); | 409 | qWarning(" New Tab Widget %s", name() ); |
402 | /* | 410 | /* |
403 | * and add all widgets this will reparent them | 411 | * and add all widgets this will reparent them |
404 | * delete m_hbox set it to 0 | 412 | * delete m_hbox set it to 0 |
405 | * | 413 | * |
406 | */ | 414 | */ |
407 | OTabWidget *tab; | 415 | OTabWidget *tab; |
408 | if ( m_parentTab ) { | 416 | if ( m_parentTab ) { |
409 | tab = m_parentTab; | 417 | tab = m_parentTab; |
410 | tab->removePage( this ); | 418 | /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ |
419 | if (!m_container.isEmpty() ) { | ||
420 | ContainerList::Iterator it = m_container.begin(); | ||
421 | for (; it != m_container.end(); ++it ) | ||
422 | m_parentTab->removePage( (*it).widget ); | ||
423 | } | ||
411 | }else | 424 | }else |
412 | tab = m_tabWidget = new OTabWidget( this ); | 425 | tab = m_tabWidget = new OTabWidget( this ); |
413 | 426 | ||
414 | connect(tab, SIGNAL(currentChanged(QWidget*) ), | 427 | connect(tab, SIGNAL(currentChanged(QWidget*) ), |
415 | this, SIGNAL(currentChanged(QWidget*) ) ); | 428 | this, SIGNAL(currentChanged(QWidget*) ) ); |
416 | 429 | ||
417 | for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { | 430 | for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { |
418 | qWarning("Widget is %s", (*it).name.latin1() ); | 431 | qWarning("Widget is %s", (*it).name.latin1() ); |
419 | addToTab( (*it) ); | 432 | addToTab( (*it) ); |
420 | } | 433 | } |
421 | 434 | ||
422 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) | 435 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { |
436 | split->reparent(this, 0, QPoint(0, 0) ); | ||
423 | split->setTabWidget( tab ); | 437 | split->setTabWidget( tab ); |
438 | } | ||
424 | 439 | ||
425 | 440 | ||
426 | delete m_hbox; | 441 | delete m_hbox; |
427 | m_hbox = 0; | 442 | m_hbox = 0; |
428 | if (!m_tabWidget ) | 443 | if (!m_tabWidget ) |
429 | return; | 444 | return; |
430 | 445 | ||
431 | m_tabWidget->setGeometry( frameRect() ); | 446 | m_tabWidget->setGeometry( frameRect() ); |
432 | m_tabWidget->show(); | 447 | m_tabWidget->show(); |
433 | 448 | ||
434 | } | 449 | } |
435 | 450 | ||
436 | /* | 451 | /* |
437 | * changes over to a box | 452 | * changes over to a box |
438 | * this is recursive as well | 453 | * this is recursive as well |
439 | */ | 454 | */ |
440 | void OSplitter::changeHBox() { | 455 | void OSplitter::changeHBox() { |
441 | if (m_hbox ) { | 456 | if (m_hbox ) { |
442 | m_hbox->setGeometry( frameRect() ); | 457 | m_hbox->setGeometry( frameRect() ); |
443 | return; | 458 | return; |
444 | } | 459 | } |
445 | 460 | ||
446 | qWarning("new HBox"); | 461 | qWarning("new HBox %s", name() ); |
447 | m_hbox = new QHBox( this ); | 462 | m_hbox = new QHBox( this ); |
448 | commonChangeBox(); | 463 | commonChangeBox(); |
449 | } | 464 | } |
450 | 465 | ||
451 | void OSplitter::changeVBox() { | 466 | void OSplitter::changeVBox() { |
452 | if (m_hbox ) { | 467 | if (m_hbox ) { |
453 | m_hbox->setGeometry( frameRect() ); | 468 | m_hbox->setGeometry( frameRect() ); |
454 | return; | 469 | return; |
455 | } | 470 | } |
456 | 471 | ||
457 | qWarning("New VBOX"); | 472 | qWarning("New VBOX %s", name() ); |
458 | m_hbox = new QVBox( this ); | 473 | m_hbox = new QVBox( this ); |
459 | 474 | ||
460 | commonChangeBox(); | 475 | commonChangeBox(); |
461 | 476 | ||
462 | } | 477 | } |
463 | 478 | ||
464 | /* | 479 | /* |
465 | * common box code | 480 | * common box code |
466 | * first remove and add children | 481 | * first remove and add children |
467 | * the other splitters | 482 | * the other splitters |
468 | * it is recursive as well due the call to setTabWidget | 483 | * it is recursive as well due the call to setTabWidget |
469 | */ | 484 | */ |
470 | void OSplitter::commonChangeBox() { | 485 | void OSplitter::commonChangeBox() { |
486 | qWarning(" Name of Splitters is %s", name() ); | ||
471 | 487 | ||
472 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { | 488 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { |
473 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ | 489 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ |
474 | if (m_parentTab ) | 490 | if (m_parentTab ) |
475 | removeFromTab( (*it).widget ); | 491 | removeFromTab( (*it).widget ); |
476 | qWarning("Adding to box %s", (*it).name.latin1() ); | 492 | qWarning("Adding to box %s", (*it).name.latin1() ); |
477 | addToBox( (*it) ); | 493 | addToBox( (*it) ); |
478 | } | 494 | } |
479 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { | 495 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { |
480 | /* tell them the world had changed */ | 496 | /* tell them the world had changed */ |
481 | split->setTabWidget( 0 ); | 497 | split->setTabWidget( 0 ); |
482 | Opie::OSplitterContainer con; | 498 | Opie::OSplitterContainer con; |
483 | con.widget = split; | 499 | con.widget = split; |
500 | // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) | ||
501 | // : static_cast<QWidget*>(split->m_hbox); | ||
484 | addToBox( con ); | 502 | addToBox( con ); |
485 | } | 503 | } |
486 | 504 | ||
487 | 505 | ||
488 | 506 | ||
489 | if (m_parentTab ) | 507 | if (m_parentTab ) |
490 | m_parentTab->addTab(this, iconName(), label() ); | 508 | m_parentTab->addTab(m_hbox, iconName(), label() ); |
491 | else { | 509 | else { |
510 | qWarning(" setting Box geometry for %s", name() ); | ||
492 | m_hbox->setGeometry( frameRect() ); | 511 | m_hbox->setGeometry( frameRect() ); |
493 | m_hbox->show(); | 512 | m_hbox->show(); |
494 | delete m_tabWidget; | 513 | delete m_tabWidget; |
495 | m_tabWidget = 0; | 514 | m_tabWidget = 0; |
496 | } | 515 | } |
497 | } | 516 | } |
498 | 517 | ||
499 | /* | 518 | /* |
500 | * sets the tabwidget, removes tabs, and relayouts the widget | 519 | * sets the tabwidget, removes tabs, and relayouts the widget |
501 | */ | 520 | */ |
502 | void OSplitter::setTabWidget( OTabWidget* wid) { | 521 | void OSplitter::setTabWidget( OTabWidget* wid) { |
503 | /* clean up cause m_parentTab will not be available for us */ | 522 | /* clean up cause m_parentTab will not be available for us */ |
504 | if ( m_parentTab ) { | 523 | if ( m_parentTab ) { |
505 | if (m_hbox ) | 524 | if (m_hbox ) |
506 | m_parentTab->removePage( this ); | 525 | m_parentTab->removePage( m_hbox ); |
507 | else if (!m_container.isEmpty() ){ | 526 | else if (!m_container.isEmpty() ){ |
508 | ContainerList::Iterator it = m_container.begin(); | 527 | ContainerList::Iterator it = m_container.begin(); |
509 | for ( ; it != m_container.end(); ++it ) | 528 | for ( ; it != m_container.end(); ++it ) |
510 | m_parentTab->removePage( (*it).widget ); | 529 | m_parentTab->removePage( (*it).widget ); |
511 | } | 530 | } |
512 | } | 531 | } |
513 | /* the parent Splitter changed so either make us indepent or dep */ | 532 | /* the parent Splitter changed so either make us indepent or dep */ |
514 | 533 | ||
515 | m_parentTab = wid; | 534 | m_parentTab = wid; |
516 | 535 | ||
517 | QWidget *tab = m_tabWidget; | 536 | QWidget *tab = m_tabWidget; |
518 | QWidget *box = m_hbox; | 537 | QWidget *box = m_hbox; |
519 | m_hbox = 0; m_tabWidget = 0; | 538 | m_hbox = 0; m_tabWidget = 0; |
520 | 539 | ||
521 | if ( layoutMode() ) | 540 | if ( layoutMode() ) |
522 | changeTab(); | 541 | changeTab(); |
523 | else if (m_orient == Horizontal ) | 542 | else if (m_orient == Horizontal ) |
524 | changeHBox(); | 543 | changeHBox(); |
525 | else | 544 | else |
526 | changeVBox(); | 545 | changeVBox(); |
527 | 546 | ||
528 | /* our own crap is added and children from change* */ | 547 | /* our own crap is added and children from change* */ |
529 | delete tab; | 548 | if (m_parentTab ) { |
530 | delete box; | 549 | delete tab; |
550 | delete box; | ||
551 | } | ||
531 | } | 552 | } |
532 | 553 | ||
533 | 554 | ||
534 | #if 0 | 555 | #if 0 |
535 | void OSplitter::reparentAll() { | 556 | void OSplitter::reparentAll() { |
536 | if (m_container.isEmpty() ) | 557 | if (m_container.isEmpty() ) |
537 | return; | 558 | return; |
538 | 559 | ||
539 | ContainerList::Iterator it = m_container.begin(); | 560 | ContainerList::Iterator it = m_container.begin(); |
540 | for ( ; it != m_container.end(); ++it ) | 561 | for ( ; it != m_container.end(); ++it ) |
541 | (*it).wid->reparent(0, 0, QPoint(0, 0) ); | 562 | (*it).wid->reparent(0, 0, QPoint(0, 0) ); |
542 | 563 | ||
543 | 564 | ||
544 | } | 565 | } |
545 | #endif | 566 | #endif |
546 | 567 | ||
547 | /** | 568 | /** |
548 | * @internal | 569 | * @internal |
549 | */ | 570 | */ |
550 | bool OSplitter::layoutMode()const { | 571 | bool OSplitter::layoutMode()const { |
551 | if ( size().width() > m_size_policy && | 572 | if ( size().width() > m_size_policy && |
552 | m_orient == Horizontal ) { | 573 | m_orient == Horizontal ) { |
553 | return false; | 574 | return false; |
554 | }else if ( size().height() > m_size_policy && | 575 | }else if ( size().height() > m_size_policy && |
555 | m_size_policy == Vertical ) { | 576 | m_orient == Vertical ) { |
556 | return false; | 577 | return false; |
557 | } | 578 | } |
558 | 579 | ||
559 | return true; | 580 | return true; |
560 | } | 581 | } |
diff --git a/libopie/big-screen/osplitter.h b/libopie/big-screen/osplitter.h index 2bcde57..33a085f 100644 --- a/libopie/big-screen/osplitter.h +++ b/libopie/big-screen/osplitter.h | |||
@@ -1,139 +1,145 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OPIE_SPLITTER_H | 29 | #ifndef OPIE_SPLITTER_H |
30 | #define OPIE_SPLITTER_H | 30 | #define OPIE_SPLITTER_H |
31 | 31 | ||
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | 33 | ||
34 | #include <qframe.h> | 34 | #include <qframe.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | #include <qlist.h> | 36 | #include <qlist.h> |
37 | 37 | ||
38 | #include "obigscreen_p.h" | 38 | #include "obigscreen_p.h" |
39 | 39 | ||
40 | /* forward declarations */ | 40 | /* forward declarations */ |
41 | class OTabWidget; | 41 | class OTabWidget; |
42 | class QHBox; | 42 | class QHBox; |
43 | //template class QValueList<Opie::OSplitterContainer>; | 43 | //template class QValueList<Opie::OSplitterContainer>; |
44 | 44 | ||
45 | /* | ||
46 | * TODO | ||
47 | * -check API docu | ||
48 | * -one more example | ||
49 | * -allow inserting at a position | ||
50 | */ | ||
45 | 51 | ||
46 | /** | 52 | /** |
47 | * | 53 | * |
48 | * If you've widgets that could be placed side by side but you think | 54 | * If you've widgets that could be placed side by side but you think |
49 | * on small resolutions is not enough place but it would really make sense | 55 | * on small resolutions is not enough place but it would really make sense |
50 | * on bigger resolutions this class will help you. | 56 | * on bigger resolutions this class will help you. |
51 | * You can add as many widgets you want to it. Set a poliy on which width/height it | 57 | * You can add as many widgets you want to it. Set a poliy on which width/height it |
52 | * should switch the layout. | 58 | * should switch the layout. |
53 | * You can either say to place widgets vertical or horizontal. | 59 | * You can either say to place widgets vertical or horizontal. |
54 | * This class uses QHBox, QVBox and QTAbWidget internally. | 60 | * This class uses QHBox, QVBox and QTAbWidget internally. |
55 | * OSplitter takes ownership of the widgets | 61 | * OSplitter takes ownership of the widgets |
56 | * | 62 | * |
57 | * @since 1.2 | 63 | * @since 1.2 |
58 | * | 64 | * |
59 | * @short a small dynamically changing its layout to store two or more widgets side by side | 65 | * @short a small dynamically changing its layout to store two or more widgets side by side |
60 | * @version 0.1 | 66 | * @version 0.1 |
61 | * @author zecke | 67 | * @author zecke |
62 | */ | 68 | */ |
63 | class OSplitter : public QFrame{ | 69 | class OSplitter : public QFrame{ |
64 | Q_OBJECT | 70 | Q_OBJECT |
65 | public: | 71 | public: |
66 | typedef QValueList<Opie::OSplitterContainer> ContainerList; | 72 | typedef QValueList<Opie::OSplitterContainer> ContainerList; |
67 | OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, | 73 | OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, |
68 | const char* name = 0, WFlags fl = 0 ); | 74 | const char* name = 0, WFlags fl = 0 ); |
69 | ~OSplitter(); | 75 | ~OSplitter(); |
70 | 76 | ||
71 | void setLabel( const QString& name ); | 77 | void setLabel( const QString& name ); |
72 | void setIconName( const QString& name ); | 78 | void setIconName( const QString& name ); |
73 | QString label()const; | 79 | QString label()const; |
74 | QString iconName()const; | 80 | QString iconName()const; |
75 | 81 | ||
76 | void setSizeChange( int width_height ); | 82 | void setSizeChange( int width_height ); |
77 | 83 | ||
78 | void addWidget( OSplitter* splitter ); | 84 | void addWidget( OSplitter* splitter ); |
79 | void addWidget( QWidget* wid, const QString& icon, const QString& label ); | 85 | void addWidget( QWidget* wid, const QString& icon, const QString& label ); |
80 | void removeWidget( QWidget* ); | 86 | void removeWidget( QWidget* ); |
81 | void removeWidget( OSplitter* ); | 87 | void removeWidget( OSplitter* ); |
82 | 88 | ||
83 | void setCurrentWidget( QWidget* ); | 89 | void setCurrentWidget( QWidget* ); |
84 | void setCurrentWidget( const QString& label ); | 90 | void setCurrentWidget( const QString& label ); |
85 | void setCurrentWidget( int ); | 91 | void setCurrentWidget( int ); |
86 | QWidget* currentWidget()const; | 92 | QWidget* currentWidget()const; |
87 | 93 | ||
88 | signals: | 94 | signals: |
89 | /** | 95 | /** |
90 | * Emitted if in tab and comes directly from the tab widget | 96 | * Emitted if in tab and comes directly from the tab widget |
91 | * | 97 | * |
92 | */ | 98 | */ |
93 | void currentChanged( QWidget* ); | 99 | void currentChanged( QWidget* ); |
94 | 100 | ||
95 | /** | 101 | /** |
96 | * emitted whenever a border is crossed | 102 | * emitted whenever a border is crossed |
97 | * true if in small screen mode | 103 | * true if in small screen mode |
98 | * false if in bigscreen | 104 | * false if in bigscreen |
99 | * this signal is emitted after the layout switch | 105 | * this signal is emitted after the layout switch |
100 | * @param b The layout mode | 106 | * @param b The layout mode |
101 | * @param ori The orientation | 107 | * @param ori The orientation |
102 | */ | 108 | */ |
103 | void sizeChanged( bool b, Orientation ori); | 109 | void sizeChanged( bool b, Orientation ori); |
104 | public: | 110 | public: |
105 | // QSize sizeHint()const; | 111 | QSize sizeHint()const; |
106 | // QSize minimumSizeHint()const; | 112 | QSize minimumSizeHint()const; |
107 | 113 | ||
108 | protected: | 114 | protected: |
109 | void resizeEvent( QResizeEvent* ); | 115 | void resizeEvent( QResizeEvent* ); |
110 | 116 | ||
111 | private: | 117 | private: |
112 | /* true if OTabMode */ | 118 | /* true if OTabMode */ |
113 | bool layoutMode()const; | 119 | bool layoutMode()const; |
114 | // void reparentAll(); | 120 | // void reparentAll(); |
115 | void setTabWidget( OTabWidget*); | 121 | void setTabWidget( OTabWidget*); |
116 | void addToTab( const Opie::OSplitterContainer& ); | 122 | void addToTab( const Opie::OSplitterContainer& ); |
117 | void addToBox( const Opie::OSplitterContainer& ); | 123 | void addToBox( const Opie::OSplitterContainer& ); |
118 | void removeFromTab( QWidget* ); | 124 | void removeFromTab( QWidget* ); |
119 | void changeTab(); | 125 | void changeTab(); |
120 | void changeHBox(); | 126 | void changeHBox(); |
121 | void changeVBox(); | 127 | void changeVBox(); |
122 | void commonChangeBox(); | 128 | void commonChangeBox(); |
123 | QHBox *m_hbox; | 129 | QHBox *m_hbox; |
124 | OTabWidget *m_tabWidget; | 130 | OTabWidget *m_tabWidget; |
125 | OTabWidget *m_parentTab; | 131 | OTabWidget *m_parentTab; |
126 | Orientation m_orient; | 132 | Orientation m_orient; |
127 | int m_size_policy; | 133 | int m_size_policy; |
128 | 134 | ||
129 | ContainerList m_container; | 135 | ContainerList m_container; |
130 | QList<OSplitter> m_splitter; | 136 | QList<OSplitter> m_splitter; |
131 | 137 | ||
132 | QString m_icon, m_name; | 138 | QString m_icon, m_name; |
133 | 139 | ||
134 | struct Private; | 140 | struct Private; |
135 | Private *d; | 141 | Private *d; |
136 | }; | 142 | }; |
137 | 143 | ||
138 | 144 | ||
139 | #endif | 145 | #endif |