Tulip  5.2.1
Large graphs analysis and drawing
StringsListSelectionDialog.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 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 strings list and the already selected strings
72  */
73  void setStringsList(const std::vector<std::string> &strList, std::vector<std::string> &selList);
74 
75  /**
76  * @brief Constructs a strings list selection dialog with the given parent.
77  * \param parent the widget's parent
78  * \param listType this parameter defines the widget's look (see class description)
79  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no
80  *size restriction)
81  **/
82  explicit StringsListSelectionDialog(
83  QString title, QWidget *parent = nullptr,
84  const StringsListSelectionWidget::ListType listType = StringsListSelectionWidget::SIMPLE_LIST,
85  const unsigned int maxSelectedStringsListSize = 0);
86  ~StringsListSelectionDialog() override;
87 
88  /**
89  * @brief This is a convenience static function that create a dialog
90  * to select some strings in a list.
91  * The function creates a modal dialog with the given title and parent widget.
92  *
93  * @param title the string to display in the dialog title bar,
94  * @param strList the list of strings to choose,
95  * @param selList on input it indicates the already selected strings, then on output the user
96  *selected strings,
97  * @param listType the type of display for the strings to choose,
98  * @param maxSize the maximum number of strings to select. 0 means this number is not limited.
99  **/
100  static bool choose(
101  QString title, const std::vector<std::string> &strList, std::vector<std::string> &selList,
102  QWidget *parent = nullptr,
103  const StringsListSelectionWidget::ListType listType = StringsListSelectionWidget::SIMPLE_LIST,
104  const unsigned int maxSize = 0);
105 
106 private:
107  Ui::StringsListSelectionDialog *ui;
108 };
109 } // namespace tlp
110 
111 #endif // STRINGSLISTSELECTIONDIALOG_H
112 ///@endcond