author | zecke <zecke> | 2003-10-07 12:56:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-07 12:56:18 (UTC) |
commit | 6f807f937764d0b80d38cd5e29983ad4ec2ae3c8 (patch) (side-by-side diff) | |
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 @@ -9,32 +9,33 @@ #include "../osplitter.h" #include "osplitter_mail.h" OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) class Folder { int dummy; }; // ----------------------------------------------------------------- ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) : QWidget( p, name, fl ) { + qApp->installEventFilter( this ); m_lstFolders.setAutoDelete( true ); QHBoxLayout *lay = new QHBoxLayout(this); m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" ); lay->addWidget( m_splitter ); connect(m_splitter, SIGNAL(sizeChange(bool, const QSize& ) ), this, SLOT(slotSizeChange(bool, const QSize& ) ) ); m_overview = new QListView( m_splitter ); m_overview->header()->setClickEnabled( FALSE ); m_overview->addColumn( tr("Folder") ); m_overview->setMaximumWidth( 200 ); m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") ); m_splitter->setSizeChange( 300 ); /* OSplitter starts with the small mode */ @@ -55,16 +56,27 @@ ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) folder1 = new QListView( splitti ); folder1->addColumn( "Messages 2 " ); splitti->addWidget(m_messages, "mail", tr("Mails") ); splitti->addWidget(folder1, "folder", tr("Folder") ); splitti->addWidget( lbl, "logo", tr("Label") ); m_message = lbl; m_splitter->addWidget( splitti ); } ListViews::~ListViews() { } + + +bool ListViews::eventFilter( QObject* obj, QEvent* ev ) { + if (!obj->isWidgetType() ) + return false; + if ( ev->type() == QEvent::MouseButtonRelease ) { + qWarning(" name %s, class %s", obj->name(), obj->className() ); + } + + return false; +} 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 @@ -12,32 +12,33 @@ #include <qwidget.h> #include <qlist.h> #include <qlistview.h> class Folder; class QLabel; class OSplitter; class ListViews : public QWidget { Q_OBJECT public: static QString appName() { return QString::fromLatin1("osplitter-mail"); } ListViews( QWidget* parent, const char * name, WFlags fl ); ~ListViews(); + bool eventFilter( QObject* , QEvent* ); private: void initFolders(); void initFolder( Folder *folder, unsigned int &count ); QListView *m_messages, *m_overview; QLabel *m_message, *m_attach; QList<QListView> m_folders; // used in tab mode QList<Folder> m_lstFolders; bool m_mode : 1; // bitfield OSplitter *m_splitter; OSplitter *splitti; QListView *folder1; #if 0 //private slots: // void slotFolderChanged( QListViewItem* ); // void slotMessageChanged(); |