Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/ItemsListWidget.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef ITEMSDIALOGLIST_H
00022 #define ITEMSDIALOGLIST_H
00023 
00024 #ifndef DOXYGEN_NOTFOR_DEVEL
00025 
00026 #include <tulip/tulipconf.h>
00027 
00028 #include <QListWidget>
00029 
00030 namespace tlp {
00031 
00032 struct itemInfo {
00033   QString attribut;
00034   bool choice;
00035 };
00036 
00037 // A Custom List Widget which supports drag and drop
00038 class TLP_QT_SCOPE ItemsListWidget : public QListWidget {
00039 
00040   Q_OBJECT
00041 
00042 public:
00043 
00044   ItemsListWidget(QWidget *parent = NULL, const unsigned int maxListSize = 0);
00045 
00046   // Method which adds an item in the list
00047   // return true if the item has been added, false if the maximum size of the list is already reached
00048   bool addItemList(QString item);
00049 
00050   void deleteItemList(QListWidgetItem *item);
00051 
00052   // Method which sets the maximum size of the list
00053   // if 0, there is no size restriction
00054   void setMaxListSize(const unsigned int maxListSize) {
00055     this->maxListSize = maxListSize;
00056   }
00057   unsigned int getMaxListSize() const {
00058     return maxListSize;
00059   }
00060 
00061 protected:
00062 
00063   void mousePressEvent(QMouseEvent *event);
00064   void mouseMoveEvent(QMouseEvent *event);
00065   void dragEnterEvent(QDragEnterEvent *event);
00066   void dragMoveEvent(QDragMoveEvent *event);
00067   void dropEvent(QDropEvent *event);
00068 
00069 private:
00070 
00071   void beginDrag(QListWidgetItem *item);
00072   void changeStatus(QListWidgetItem *item);
00073   void dragMoveOrEnterEvent(QDragMoveEvent *event);
00074   QPoint startPos;
00075   QHash<QString,itemInfo> hashDataBase;
00076   unsigned int maxListSize;
00077 };
00078 
00079 }
00080 
00081 #endif // DOXYGEN_NOTFOR_DEVEL
00082 
00083 #endif
00084 
00085 
00086 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties