Tulip  5.2.1
Large graphs analysis and drawing
StringsListSelectionWidget.h
1 /*
2  *
3  * This file is part of Tulip (http://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 
30 namespace tlp {
31 
32 /** \brief A widget for selecting a set of strings
33  *
34  * This widget allow to select 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 unselected string
39  * list and the right one the selected strings list. To select
40  * a string (resp. unselect 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  */
45 class TLP_QT_SCOPE StringsListSelectionWidget : public QWidget,
46  public StringsListSelectionWidgetInterface {
47 
48 public:
49  enum ListType { SIMPLE_LIST, DOUBLE_LIST };
50 
51  /**
52  * Default constructor (for qt designer)
53  * \param parent the widget's parent
54  * \param listType this parameter defines the widget's look (see class description)
55  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no
56  * size restriction)
57  */
58  StringsListSelectionWidget(QWidget *parent = nullptr, const ListType listType = DOUBLE_LIST,
59  const unsigned int maxSelectedStringsListSize = 0);
60 
61  /**
62  * This constructor creates the widget and initializes the unselected strings list
63  * \param unselectedStringsList a vector containing the set of strings that can be selected
64  * \param parent the widget's parent
65  * \param listType this parameter defines the widget's look (see class description)
66  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no
67  * size restriction)
68  */
69  StringsListSelectionWidget(const std::vector<std::string> &unselectedStringsList,
70  QWidget *parent = nullptr, const ListType listType = DOUBLE_LIST,
71  const unsigned int maxSelectedStringsListSize = 0);
72 
73  /**
74  * Method which sets the look of the widget
75  * \param listType this parameter defines the widget's look (see class description)
76  */
77  void setListType(const ListType listType);
78 
79  /**
80  * Method which sets the unselected strings list
81  * \param unselectedStringsList a vector containing a set of strings to be unselected
82  */
83  void setUnselectedStringsList(const std::vector<std::string> &unselectedStringsList) override;
84 
85  /**
86  * Method which sets the selected strings list
87  * \param selectedStringsList a vector containing a set of strings to be selected
88  */
89  void setSelectedStringsList(const std::vector<std::string> &selectedStringsList) override;
90 
91  /**
92  * Method which empty the unselected strings list
93  */
94  void clearUnselectedStringsList() override;
95 
96  /**
97  * Method which empty the selected strings list
98  */
99  void clearSelectedStringsList() override;
100 
101  /**
102  * Method which sets the label text value of the unselected strings list
103  * (this method does nothing if listType = SIMPLE_LIST)
104  */
105  void setUnselectedStringsListLabel(const std::string &unselectedStringsListLabel);
106 
107  /**
108  * Method which sets the label text value of the selected strings list
109  * (this method does nothing if listType = SIMPLE_LIST)
110  */
111  void setSelectedStringsListLabel(const std::string &selectedStringsListLabel);
112 
113  /**
114  * Method which sets the maximum size of the selected strings list
115  */
116  void setMaxSelectedStringsListSize(const unsigned int maxSelectedStringsListSize) override;
117 
118  /**
119  * Method which returns the selected strings as a vector
120  */
121  std::vector<std::string> getSelectedStringsList() const override;
122 
123  /**
124  * Method which returns the unselected strings as a vector
125  */
126  std::vector<std::string> getUnselectedStringsList() const override;
127 
128  /**
129  * Method which returns both of the selected and unselected strings as a vector
130  */
131  std::vector<std::string> getCompleteStringsList() const;
132 
133  /**
134  * Method which selects all strings
135  */
136  void selectAllStrings() override;
137 
138  /**
139  * Method which unselect all strings
140  */
141  void unselectAllStrings() override;
142 
143 private:
144  ListType listType;
145  StringsListSelectionWidgetInterface *stringsListSelectionWidget;
146 };
147 } // namespace tlp
148 
149 #endif /* STRINGLISTSELECTIONWIDGET_H_ */
150 ///@endcond