-rw-r--r-- | libopie/big-screen/example/osplitter_example.cpp | 28 | ||||
-rw-r--r-- | libopie/big-screen/example/osplitter_example.h | 20 | ||||
-rw-r--r-- | libopie/big-screen/example/osplitter_example.o | bin | 0 -> 17276 bytes | |||
-rw-r--r-- | libopie/big-screen/example/osplitter_example.pro | 13 | ||||
-rw-r--r-- | libopie/big-screen/obigscreen_p.h | 20 | ||||
-rw-r--r-- | libopie/big-screen/osplitter.cpp | 165 | ||||
-rw-r--r-- | libopie/big-screen/osplitter.h | 22 |
7 files changed, 228 insertions, 40 deletions
diff --git a/libopie/big-screen/example/osplitter_example.cpp b/libopie/big-screen/example/osplitter_example.cpp new file mode 100644 index 0000000..e337379 --- a/dev/null +++ b/libopie/big-screen/example/osplitter_example.cpp | |||
@@ -0,0 +1,28 @@ | |||
1 | #include <qdir.h> | ||
2 | #include <qlayout.h> | ||
3 | |||
4 | #include "../osplitter.h" | ||
5 | |||
6 | #include <qpe/qpeapplication.h> | ||
7 | #include <opie/oapplicationfactory.h> | ||
8 | |||
9 | #include "osplitter_example.h" | ||
10 | |||
11 | OPIE_EXPORT_APP( OApplicationFactory<OSplitterExample> ) | ||
12 | |||
13 | OSplitterExample::OSplitterExample( QWidget *w,const char* n,WFlags f ) | ||
14 | : QWidget( w, n, f ){ | ||
15 | QVBoxLayout * lay = new QVBoxLayout(this); | ||
16 | OSplitter * splitter = new OSplitter( Horizontal, this ); | ||
17 | lay->addWidget( splitter ); | ||
18 | |||
19 | OFileSelector *selector = new OFileSelector( splitter, OFileSelector::FileSelector, | ||
20 | OFileSelector::Normal, QDir::homeDirPath(), | ||
21 | QString::null ); | ||
22 | splitter->addWidget( selector, "zoom", tr("Selector 1") ); | ||
23 | |||
24 | selector = new OFileSelector( splitter, OFileSelector::FileSelector, OFileSelector::Normal, | ||
25 | QDir::homeDirPath(), QString::null ); | ||
26 | splitter->addWidget( selector, "zoom", tr("Selector 2") ); | ||
27 | |||
28 | } | ||
diff --git a/libopie/big-screen/example/osplitter_example.h b/libopie/big-screen/example/osplitter_example.h new file mode 100644 index 0000000..ae8f120 --- a/dev/null +++ b/libopie/big-screen/example/osplitter_example.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * May be used, copied and modified wihtout any limitation | ||
3 | */ | ||
4 | |||
5 | #ifndef OSPlitter_EXAMPLE_H | ||
6 | #define OSPlitter_EXAMPLE_H | ||
7 | |||
8 | #include <qvbox.h> | ||
9 | #include <opie/ofileselector.h> | ||
10 | |||
11 | class OSplitterExample : public QWidget { | ||
12 | Q_OBJECT | ||
13 | public: | ||
14 | static QString appName() { return QString::fromLatin1("osplitter_example"); } | ||
15 | OSplitterExample( QWidget *parent, const char* name, WFlags fl ); | ||
16 | |||
17 | }; | ||
18 | |||
19 | |||
20 | #endif | ||
diff --git a/libopie/big-screen/example/osplitter_example.o b/libopie/big-screen/example/osplitter_example.o new file mode 100644 index 0000000..e52d5d9 --- a/dev/null +++ b/libopie/big-screen/example/osplitter_example.o | |||
Binary files differ | |||
diff --git a/libopie/big-screen/example/osplitter_example.pro b/libopie/big-screen/example/osplitter_example.pro new file mode 100644 index 0000000..b12bf17 --- a/dev/null +++ b/libopie/big-screen/example/osplitter_example.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | CONFIG = qt warn_on | ||
2 | TEMPLATE = app | ||
3 | TARGET = osplitter_example | ||
4 | |||
5 | HEADERS = osplitter_example.h ../osplitter.h | ||
6 | SOURCES = osplitter_example.cpp ../osplitter.cpp | ||
7 | |||
8 | INCLUDEPATH += $(OPIEDIR)/include ../ | ||
9 | DEPENDSPATH += $(OPIEDIR)/include | ||
10 | |||
11 | LIBS += -lqpe -lopie | ||
12 | |||
13 | include ( $(OPIEDIR)/include.pro ) \ No newline at end of file | ||
diff --git a/libopie/big-screen/obigscreen_p.h b/libopie/big-screen/obigscreen_p.h new file mode 100644 index 0000000..ed256d9 --- a/dev/null +++ b/libopie/big-screen/obigscreen_p.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef OPIE_BIG_SCREEN_PRIVATE | ||
2 | #define OPIE_BIG_SCREEN_PRIVATE | ||
3 | |||
4 | namespace Opie { | ||
5 | |||
6 | struct OSplitterContainer { | ||
7 | bool operator==( const OSplitterContainer& o)const { | ||
8 | if (widget != o.widget ) return false; | ||
9 | if (icon != o.icon ) return false; | ||
10 | if (name != o.name ) return false; | ||
11 | return true; | ||
12 | } | ||
13 | QWidget* widget; | ||
14 | QString icon; | ||
15 | QString name; | ||
16 | }; | ||
17 | |||
18 | } | ||
19 | |||
20 | #endif | ||
diff --git a/libopie/big-screen/osplitter.cpp b/libopie/big-screen/osplitter.cpp index dcb5cc5..ce53ee1 100644 --- a/libopie/big-screen/osplitter.cpp +++ b/libopie/big-screen/osplitter.cpp | |||
@@ -35,11 +35,4 @@ | |||
35 | 35 | ||
36 | 36 | ||
37 | struct OSplitterContainer { | ||
38 | QWidget* widget; | ||
39 | const QString& icon | ||
40 | const QString& name; | ||
41 | }; | ||
42 | |||
43 | |||
44 | /** | 37 | /** |
45 | * | 38 | * |
@@ -59,10 +52,13 @@ struct OSplitterContainer { | |||
59 | */ | 52 | */ |
60 | OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) | 53 | OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) |
61 | : QWidget( parent, name, fl ) | 54 | : QFrame( parent, name, fl ) |
62 | { | 55 | { |
63 | m_orient = orient; | 56 | m_orient = orient; |
64 | m_hbox = 0; | 57 | m_hbox = 0; |
65 | m_tabWidget = 0; | ||
66 | m_size_policy = 330; | 58 | m_size_policy = 330; |
59 | setFontPropagation( AllChildren ); | ||
60 | setPalettePropagation( AllChildren ); | ||
61 | |||
62 | m_tabWidget = new OTabWidget(this); | ||
67 | } | 63 | } |
68 | 64 | ||
@@ -90,5 +86,7 @@ OSplitter::~OSplitter() { | |||
90 | void OSplitter::setSizeChange( int width_height ) { | 86 | void OSplitter::setSizeChange( int width_height ) { |
91 | m_size_policy = width_height; | 87 | m_size_policy = width_height; |
92 | relayout(); | 88 | QSize sz(width(), height() ); |
89 | QResizeEvent ev(sz, sz ); | ||
90 | resizeEvent(&ev); | ||
93 | } | 91 | } |
94 | 92 | ||
@@ -113,8 +111,8 @@ void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& lab | |||
113 | } | 111 | } |
114 | #endif | 112 | #endif |
115 | OSplitterContainer cont; | 113 | Opie::OSplitterContainer cont; |
116 | cont.widget = wid; | 114 | cont.widget = wid; |
117 | cont.icon =icon; | 115 | cont.icon =icon; |
118 | cont.label = label; | 116 | cont.name = label; |
119 | 117 | ||
120 | m_container.append( cont ); | 118 | m_container.append( cont ); |
@@ -128,6 +126,7 @@ void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& lab | |||
128 | 126 | ||
129 | /** | 127 | /** |
130 | * Removes the widget from the tab widgets. OSplitter drops ownership | 128 | * Removes the widget from the tab widgets if necessary. |
131 | * of this widget and the widget will be reparented to 0. | 129 | * OSplitter drops ownership of this widget and the widget |
130 | * will be reparented i tto 0. | ||
132 | * The widget will not be deleted. | 131 | * The widget will not be deleted. |
133 | * | 132 | * |
@@ -135,8 +134,13 @@ void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& lab | |||
135 | */ | 134 | */ |
136 | void OSplitter::removeWidget( QWidget* w) { | 135 | void OSplitter::removeWidget( QWidget* w) { |
137 | /* if not widget nor parent or parent not any of my master childs return */ | 136 | ContainerList::Iterator it; |
138 | if (!w && w->parent() && ( w->parent() != m_hbox || w->parent() != m_tabWidget ) ) | 137 | for ( it = m_container.begin(); it != m_container.end(); ++it ) |
138 | if ( (*it).widget == w ) | ||
139 | break; | ||
140 | |||
141 | if (it == m_container.end() ) | ||
139 | return; | 142 | return; |
140 | 143 | ||
144 | |||
141 | /* only tab needs to be removed.. box recognizes it */ | 145 | /* only tab needs to be removed.. box recognizes it */ |
142 | if ( !m_hbox ) | 146 | if ( !m_hbox ) |
@@ -144,13 +148,8 @@ void OSplitter::removeWidget( QWidget* w) { | |||
144 | 148 | ||
145 | 149 | ||
146 | /* Find the widget, reparent it and remove it from our list */ | 150 | /* Find reparent it and remove it from our list */ |
147 | ContainerList::Iterator it; | ||
148 | for ( it = m_container.begin(); it != m_container.end(); ++it ) | ||
149 | if ( (*it).widget == w ) { | ||
150 | w.reparent( 0, w.getWFlags ); | ||
151 | it = m_container.remove( it ); | ||
152 | break; | ||
153 | } | ||
154 | 151 | ||
152 | w->reparent( 0, 0, QPoint(0, 0)); | ||
153 | it = m_container.remove( it ); | ||
155 | 154 | ||
156 | } | 155 | } |
@@ -165,12 +164,13 @@ void OSplitter::removeWidget( QWidget* w) { | |||
165 | void OSplitter::setCurrentWidget( QWidget* w) { | 164 | void OSplitter::setCurrentWidget( QWidget* w) { |
166 | if (m_tabWidget ) | 165 | if (m_tabWidget ) |
167 | m_tabWidget->setCurrentWidget( w ); | 166 | m_tabWidget->setCurrentTab( w ); |
168 | else | 167 | // else |
169 | m_hbox->setFocus( w ); | 168 | // m_hbox->setFocus( w ); |
170 | 169 | ||
171 | } | 170 | } |
172 | 171 | ||
173 | /** | 172 | /** |
174 | * This is an overloaded member function and only differs in the argument it takes. | 173 | * This is an overloaded member function and only differs in the |
174 | * argument it takes. | ||
175 | * Searches list of widgets for label. It'll pick the first label it finds | 175 | * Searches list of widgets for label. It'll pick the first label it finds |
176 | * | 176 | * |
@@ -188,5 +188,5 @@ void OSplitter::setCurrentWidget( const QString& label ) { | |||
188 | 188 | ||
189 | /** | 189 | /** |
190 | * return the currently activated widget if in tab widget moud | 190 | * return the currently activated widget if in tab widget mode |
191 | * or null because all widgets are visible | 191 | * or null because all widgets are visible |
192 | */ | 192 | */ |
@@ -198,5 +198,5 @@ QWidget* OSplitter::currentWidget() { | |||
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | #if 0 | |
201 | /** | 201 | /** |
202 | * @reimplented for internal reasons | 202 | * @reimplented for internal reasons |
@@ -204,5 +204,10 @@ QWidget* OSplitter::currentWidget() { | |||
204 | */ | 204 | */ |
205 | QSize OSplitter::sizeHint()const { | 205 | QSize OSplitter::sizeHint()const { |
206 | if (m_hbox ) | ||
207 | return m_hbox->sizeHint(); | ||
208 | else | ||
209 | return m_tabWidget->sizeHint(); | ||
206 | } | 210 | } |
211 | #endif | ||
207 | 212 | ||
208 | /** | 213 | /** |
@@ -210,4 +215,104 @@ QSize OSplitter::sizeHint()const { | |||
210 | */ | 215 | */ |
211 | void OSplitter::resizeEvent( QResizeEvent* res ) { | 216 | void OSplitter::resizeEvent( QResizeEvent* res ) { |
217 | QFrame::resizeEvent( res ); | ||
218 | /* | ||
219 | * | ||
220 | */ | ||
221 | // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); | ||
222 | // qWarning("New size is width = %d height = %d", res->size().width(), res->size().height() ); | ||
223 | if ( res->size().width() > m_size_policy && | ||
224 | m_orient == Horizontal ) { | ||
225 | changeHBox(); | ||
226 | }else if ( (res->size().width() <= m_size_policy && | ||
227 | m_orient == Horizontal ) || | ||
228 | (res->size().height() <= m_size_policy && | ||
229 | m_orient == Vertical ) ) { | ||
230 | changeTab(); | ||
231 | }else if ( res->size().height() > m_size_policy && | ||
232 | m_size_policy == Vertical ) { | ||
233 | changeVBox(); | ||
234 | } | ||
235 | } | ||
212 | 236 | ||
237 | |||
238 | void OSplitter::addToTab( const Opie::OSplitterContainer& con ) { | ||
239 | QWidget *wid = con.widget; | ||
240 | // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); | ||
241 | m_tabWidget->addTab( wid, con.icon, con.name ); | ||
242 | } | ||
243 | |||
244 | void OSplitter::addToBox( const Opie::OSplitterContainer& con ) { | ||
245 | QWidget* wid = con.widget; | ||
246 | wid->reparent(m_hbox, 0, QPoint(0, 0) ); | ||
247 | } | ||
248 | |||
249 | void OSplitter::removeFromTab( QWidget* wid ) { | ||
250 | m_tabWidget->removePage( wid ); | ||
251 | } | ||
252 | |||
253 | void OSplitter::changeTab() { | ||
254 | if (m_tabWidget ) { | ||
255 | m_tabWidget->setGeometry( frameRect() ); | ||
256 | return; | ||
257 | } | ||
258 | |||
259 | qWarning(" New Tab Widget "); | ||
260 | /* | ||
261 | * and add all widgets this will reparent them | ||
262 | * delete m_hbox set it to 0 | ||
263 | * | ||
264 | */ | ||
265 | m_tabWidget = new OTabWidget( this ); | ||
266 | |||
267 | for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { | ||
268 | qWarning("Widget is %s", (*it).name.latin1() ); | ||
269 | addToTab( (*it) ); | ||
270 | } | ||
271 | |||
272 | delete m_hbox; | ||
273 | m_hbox = 0; | ||
274 | m_tabWidget->setGeometry( frameRect() ); | ||
275 | m_tabWidget->show(); | ||
276 | |||
277 | } | ||
278 | |||
279 | void OSplitter::changeHBox() { | ||
280 | if (m_hbox ) { | ||
281 | m_hbox->setGeometry( frameRect() ); | ||
282 | return; | ||
283 | } | ||
284 | |||
285 | qWarning("new HBox"); | ||
286 | m_hbox = new QHBox( this ); | ||
287 | commonChangeBox(); | ||
288 | delete m_tabWidget; | ||
289 | m_tabWidget = 0; | ||
290 | m_hbox->setGeometry( frameRect() ); | ||
291 | m_hbox->show(); | ||
292 | } | ||
293 | |||
294 | void OSplitter::changeVBox() { | ||
295 | if (m_hbox ) { | ||
296 | m_hbox->setGeometry( frameRect() ); | ||
297 | return; | ||
298 | } | ||
299 | |||
300 | qWarning("New VBOX"); | ||
301 | m_hbox = new QVBox( this ); | ||
302 | |||
303 | commonChangeBox(); | ||
304 | delete m_tabWidget; | ||
305 | m_tabWidget = 0; | ||
306 | m_hbox->setGeometry( frameRect() ); | ||
307 | m_hbox->show(); | ||
308 | } | ||
309 | |||
310 | |||
311 | void OSplitter::commonChangeBox() { | ||
312 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { | ||
313 | qWarning("Adding to box %s", (*it).name.latin1() ); | ||
314 | addToBox( (*it) ); | ||
315 | } | ||
316 | delete m_tabWidget; | ||
317 | m_tabWidget = 0; | ||
213 | } | 318 | } |
diff --git a/libopie/big-screen/osplitter.h b/libopie/big-screen/osplitter.h index 05849af..bc4f80b 100644 --- a/libopie/big-screen/osplitter.h +++ b/libopie/big-screen/osplitter.h | |||
@@ -32,13 +32,13 @@ | |||
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qframe.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include "obigscreen_p.h" | ||
37 | 38 | ||
38 | /* forward declarations */ | 39 | /* forward declarations */ |
39 | class OTabWidget; | 40 | class OTabWidget; |
40 | class QHBox; | 41 | class QHBox; |
41 | struct OSplitterContainer; | 42 | //template class QValueList<Opie::OSplitterContainer>; |
42 | template class QValueList<OSplitterContainer>; | ||
43 | 43 | ||
44 | 44 | ||
@@ -60,8 +60,8 @@ template class QValueList<OSplitterContainer>; | |||
60 | * @author zecke | 60 | * @author zecke |
61 | */ | 61 | */ |
62 | class OSplitter : public QWidget{ | 62 | class OSplitter : public QFrame{ |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | typedef QValueList<OSplitterContainer> ContainerList; | 65 | typedef QValueList<Opie::OSplitterContainer> ContainerList; |
66 | OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, | 66 | OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, |
67 | const char* name = 0, WFlags fl = 0 ); | 67 | const char* name = 0, WFlags fl = 0 ); |
@@ -77,5 +77,5 @@ public: | |||
77 | QWidget* currentWidget(); | 77 | QWidget* currentWidget(); |
78 | 78 | ||
79 | QSize sizeHint()const; | 79 | // QSize sizeHint()const; |
80 | 80 | ||
81 | protected: | 81 | protected: |
@@ -83,9 +83,11 @@ protected: | |||
83 | 83 | ||
84 | private: | 84 | private: |
85 | void relayout(); | 85 | void addToTab( const Opie::OSplitterContainer& ); |
86 | void addToTab( const OSplitterContainer& ); | 86 | void addToBox( const Opie::OSplitterContainer& ); |
87 | void addToBox( const OSplitterContainer& ); | ||
88 | void removeFromTab( QWidget* ); | 87 | void removeFromTab( QWidget* ); |
89 | void removeFromBox( QWidget* ); | 88 | void changeTab(); |
89 | void changeHBox(); | ||
90 | void changeVBox(); | ||
91 | void commonChangeBox(); | ||
90 | QHBox *m_hbox; | 92 | QHBox *m_hbox; |
91 | OTabWidget *m_tabWidget; | 93 | OTabWidget *m_tabWidget; |