Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
ItemsListWidget.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef ITEMSDIALOGLIST_H
22#define ITEMSDIALOGLIST_H
23
24#ifndef DOXYGEN_NOTFOR_DEVEL
25
26#include <tulip/tulipconf.h>
27
28#include <QListWidget>
29
30namespace tlp {
31
32struct itemInfo {
33 QString attribut;
34 bool choice;
35};
36
37// A Custom List Widget which supports drag and drop
38class TLP_QT_SCOPE ItemsListWidget : public QListWidget {
39
40 Q_OBJECT
41
42public:
43 ItemsListWidget(QWidget *parent = nullptr, const unsigned int maxListSize = 0);
44
45 // Method which adds an item in the list
46 // return true if the item has been added, false if the maximum size of the list is already
47 // reached
48 bool addItemList(QString item);
49
50 void deleteItemList(QListWidgetItem *item);
51
52 // Method which sets the maximum size of the list
53 // if 0, there is no size restriction
54 void setMaxListSize(const unsigned int maxListSize) {
55 this->maxListSize = maxListSize;
56 }
57 unsigned int getMaxListSize() const {
58 return maxListSize;
59 }
60
61protected:
62 void mousePressEvent(QMouseEvent *event) override;
63 void mouseMoveEvent(QMouseEvent *event) override;
64 void dragEnterEvent(QDragEnterEvent *event) override;
65 void dragMoveEvent(QDragMoveEvent *event) override;
66 void dropEvent(QDropEvent *event) override;
67
68private:
69 void beginDrag(QListWidgetItem *item);
70 void changeStatus(QListWidgetItem *item);
71 void dragMoveOrEnterEvent(QDragMoveEvent *event);
72 QPoint startPos;
73 QHash<QString, itemInfo> hashDataBase;
74 unsigned int maxListSize;
75};
76} // namespace tlp
77
78#endif // DOXYGEN_NOTFOR_DEVEL
79
80#endif
81
82///@endcond