Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
StringsListSelectionWidget.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 
22 #ifndef STRINGLISTSELECTIONWIDGET_H_
23 #define STRINGLISTSELECTIONWIDGET_H_
24 
25 #include <vector>
26 
27 #include "StringsListSelectionWidgetInterface.h"
28 
29 namespace tlp {
30 
31 /** \brief A widget for selecting a set of strings
32  *
33  * This widget allow to select a subset of strings from an initial input strings list.
34  * The look of the widget can be set via the ListType parameter :
35  * -> SIMPLE_LIST : the widget contains only one strings list, the selection of strings is done via the checkboxes located on the left of the items list
36  * -> DOUBLE_LIST : the widget contains two lists, the left one contains the unselected string list and the right one the selected strings list. To select
37  * a string (resp. unselect a string), it has to be moved from the list on the left to the list on the right (resp. from the list on the right to
38  * the list on the left) via the buttons located between the two lists or by drag'n drop.
39  */
40 class TLP_QT_SCOPE StringsListSelectionWidget: public QWidget,
41  public StringsListSelectionWidgetInterface {
42 
43 public:
44 
45  enum ListType {
46  SIMPLE_LIST, DOUBLE_LIST
47  };
48 
49  /**
50  * Default constructor (for qt designer)
51  * \param parent the widget's parent
52  * \param listType this parameter defines the widget's look (see class description)
53  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no size restriction)
54  */
55  StringsListSelectionWidget(QWidget *parent = NULL, const ListType listType =
56  DOUBLE_LIST, const unsigned int maxSelectedStringsListSize = 0);
57 
58  /**
59  * This constructor creates the widget and initializes the unselected strings list
60  * \param unselectedStringsList a vector containing the set of strings that can be selected
61  * \param parent the widget's parent
62  * \param listType this parameter defines the widget's look (see class description)
63  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no size restriction)
64  */
65  StringsListSelectionWidget(
66  const std::vector<std::string> &unselectedStringsList,
67  QWidget *parent = NULL, const ListType listType = DOUBLE_LIST,
68  const unsigned int maxSelectedStringsListSize = 0);
69 
70  /**
71  * Method which sets the look of the widget
72  * \param listType this parameter defines the widget's look (see class description)
73  */
74  void setListType(const ListType listType);
75 
76  /**
77  * Method which sets the unselected strings list
78  * \param unselectedStringsList a vector containing a set of strings to be unselected
79  */
80  void setUnselectedStringsList(
81  const std::vector<std::string> &unselectedStringsList);
82 
83  /**
84  * Method which sets the selected strings list
85  * \param selectedStringsList a vector containing a set of strings to be selected
86  */
87  void setSelectedStringsList(
88  const std::vector<std::string> &selectedStringsList);
89 
90  /**
91  * Method which empty the unselected strings list
92  */
93  void clearUnselectedStringsList();
94 
95  /**
96  * Method which empty the selected strings list
97  */
98  void clearSelectedStringsList();
99 
100  /**
101  * Method which sets the label text value of the unselected strings list
102  * (this method does nothing if listType = SIMPLE_LIST)
103  */
104  void setUnselectedStringsListLabel(
105  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(
112  const std::string &selectedStringsListLabel);
113 
114  /**
115  * Method which sets the maximum size of the selected strings list
116  */
117  void setMaxSelectedStringsListSize(
118  const unsigned int maxSelectedStringsListSize);
119 
120  /**
121  * Method which returns the selected strings as a vector
122  */
123  std::vector<std::string> getSelectedStringsList() const;
124 
125  /**
126  * Method which returns the unselected strings as a vector
127  */
128  std::vector<std::string> getUnselectedStringsList() const;
129 
130  /**
131  * Method which returns both of the selected and unselected strings as a vector
132  */
133  std::vector<std::string> getCompleteStringsList() const;
134 
135  /**
136  * Method which selects all strings
137  */
138  void selectAllStrings();
139 
140  /**
141  * Method which unselect all strings
142  */
143  void unselectAllStrings();
144 
145 private:
146 
147  ListType listType;
148  StringsListSelectionWidgetInterface *stringsListSelectionWidget;
149 
150 };
151 
152 }
153 
154 #endif /* STRINGLISTSELECTIONWIDGET_H_ */
155 ///@endcond