Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
StringsListSelectionWidget.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 STRINGLISTSELECTIONWIDGET_H_
22#define STRINGLISTSELECTIONWIDGET_H_
23
24#include <vector>
25
26#include <tulip/StringsListSelectionWidgetInterface.h>
27
28#include <QWidget>
29
30namespace tlp {
31
32/** \brief A widget for selecting a set of strings
33 *
34 * This widget allow to select and reorder a subset of strings from an initial input strings list.
35 * The look of the widget can be set via the ListType parameter :
36 * -> SIMPLE_LIST : the widget contains only one strings list, the selection of strings is done
37 * via the checkboxes located on the left of the items list
38 * -> DOUBLE_LIST : the widget contains two lists, the left one contains the non selected strings
39 * list and the right one the selected strings list. To select
40 * a string (resp. deselect a string), it has to be moved from the list on the
41 * left to the list on the right (resp. from the list on the right to
42 * the list on the left) via the buttons located between the two lists or by
43 * drag'n drop.
44 * -> NON_ORDERABLE_LIST : same as SIMPLE_LIST but strings cannot be reodered
45 */
46class TLP_QT_SCOPE StringsListSelectionWidget : public QWidget,
47 public StringsListSelectionWidgetInterface {
48
49public:
50 enum ListType { SIMPLE_LIST, DOUBLE_LIST, NON_ORDERABLE_LIST };
51
52 /**
53 * Default constructor (for qt designer)
54 * \param parent the widget's parent
55 * \param listType this parameter defines the widget's look (see class description)
56 * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no
57 * size restriction)
58 */
59 StringsListSelectionWidget(QWidget *parent = nullptr, const ListType listType = DOUBLE_LIST,
60 const unsigned int maxSelectedStringsListSize = 0);
61
62 /**
63 * This constructor creates the widget and initializes the unselected strings list
64 * \param unselectedStringsList a vector containing the set of strings that can be selected
65 * \param parent the widget's parent
66 * \param listType this parameter defines the widget's look (see class description)
67 * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no
68 * size restriction)
69 */
70 StringsListSelectionWidget(const std::vector<std::string> &unselectedStringsList,
71 QWidget *parent = nullptr, const ListType listType = DOUBLE_LIST,
72 const unsigned int maxSelectedStringsListSize = 0);
73
74 /**
75 * Method which sets the look of the widget
76 * \param listType this parameter defines the widget's look (see class description)
77 */
78 void setListType(const ListType listType);
79
80 /**
81 * Method which sets the unselected strings list
82 * \param unselectedStringsList a vector containing a set of strings to be unselected
83 */
84 void setUnselectedStringsList(const std::vector<std::string> &unselectedStringsList) override;
85
86 /**
87 * Method which sets the selected strings list
88 * \param selectedStringsList a vector containing a set of strings to be selected
89 */
90 void setSelectedStringsList(const std::vector<std::string> &selectedStringsList) override;
91
92 /**
93 * Method which empty the unselected strings list
94 */
95 void clearUnselectedStringsList() override;
96
97 /**
98 * Method which empty the selected strings list
99 */
100 void clearSelectedStringsList() override;
101
102 /**
103 * Method which sets the label text value of the unselected strings list
104 * (this method does nothing if listType = SIMPLE_LIST)
105 */
106 void setUnselectedStringsListLabel(const std::string &unselectedStringsListLabel);
107
108 /**
109 * Method which sets the label text value of the selected strings list
110 * (this method does nothing if listType = SIMPLE_LIST)
111 */
112 void setSelectedStringsListLabel(const std::string &selectedStringsListLabel);
113
114 /**
115 * Method which sets the maximum size of the selected strings list
116 */
117 void setMaxSelectedStringsListSize(const unsigned int maxSelectedStringsListSize) override;
118
119 /**
120 * Method which returns the selected strings as a vector
121 */
122 std::vector<std::string> getSelectedStringsList() const override;
123
124 /**
125 * Method which returns the unselected strings as a vector
126 */
127 std::vector<std::string> getUnselectedStringsList() const override;
128
129 /**
130 * Method which returns both of the selected and unselected strings as a vector
131 */
132 std::vector<std::string> getCompleteStringsList() const;
133
134 /**
135 * Method which selects all strings
136 */
137 void selectAllStrings() override;
138
139 /**
140 * Method which deselect all strings
141 */
142 void unselectAllStrings() override;
143
144private:
145 ListType listType;
146 StringsListSelectionWidgetInterface *stringsListSelectionWidget;
147};
148} // namespace tlp
149
150#endif /* STRINGLISTSELECTIONWIDGET_H_ */
151///@endcond