summaryrefslogtreecommitdiff
authorzecke <zecke>2003-10-07 12:56:18 (UTC)
committer zecke <zecke>2003-10-07 12:56:18 (UTC)
commit6f807f937764d0b80d38cd5e29983ad4ec2ae3c8 (patch) (unidiff)
treea1fc0bf579e5dfa0b07813110e998d4ea97d5c78
parent898d453b417e561cea25f6b7578814d31cec6e97 (diff)
downloadopie-6f807f937764d0b80d38cd5e29983ad4ec2ae3c8.zip
opie-6f807f937764d0b80d38cd5e29983ad4ec2ae3c8.tar.gz
opie-6f807f937764d0b80d38cd5e29983ad4ec2ae3c8.tar.bz2
Just a small example on usage of an Event Filter...
I needed that for debugging but it looks useful as an example
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/big-screen/example/osplitter_mail.cpp12
-rw-r--r--libopie/big-screen/example/osplitter_mail.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/libopie/big-screen/example/osplitter_mail.cpp b/libopie/big-screen/example/osplitter_mail.cpp
index 91442c8..4eaf3a9 100644
--- a/libopie/big-screen/example/osplitter_mail.cpp
+++ b/libopie/big-screen/example/osplitter_mail.cpp
@@ -1,70 +1,82 @@
1 1
2#include <qstring.h> 2#include <qstring.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qheader.h> 4#include <qheader.h>
5#include <qlayout.h> 5#include <qlayout.h>
6 6
7#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8#include <opie/oapplicationfactory.h> 8#include <opie/oapplicationfactory.h>
9 9
10#include "../osplitter.h" 10#include "../osplitter.h"
11 11
12#include "osplitter_mail.h" 12#include "osplitter_mail.h"
13 13
14 14
15OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) 15OPIE_EXPORT_APP( OApplicationFactory<ListViews> )
16 16
17class Folder { 17class Folder {
18 int dummy; 18 int dummy;
19}; 19};
20 20
21// ----------------------------------------------------------------- 21// -----------------------------------------------------------------
22 22
23ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) 23ListViews::ListViews( QWidget* p, const char* name, WFlags fl )
24 : QWidget( p, name, fl ) { 24 : QWidget( p, name, fl ) {
25 qApp->installEventFilter( this );
25 m_lstFolders.setAutoDelete( true ); 26 m_lstFolders.setAutoDelete( true );
26 QHBoxLayout *lay = new QHBoxLayout(this); 27 QHBoxLayout *lay = new QHBoxLayout(this);
27 28
28 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" ); 29 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" );
29 lay->addWidget( m_splitter ); 30 lay->addWidget( m_splitter );
30 connect(m_splitter, SIGNAL(sizeChange(bool, const QSize& ) ), 31 connect(m_splitter, SIGNAL(sizeChange(bool, const QSize& ) ),
31 this, SLOT(slotSizeChange(bool, const QSize& ) ) ); 32 this, SLOT(slotSizeChange(bool, const QSize& ) ) );
32 33
33 m_overview = new QListView( m_splitter ); 34 m_overview = new QListView( m_splitter );
34 m_overview->header()->setClickEnabled( FALSE ); 35 m_overview->header()->setClickEnabled( FALSE );
35 m_overview->addColumn( tr("Folder") ); 36 m_overview->addColumn( tr("Folder") );
36 m_overview->setMaximumWidth( 200 ); 37 m_overview->setMaximumWidth( 200 );
37 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") ); 38 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") );
38 m_splitter->setSizeChange( 300 ); 39 m_splitter->setSizeChange( 300 );
39 40
40 /* OSplitter starts with the small mode */ 41 /* OSplitter starts with the small mode */
41 m_messages = 0; 42 m_messages = 0;
42 m_message = m_attach = 0; 43 m_message = m_attach = 0;
43 44
44 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" ); 45 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" );
45 splitti->setSizeChange( 300 ); 46 splitti->setSizeChange( 300 );
46 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); 47 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
47 48
48 QLabel *lbl = new QLabel(splitti); 49 QLabel *lbl = new QLabel(splitti);
49 lbl->setTextFormat ( Qt::RichText ); 50 lbl->setTextFormat ( Qt::RichText );
50 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>"); 51 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>");
51 52
52 m_messages = new QListView( splitti ); 53 m_messages = new QListView( splitti );
53 m_messages->addColumn(" Messages "); 54 m_messages->addColumn(" Messages ");
54 55
55 folder1 = new QListView( splitti ); 56 folder1 = new QListView( splitti );
56 folder1->addColumn( "Messages 2 " ); 57 folder1->addColumn( "Messages 2 " );
57 58
58 splitti->addWidget(m_messages, "mail", tr("Mails") ); 59 splitti->addWidget(m_messages, "mail", tr("Mails") );
59 splitti->addWidget(folder1, "folder", tr("Folder") ); 60 splitti->addWidget(folder1, "folder", tr("Folder") );
60 splitti->addWidget( lbl, "logo", tr("Label") ); 61 splitti->addWidget( lbl, "logo", tr("Label") );
61 m_message = lbl; 62 m_message = lbl;
62 63
63 m_splitter->addWidget( splitti ); 64 m_splitter->addWidget( splitti );
64 65
65} 66}
66 67
67 68
68ListViews::~ListViews() { 69ListViews::~ListViews() {
69 70
70} 71}
72
73
74bool ListViews::eventFilter( QObject* obj, QEvent* ev ) {
75 if (!obj->isWidgetType() )
76 return false;
77 if ( ev->type() == QEvent::MouseButtonRelease ) {
78 qWarning(" name %s, class %s", obj->name(), obj->className() );
79 }
80
81 return false;
82}
diff --git a/libopie/big-screen/example/osplitter_mail.h b/libopie/big-screen/example/osplitter_mail.h
index d76f264..b7e7efe 100644
--- a/libopie/big-screen/example/osplitter_mail.h
+++ b/libopie/big-screen/example/osplitter_mail.h
@@ -4,45 +4,46 @@
4 4
5/* 5/*
6 * Header file for a more complete email client like 6 * Header file for a more complete email client like
7 * layout 7 * layout
8 */ 8 */
9 9
10#ifndef OPIE_SPLITTER_MAIL_EXAMPLE_H 10#ifndef OPIE_SPLITTER_MAIL_EXAMPLE_H
11#define OPIE_SPLITTER_MAIL_EXAMPLE_H 11#define OPIE_SPLITTER_MAIL_EXAMPLE_H
12 12
13#include <qwidget.h> 13#include <qwidget.h>
14#include <qlist.h> 14#include <qlist.h>
15#include <qlistview.h> 15#include <qlistview.h>
16 16
17class Folder; 17class Folder;
18class QLabel; 18class QLabel;
19 19
20class OSplitter; 20class OSplitter;
21class ListViews : public QWidget { 21class ListViews : public QWidget {
22 Q_OBJECT 22 Q_OBJECT
23public: 23public:
24 static QString appName() { return QString::fromLatin1("osplitter-mail"); } 24 static QString appName() { return QString::fromLatin1("osplitter-mail"); }
25 ListViews( QWidget* parent, const char * name, WFlags fl ); 25 ListViews( QWidget* parent, const char * name, WFlags fl );
26 ~ListViews(); 26 ~ListViews();
27 27
28 bool eventFilter( QObject* , QEvent* );
28private: 29private:
29 void initFolders(); 30 void initFolders();
30 void initFolder( Folder *folder, unsigned int &count ); 31 void initFolder( Folder *folder, unsigned int &count );
31 32
32 QListView *m_messages, *m_overview; 33 QListView *m_messages, *m_overview;
33 QLabel *m_message, *m_attach; 34 QLabel *m_message, *m_attach;
34 QList<QListView> m_folders; // used in tab mode 35 QList<QListView> m_folders; // used in tab mode
35 QList<Folder> m_lstFolders; 36 QList<Folder> m_lstFolders;
36 bool m_mode : 1; // bitfield 37 bool m_mode : 1; // bitfield
37 OSplitter *m_splitter; 38 OSplitter *m_splitter;
38 OSplitter *splitti; 39 OSplitter *splitti;
39 QListView *folder1; 40 QListView *folder1;
40#if 0 41#if 0
41//private slots: 42//private slots:
42// void slotFolderChanged( QListViewItem* ); 43// void slotFolderChanged( QListViewItem* );
43// void slotMessageChanged(); 44// void slotMessageChanged();
44// void slotSizeChange( bool, const QSize& ); 45// void slotSizeChange( bool, const QSize& );
45#endif 46#endif
46}; 47};
47 48
48#endif 49#endif