author | zecke <zecke> | 2003-10-07 12:56:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-07 12:56:18 (UTC) |
commit | 6f807f937764d0b80d38cd5e29983ad4ec2ae3c8 (patch) (unidiff) | |
tree | a1fc0bf579e5dfa0b07813110e998d4ea97d5c78 | |
parent | 898d453b417e561cea25f6b7578814d31cec6e97 (diff) | |
download | opie-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
-rw-r--r-- | libopie/big-screen/example/osplitter_mail.cpp | 12 | ||||
-rw-r--r-- | libopie/big-screen/example/osplitter_mail.h | 1 |
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 | |||
@@ -13,24 +13,25 @@ | |||
13 | 13 | ||
14 | 14 | ||
15 | OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) | 15 | OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) |
16 | 16 | ||
17 | class Folder { | 17 | class Folder { |
18 | int dummy; | 18 | int dummy; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | // ----------------------------------------------------------------- | 21 | // ----------------------------------------------------------------- |
22 | 22 | ||
23 | ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) | 23 | ListViews::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 ); |
@@ -59,12 +60,23 @@ ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) | |||
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 | ||
68 | ListViews::~ListViews() { | 69 | ListViews::~ListViews() { |
69 | 70 | ||
70 | } | 71 | } |
72 | |||
73 | |||
74 | bool 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 | |||
@@ -16,24 +16,25 @@ | |||
16 | 16 | ||
17 | class Folder; | 17 | class Folder; |
18 | class QLabel; | 18 | class QLabel; |
19 | 19 | ||
20 | class OSplitter; | 20 | class OSplitter; |
21 | class ListViews : public QWidget { | 21 | class ListViews : public QWidget { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
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* ); | ||
28 | private: | 29 | private: |
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; |