Tulip  6.0.0
Large graphs analysis and drawing
StringsListSelectionDialog.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 STRINGSLISTSELECTIONDIALOG_H
22 #define STRINGSLISTSELECTIONDIALOG_H
23 
24 #include <QDialog>
25 
26 #include <tulip/tulipconf.h>
27 #include <tulip/StringsListSelectionWidget.h>
28 
29 namespace Ui {
30 class StringsListSelectionDialog;
31 }
32 
33 namespace tlp {
34 
35 /**
36  * @brief Provide a dialog that allow user to select a list of strings.
37  *
38  * The easiest way to use this class is to use the static function.
39  * @code
40  * QString title;
41  * QWidget* parent;
42  * vector<string> listOfStrings; // must be initialized
43  * vector<string> selectedStrings;
44  * bool choosen = StringsListSelectionDialog::choose(title, parent, listOfStrings,
45  *selectedStrings);
46  * @endcode
47  *
48  *
49  **/
50 class TLP_QT_SCOPE StringsListSelectionDialog : public QDialog {
51  Q_OBJECT
52 
53 public:
54  /**
55  * @brief Constructs a dialog with the given parent.
56  **/
57  explicit StringsListSelectionDialog(QWidget *parent = nullptr);
58 
59  /**
60  * set the look of the widget
61  * \param listType this parameter defines the widget's look (see class description)
62  */
63  void setListType(const StringsListSelectionWidget::ListType listType);
64 
65  /**
66  * sets the maximum size of the selected strings list
67  */
68  void setMaxSelectedStringsListSize(const unsigned int maxSize);
69 
70  /**
71  * sets the unselected and selected strings lists
72  */
73  void setStringsList(const std::vector<std::string> &unselList,
74  const std::vector<std::string> &selList);
75 
76  /**
77  * gets the selected strings list
78  */
79  std::vector<std::string> getSelectedStringsList() const;
80 
81  /**
82  * Method which sets the label text value of the unselected strings list
83  * (this method does nothing if listType = SIMPLE_LIST)
84  */
85  void setUnselectedStringsListLabel(const std::string &unselectedStringsListLabel);
86 
87  /**
88  * Method which sets the label text value of the selected strings list
89  * (this method does nothing if listType = SIMPLE_LIST)
90  */
91  void setSelectedStringsListLabel(const std::string &selectedStringsListLabel);
92 
93  /**
94  * @brief Constructs a strings list selection dialog with the given parent.
95  * \param parent the widget's parent
96  * \param listType this parameter defines the widget's look (see class description)
97  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no
98  *size restriction)
99  **/
100  explicit StringsListSelectionDialog(
101  QString title, QWidget *parent = nullptr,
102  const StringsListSelectionWidget::ListType listType = StringsListSelectionWidget::SIMPLE_LIST,
103  const unsigned int maxSelectedStringsListSize = 0);
104  ~StringsListSelectionDialog() override;
105 
106  /**
107  * @brief This is a convenience static function that create a dialog
108  * to select some strings in a list.
109  * The function creates a modal dialog with the given title and parent widget.
110  *
111  * @param title the string to display in the dialog title bar,
112  * @param strList the list of strings to choose,
113  * @param selList on input it indicates the already selected strings, then on output the user
114  *selected strings,
115  * @param listType the type of display for the strings to choose,
116  * @param maxSize the maximum number of strings to select. 0 means this number is not limited.
117  **/
118  static bool choose(
119  QString title, const std::vector<std::string> &strList, std::vector<std::string> &selList,
120  QWidget *parent = nullptr,
121  const StringsListSelectionWidget::ListType listType = StringsListSelectionWidget::SIMPLE_LIST,
122  const unsigned int maxSize = 0);
123 
124 private:
125  Ui::StringsListSelectionDialog *ui;
126 };
127 } // namespace tlp
128 
129 #endif // STRINGSLISTSELECTIONDIALOG_H
130 ///@endcond