Diffstat (limited to 'libopie2/opieui/big-screen/osplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/big-screen/osplitter.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp index 89f3793..bcfd3a6 100644 --- a/libopie2/opieui/big-screen/osplitter.cpp +++ b/libopie2/opieui/big-screen/osplitter.cpp | |||
@@ -14,49 +14,50 @@ | |||
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 "osplitter.h" | 29 | #include "osplitter.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <opie2/otabwidget.h> | 32 | #include <opie2/otabwidget.h> |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | #include <qvbox.h> | 36 | #include <qvbox.h> |
37 | 37 | ||
38 | using namespace Opie; | 38 | using namespace Opie::Ui; |
39 | using namespace Opie::Ui::Private; | ||
39 | 40 | ||
40 | /** | 41 | /** |
41 | * | 42 | * |
42 | * This is the constructor of OSplitter | 43 | * This is the constructor of OSplitter |
43 | * You might want to call setSizeChange to tell | 44 | * You might want to call setSizeChange to tell |
44 | * OSplitter to change its layout when a specefic | 45 | * OSplitter to change its layout when a specefic |
45 | * mark was crossed. OSplitter sets a default value. | 46 | * mark was crossed. OSplitter sets a default value. |
46 | * | 47 | * |
47 | * You cann add widget with addWidget to the OSplitter. | 48 | * You cann add widget with addWidget to the OSplitter. |
48 | * OSplitter supports also grouping of Splitters where they | 49 | * OSplitter supports also grouping of Splitters where they |
49 | * can share one OTabBar in small screen mode. This can be used | 50 | * can share one OTabBar in small screen mode. This can be used |
50 | * for email clients like vies but see the example. | 51 | * for email clients like vies but see the example. |
51 | * | 52 | * |
52 | * @param orient The orientation wether to layout horizontal or vertical | 53 | * @param orient The orientation wether to layout horizontal or vertical |
53 | * @param parent The parent of this widget | 54 | * @param parent The parent of this widget |
54 | * @param name The name passed on to QObject | 55 | * @param name The name passed on to QObject |
55 | * @param fl Additional widgets flags passed to QWidget | 56 | * @param fl Additional widgets flags passed to QWidget |
56 | * | 57 | * |
57 | * @short single c'tor of the OSplitter | 58 | * @short single c'tor of the OSplitter |
58 | */ | 59 | */ |
59 | OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) | 60 | OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) |
60 | : QFrame( parent, name, fl ) | 61 | : QFrame( parent, name, fl ) |
61 | { | 62 | { |
62 | m_orient = orient; | 63 | m_orient = orient; |
@@ -147,94 +148,94 @@ QString OSplitter::label()const | |||
147 | void OSplitter::setSizeChange( int width_height ) | 148 | void OSplitter::setSizeChange( int width_height ) |
148 | { | 149 | { |
149 | m_size_policy = width_height; | 150 | m_size_policy = width_height; |
150 | QSize sz(width(), height() ); | 151 | QSize sz(width(), height() ); |
151 | QResizeEvent ev(sz, sz ); | 152 | QResizeEvent ev(sz, sz ); |
152 | resizeEvent(&ev); | 153 | resizeEvent(&ev); |
153 | } | 154 | } |
154 | 155 | ||
155 | /** | 156 | /** |
156 | * This functions allows to add another OSplitter and to share | 157 | * This functions allows to add another OSplitter and to share |
157 | * the OTabBar in small screen mode. The ownerships gets transfered. | 158 | * the OTabBar in small screen mode. The ownerships gets transfered. |
158 | * OSplitters are always added after normal widget items | 159 | * OSplitters are always added after normal widget items |
159 | */ | 160 | */ |
160 | void OSplitter::addWidget( OSplitter* split ) | 161 | void OSplitter::addWidget( OSplitter* split ) |
161 | { | 162 | { |
162 | m_splitter.append( split ); | 163 | m_splitter.append( split ); |
163 | 164 | ||
164 | /* | 165 | /* |
165 | * set tab widget | 166 | * set tab widget |
166 | */ | 167 | */ |
167 | if (m_tabWidget ) | 168 | if (m_tabWidget ) |
168 | setTabWidget( m_parentTab ); | 169 | setTabWidget( m_parentTab ); |
169 | else | 170 | else |
170 | { | 171 | { |
171 | Opie::OSplitterContainer con; | 172 | OSplitterContainer con; |
172 | con.widget =split; | 173 | con.widget =split; |
173 | addToBox( con ); | 174 | addToBox( con ); |
174 | } | 175 | } |
175 | } | 176 | } |
176 | 177 | ||
177 | /* | 178 | /* |
178 | * If in a tab it should be removed | 179 | * If in a tab it should be removed |
179 | * and if in a hbox the reparent kills it too | 180 | * and if in a hbox the reparent kills it too |
180 | */ | 181 | */ |
181 | /** | 182 | /** |
182 | * This removes the splitter again. You currently need to call this | 183 | * This removes the splitter again. You currently need to call this |
183 | * before you delete or otherwise you can get mem corruption | 184 | * before you delete or otherwise you can get mem corruption |
184 | * or other weird behaviour. | 185 | * or other weird behaviour. |
185 | * Owner ship gets transfered back to you it's current parent | 186 | * Owner ship gets transfered back to you it's current parent |
186 | * is 0 | 187 | * is 0 |
187 | */ | 188 | */ |
188 | void OSplitter::removeWidget( OSplitter* split) | 189 | void OSplitter::removeWidget( OSplitter* split) |
189 | { | 190 | { |
190 | split->setTabWidget( 0 ); | 191 | split->setTabWidget( 0 ); |
191 | split->reparent( 0, 0, QPoint(0, 0) ); | 192 | split->reparent( 0, 0, QPoint(0, 0) ); |
192 | } | 193 | } |
193 | 194 | ||
194 | /** | 195 | /** |
195 | * Adds a widget to the Splitter. The widgets gets inserted | 196 | * Adds a widget to the Splitter. The widgets gets inserted |
196 | * at the end of either the Box or TabWidget. | 197 | * at the end of either the Box or TabWidget. |
197 | * Ownership gets transfered and the widgets gets reparented. | 198 | * Ownership gets transfered and the widgets gets reparented. |
198 | * Note: icon and label is only available on small screensizes | 199 | * Note: icon and label is only available on small screensizes |
199 | * if size is smaller than the mark | 200 | * if size is smaller than the mark |
200 | * Warning: No null checking of the widget is done. Only on debug | 201 | * Warning: No null checking of the widget is done. Only on debug |
201 | * a message will be outputtet | 202 | * a message will be outputtet |
202 | * | 203 | * |
203 | * @param wid The widget which will be added | 204 | * @param wid The widget which will be added |
204 | * @param icon The icon of the possible Tab | 205 | * @param icon The icon of the possible Tab |
205 | * @param label The label of the possible Tab | 206 | * @param label The label of the possible Tab |
206 | */ | 207 | */ |
207 | void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) | 208 | void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) |
208 | { | 209 | { |
209 | #ifdef DEBUG | 210 | #ifdef DEBUG |
210 | if (!wid ) | 211 | if (!wid ) |
211 | { | 212 | { |
212 | qWarning("Widget is not valid!"); | 213 | qWarning("Widget is not valid!"); |
213 | return; | 214 | return; |
214 | } | 215 | } |
215 | #endif | 216 | #endif |
216 | Opie::OSplitterContainer cont; | 217 | OSplitterContainer cont; |
217 | cont.widget = wid; | 218 | cont.widget = wid; |
218 | cont.icon =icon; | 219 | cont.icon =icon; |
219 | cont.name = label; | 220 | cont.name = label; |
220 | 221 | ||
221 | m_container.append( cont ); | 222 | m_container.append( cont ); |
222 | 223 | ||
223 | /* | 224 | /* |
224 | * | 225 | * |
225 | */ | 226 | */ |
226 | if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) | 227 | if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) |
227 | setTabWidget( m_parentTab ); | 228 | setTabWidget( m_parentTab ); |
228 | else | 229 | else |
229 | { | 230 | { |
230 | if (m_hbox ) | 231 | if (m_hbox ) |
231 | addToBox( cont ); | 232 | addToBox( cont ); |
232 | else | 233 | else |
233 | addToTab( cont ); | 234 | addToTab( cont ); |
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
237 | 238 | ||
238 | /** | 239 | /** |
239 | * Removes the widget from the tab widgets if necessary. | 240 | * Removes the widget from the tab widgets if necessary. |
240 | * OSplitter drops ownership of this widget and the widget | 241 | * OSplitter drops ownership of this widget and the widget |
@@ -375,63 +376,63 @@ void OSplitter::resizeEvent( QResizeEvent* res ) | |||
375 | mode = false; | 376 | mode = false; |
376 | } | 377 | } |
377 | else if ( (res->size().width() <= m_size_policy && | 378 | else if ( (res->size().width() <= m_size_policy && |
378 | m_orient == Horizontal ) || | 379 | m_orient == Horizontal ) || |
379 | (res->size().height() <= m_size_policy && | 380 | (res->size().height() <= m_size_policy && |
380 | m_orient == Vertical ) ) | 381 | m_orient == Vertical ) ) |
381 | { | 382 | { |
382 | changeTab(); | 383 | changeTab(); |
383 | } | 384 | } |
384 | else if ( res->size().height() > m_size_policy && | 385 | else if ( res->size().height() > m_size_policy && |
385 | m_orient == Vertical ) | 386 | m_orient == Vertical ) |
386 | { | 387 | { |
387 | qWarning("Changng to vbox %s", name() ); | 388 | qWarning("Changng to vbox %s", name() ); |
388 | changeVBox(); | 389 | changeVBox(); |
389 | mode = false; | 390 | mode = false; |
390 | } | 391 | } |
391 | 392 | ||
392 | emit sizeChanged(mode, m_orient ); | 393 | emit sizeChanged(mode, m_orient ); |
393 | } | 394 | } |
394 | 395 | ||
395 | /* | 396 | /* |
396 | * Adds a container to a tab either the parent tab | 397 | * Adds a container to a tab either the parent tab |
397 | * or our own | 398 | * or our own |
398 | */ | 399 | */ |
399 | void OSplitter::addToTab( const Opie::OSplitterContainer& con ) | 400 | void OSplitter::addToTab( const Opie::Ui::Private::OSplitterContainer& con ) |
400 | { | 401 | { |
401 | QWidget *wid = con.widget; | 402 | QWidget *wid = con.widget; |
402 | // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); | 403 | // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); |
403 | if (m_parentTab ) | 404 | if (m_parentTab ) |
404 | m_parentTab->addTab( wid, con.icon, con.name ); | 405 | m_parentTab->addTab( wid, con.icon, con.name ); |
405 | else | 406 | else |
406 | m_tabWidget->addTab( wid, con.icon, con.name ); | 407 | m_tabWidget->addTab( wid, con.icon, con.name ); |
407 | } | 408 | } |
408 | 409 | ||
409 | 410 | ||
410 | /* | 411 | /* |
411 | * adds a container to the box | 412 | * adds a container to the box |
412 | */ | 413 | */ |
413 | void OSplitter::addToBox( const Opie::OSplitterContainer& con ) | 414 | void OSplitter::addToBox( const Opie::Ui::Private::OSplitterContainer& con ) |
414 | { | 415 | { |
415 | QWidget* wid = con.widget; | 416 | QWidget* wid = con.widget; |
416 | wid->reparent(m_hbox, 0, QPoint(0, 0) ); | 417 | wid->reparent(m_hbox, 0, QPoint(0, 0) ); |
417 | } | 418 | } |
418 | 419 | ||
419 | 420 | ||
420 | /* | 421 | /* |
421 | * Removes a widget from the tab | 422 | * Removes a widget from the tab |
422 | */ | 423 | */ |
423 | void OSplitter::removeFromTab( QWidget* wid ) | 424 | void OSplitter::removeFromTab( QWidget* wid ) |
424 | { | 425 | { |
425 | if (m_parentTab ) | 426 | if (m_parentTab ) |
426 | m_parentTab->removePage( wid ); | 427 | m_parentTab->removePage( wid ); |
427 | else | 428 | else |
428 | m_tabWidget->removePage( wid ); | 429 | m_tabWidget->removePage( wid ); |
429 | } | 430 | } |
430 | 431 | ||
431 | /* | 432 | /* |
432 | * switches over to a OTabWidget layout | 433 | * switches over to a OTabWidget layout |
433 | * it is recursive | 434 | * it is recursive |
434 | */ | 435 | */ |
435 | void OSplitter::changeTab() | 436 | void OSplitter::changeTab() |
436 | { | 437 | { |
437 | /* if we're the owner of the tab widget */ | 438 | /* if we're the owner of the tab widget */ |
@@ -524,49 +525,49 @@ void OSplitter::changeVBox() | |||
524 | } | 525 | } |
525 | 526 | ||
526 | /* | 527 | /* |
527 | * common box code | 528 | * common box code |
528 | * first remove and add children | 529 | * first remove and add children |
529 | * the other splitters | 530 | * the other splitters |
530 | * it is recursive as well due the call to setTabWidget | 531 | * it is recursive as well due the call to setTabWidget |
531 | */ | 532 | */ |
532 | void OSplitter::commonChangeBox() | 533 | void OSplitter::commonChangeBox() |
533 | { | 534 | { |
534 | qWarning(" Name of Splitters is %s", name() ); | 535 | qWarning(" Name of Splitters is %s", name() ); |
535 | 536 | ||
536 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) | 537 | for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) |
537 | { | 538 | { |
538 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ | 539 | /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ |
539 | if (m_parentTab ) | 540 | if (m_parentTab ) |
540 | removeFromTab( (*it).widget ); | 541 | removeFromTab( (*it).widget ); |
541 | qWarning("Adding to box %s", (*it).name.latin1() ); | 542 | qWarning("Adding to box %s", (*it).name.latin1() ); |
542 | addToBox( (*it) ); | 543 | addToBox( (*it) ); |
543 | } | 544 | } |
544 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) | 545 | for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) |
545 | { | 546 | { |
546 | /* tell them the world had changed */ | 547 | /* tell them the world had changed */ |
547 | split->setTabWidget( 0 ); | 548 | split->setTabWidget( 0 ); |
548 | Opie::OSplitterContainer con; | 549 | OSplitterContainer con; |
549 | con.widget = split; | 550 | con.widget = split; |
550 | // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) | 551 | // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) |
551 | // : static_cast<QWidget*>(split->m_hbox); | 552 | // : static_cast<QWidget*>(split->m_hbox); |
552 | addToBox( con ); | 553 | addToBox( con ); |
553 | } | 554 | } |
554 | 555 | ||
555 | 556 | ||
556 | 557 | ||
557 | if (m_parentTab ) | 558 | if (m_parentTab ) |
558 | m_parentTab->addTab(m_hbox, iconName(), label() ); | 559 | m_parentTab->addTab(m_hbox, iconName(), label() ); |
559 | else | 560 | else |
560 | { | 561 | { |
561 | qWarning(" setting Box geometry for %s", name() ); | 562 | qWarning(" setting Box geometry for %s", name() ); |
562 | m_hbox->setGeometry( frameRect() ); | 563 | m_hbox->setGeometry( frameRect() ); |
563 | m_hbox->show(); | 564 | m_hbox->show(); |
564 | delete m_tabWidget; | 565 | delete m_tabWidget; |
565 | m_tabWidget = 0; | 566 | m_tabWidget = 0; |
566 | show(); // also show this widget | 567 | show(); // also show this widget |
567 | } | 568 | } |
568 | } | 569 | } |
569 | 570 | ||
570 | /* | 571 | /* |
571 | * sets the tabwidget, removes tabs, and relayouts the widget | 572 | * sets the tabwidget, removes tabs, and relayouts the widget |
572 | */ | 573 | */ |