Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

listviewplus.cpp

Go to the documentation of this file.
00001 #include <qpopupmenu.h>
00002 #include <qtimer.h>
00003 
00004 #include "listviewplus.h"
00005 
00006 ListViewPlus::ListViewPlus(QWidget *parent, const char *name, WFlags fl)
00007         : QListView(parent, name, fl)
00008 {
00009 
00010 }
00011 
00012 void ListViewPlus::keyPressEvent(QKeyEvent *event)
00013 {
00014         switch(event->key()) {
00015                 case Qt::Key_Space:             // FALLTHROUGH
00016                 case Qt::Key_Enter:
00017                         if (currentItem() != 0)
00018                                 emit clicked(currentItem());
00019                         break;
00020                 default: break;
00021         }
00022 
00023         QListView::keyPressEvent(event);
00024 }
00025 
00026 void ListViewPlus::setPopup(QPopupMenu *popup, int delay)
00027 {
00028         _popup = popup;
00029         _delay = delay;
00030 
00031         connect(this, SIGNAL(pressed(QListViewItem*,const QPoint&,int)), SLOT(_initPopup(QListViewItem*,const QPoint&,int)));
00032         connect(this, SIGNAL(clicked(QListViewItem*,const QPoint&,int)), SLOT(_cancelPopup(QListViewItem*,const QPoint&,int)));
00033 }
00034 
00035 void ListViewPlus::_initPopup(QListViewItem *, const QPoint &point, int)
00036 {
00037         _point = point;
00038 
00039         _timer = new QTimer();
00040         _timer->start(_delay, true);
00041 
00042         connect(_timer, SIGNAL(timeout()), this, SLOT(_showPopup()));
00043 }
00044 
00045 void ListViewPlus::_cancelPopup(QListViewItem *, const QPoint &, int)
00046 {
00047         delete _timer;
00048 }
00049 
00050 void ListViewPlus::_showPopup()
00051 {
00052         _popup->popup(_point);
00053 }
00054 

Generated on Sat Nov 5 16:18:08 2005 for OPIE by  doxygen 1.4.2