Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces 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 <tulip/StringsListSelectionWidgetInterface.h>
28 
29 #include <QWidget>
30 
31 namespace tlp {
32 
33 /** \brief A widget for selecting a set of strings
34  *
35  * This widget allow to select a subset of strings from an initial input strings list.
36  * The look of the widget can be set via the ListType parameter :
37  * -> 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
38  * -> 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
39  * 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
40  * the list on the left) via the buttons located between the two lists or by drag'n drop.
41  */
42 class TLP_QT_SCOPE StringsListSelectionWidget: public QWidget,
43  public StringsListSelectionWidgetInterface {
44 
45 public:
46 
47  enum ListType {
48  SIMPLE_LIST, DOUBLE_LIST
49  };
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 size restriction)
56  */
57  StringsListSelectionWidget(QWidget *parent = NULL, const ListType listType =
58  DOUBLE_LIST, const unsigned int maxSelectedStringsListSize = 0);
59 
60  /**
61  * This constructor creates the widget and initializes the unselected strings list
62  * \param unselectedStringsList a vector containing the set of strings that can be selected
63  * \param parent the widget's parent
64  * \param listType this parameter defines the widget's look (see class description)
65  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no size restriction)
66  */
67  StringsListSelectionWidget(
68  const std::vector<std::string> &unselectedStringsList,
69  QWidget *parent = NULL, const ListType listType = DOUBLE_LIST,
70  const unsigned int maxSelectedStringsListSize = 0);
71 
72  /**
73  * Method which sets the look of the widget
74  * \param listType this parameter defines the widget's look (see class description)
75  */
76  void setListType(const ListType listType);
77 
78  /**
79  * Method which sets the unselected strings list
80  * \param unselectedStringsList a vector containing a set of strings to be unselected
81  */
82  void setUnselectedStringsList(
83  const std::vector<std::string> &unselectedStringsList);
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(
90  const std::vector<std::string> &selectedStringsList);
91 
92  /**
93  * Method which empty the unselected strings list
94  */
95  void clearUnselectedStringsList();
96 
97  /**
98  * Method which empty the selected strings list
99  */
100  void clearSelectedStringsList();
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(
107  const std::string &unselectedStringsListLabel);
108 
109  /**
110  * Method which sets the label text value of the selected strings list
111  * (this method does nothing if listType = SIMPLE_LIST)
112  */
113  void setSelectedStringsListLabel(
114  const std::string &selectedStringsListLabel);
115 
116  /**
117  * Method which sets the maximum size of the selected strings list
118  */
119  void setMaxSelectedStringsListSize(
120  const unsigned int maxSelectedStringsListSize);
121 
122  /**
123  * Method which returns the selected strings as a vector
124  */
125  std::vector<std::string> getSelectedStringsList() const;
126 
127  /**
128  * Method which returns the unselected strings as a vector
129  */
130  std::vector<std::string> getUnselectedStringsList() const;
131 
132  /**
133  * Method which returns both of the selected and unselected strings as a vector
134  */
135  std::vector<std::string> getCompleteStringsList() const;
136 
137  /**
138  * Method which selects all strings
139  */
140  void selectAllStrings();
141 
142  /**
143  * Method which unselect all strings
144  */
145  void unselectAllStrings();
146 
147 private:
148 
149  ListType listType;
150  StringsListSelectionWidgetInterface *stringsListSelectionWidget;
151 
152 };
153 
154 }
155 
156 #endif /* STRINGLISTSELECTIONWIDGET_H_ */
157 ///@endcond