-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 | |||
@@ -78,2 +78,3 @@ OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFl | |||
78 | OSplitter::~OSplitter() { | 78 | OSplitter::~OSplitter() { |
79 | qWarning("Deleted Splitter"); | ||
79 | m_splitter.setAutoDelete( true ); | 80 | m_splitter.setAutoDelete( true ); |
@@ -156,3 +157,3 @@ void OSplitter::addWidget( OSplitter* split ) { | |||
156 | if (m_tabWidget ) | 157 | if (m_tabWidget ) |
157 | split->setTabWidget( m_tabWidget ); | 158 | setTabWidget( m_parentTab ); |
158 | else{ | 159 | else{ |
@@ -308,3 +309,3 @@ QWidget* OSplitter::currentWidget() const{ | |||
308 | 309 | ||
309 | #if 0 | 310 | |
310 | /** | 311 | /** |
@@ -314,3 +315,4 @@ QWidget* OSplitter::currentWidget() const{ | |||
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 | ||
@@ -323,5 +325,10 @@ QSize OSplitter::sizeHint()const { | |||
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 | ||
@@ -337,3 +344,3 @@ void OSplitter::resizeEvent( QResizeEvent* res ) { | |||
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 && |
@@ -348,3 +355,4 @@ void OSplitter::resizeEvent( QResizeEvent* res ) { | |||
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(); |
@@ -400,3 +408,3 @@ void OSplitter::changeTab() { | |||
400 | 408 | ||
401 | qWarning(" New Tab Widget "); | 409 | qWarning(" New Tab Widget %s", name() ); |
402 | /* | 410 | /* |
@@ -409,3 +417,8 @@ void OSplitter::changeTab() { | |||
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 |
@@ -421,4 +434,6 @@ void OSplitter::changeTab() { | |||
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 | ||
@@ -445,3 +460,3 @@ void OSplitter::changeHBox() { | |||
445 | 460 | ||
446 | qWarning("new HBox"); | 461 | qWarning("new HBox %s", name() ); |
447 | m_hbox = new QHBox( this ); | 462 | m_hbox = new QHBox( this ); |
@@ -456,3 +471,3 @@ void OSplitter::changeVBox() { | |||
456 | 471 | ||
457 | qWarning("New VBOX"); | 472 | qWarning("New VBOX %s", name() ); |
458 | m_hbox = new QVBox( this ); | 473 | m_hbox = new QVBox( this ); |
@@ -470,2 +485,3 @@ void OSplitter::changeVBox() { | |||
470 | void OSplitter::commonChangeBox() { | 485 | void OSplitter::commonChangeBox() { |
486 | qWarning(" Name of Splitters is %s", name() ); | ||
471 | 487 | ||
@@ -483,2 +499,4 @@ void OSplitter::commonChangeBox() { | |||
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 ); |
@@ -489,4 +507,5 @@ void OSplitter::commonChangeBox() { | |||
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() ); |
@@ -505,3 +524,3 @@ void OSplitter::setTabWidget( OTabWidget* wid) { | |||
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() ){ |
@@ -528,4 +547,6 @@ void OSplitter::setTabWidget( OTabWidget* wid) { | |||
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 | } |
@@ -554,3 +575,3 @@ bool OSplitter::layoutMode()const { | |||
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; |
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 | |||
@@ -44,2 +44,8 @@ class QHBox; | |||
44 | 44 | ||
45 | /* | ||
46 | * TODO | ||
47 | * -check API docu | ||
48 | * -one more example | ||
49 | * -allow inserting at a position | ||
50 | */ | ||
45 | 51 | ||
@@ -104,4 +110,4 @@ signals: | |||
104 | public: | 110 | public: |
105 | // QSize sizeHint()const; | 111 | QSize sizeHint()const; |
106 | // QSize minimumSizeHint()const; | 112 | QSize minimumSizeHint()const; |
107 | 113 | ||