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

tablistview.h

Go to the documentation of this file.
00001 #ifndef TABLISTVIEW_H
00002 #define TABLISTVIEW_H
00003 
00004 /* OPIE */
00005 #include <opie2/odebug.h>
00006 
00007 /* QT */
00008 #include <qlistview.h>
00009 #include <qcursor.h>
00010 #include <qapplication.h>
00011 
00012 class TabListView : public QListView {
00013   Q_OBJECT
00014 
00015 signals:
00016   void moveItem(QListViewItem *item, QListViewItem *newFolder);
00017 
00018 public:
00019   TabListView( QWidget* parent = 0, const char* name = 0) : QListView(parent, name){ currentSelectedItem = NULL;
00020   connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *)));
00021   internalCursor.setShape(0);
00022   };
00023 
00024 protected:
00025   void contentsMouseReleaseEvent(QMouseEvent* ){
00026     QListViewItem *newGroup = this->currentItem();
00027   // Make sure they are both real.
00028   if (currentSelectedItem == NULL  || newGroup == NULL)
00029     return;
00030   // Make sure they are not the same
00031   if(this->isSelected(currentSelectedItem) == true)
00032     return;
00033 
00034   // Ok we have two valid items.
00035   if(newGroup->parent())
00036     newGroup = newGroup->parent();
00037 
00038   // Just in case the parent was null
00039   if(newGroup == NULL)
00040     return;
00041 
00042   // If the new folder and buddies current parent are the same don't do anything.
00043   if (newGroup != currentSelectedItem->parent())
00044     moveItem(currentSelectedItem, newGroup);
00045   currentSelectedItem = NULL;
00046   qApp->restoreOverrideCursor();
00047 };
00048 
00049 private slots:
00050   void itemPressed(QListViewItem *item){
00051   if(item == NULL || !item->parent()){
00052     if(item == NULL)
00053       odebug << "Item is NULL" << oendl;
00054     return;
00055   }
00056 
00057   currentSelectedItem = item;
00058   internalCursor.setShape(13);
00059   qApp->setOverrideCursor(internalCursor);
00060 };
00061 
00062 
00063 private:
00064   QListViewItem *currentSelectedItem;
00065   QCursor internalCursor;
00066 };
00067 
00068 #endif
00069 

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