Tulip  5.1.0
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 
22 #ifndef STRINGSLISTSELECTIONDIALOG_H
23 #define STRINGSLISTSELECTIONDIALOG_H
24 
25 #include <QDialog>
26 
27 #include <tulip/tulipconf.h>
28 #include <tulip/StringsListSelectionWidget.h>
29 
30 namespace Ui {
31 class StringsListSelectionDialog;
32 }
33 
34 namespace tlp {
35 
36 /**
37  * @brief Provide a dialog that allow user to select a list of strings.
38  *
39  * The easiest way to use this class is to use the static function.
40  * @code
41  * QString title;
42  * QWidget* parent;
43  * vector<string> listOfStrings; // must be initialized
44  * vector<string> selectedStrings;
45  * bool choosen = StringsListSelectionDialog::choose(title, parent, listOfStrings, 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 = NULL);
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,
74  std::vector<std::string>& selList);
75 
76  /**
77  * @brief Constructs a strings list selection dialog with the given parent.
78  * \param parent the widget's parent
79  * \param listType this parameter defines the widget's look (see class description)
80  * \param maxSelectedStringsListSize the maximum number of strings that can be selected (if 0, no size restriction)
81  **/
82  explicit StringsListSelectionDialog(QString title,
83  QWidget *parent = NULL,
84  const StringsListSelectionWidget::ListType listType = StringsListSelectionWidget::SIMPLE_LIST,
85  const unsigned int maxSelectedStringsListSize = 0);
86  ~StringsListSelectionDialog();
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 selected strings,
96  * @param listType the type of display for the strings to choose,
97  * @param maxSize the maximum number of strings to select. 0 means this number is not limited.
98  **/
99  static bool choose(QString title, const std::vector<std::string>& strList,
100  std::vector<std::string>& selList,
101  QWidget* parent=NULL,
102  const StringsListSelectionWidget::ListType listType =
103  StringsListSelectionWidget::SIMPLE_LIST,
104  const unsigned int maxSize = 0);
105 private:
106 
107  Ui::StringsListSelectionDialog *ui;
108 };
109 }
110 
111 #endif // STRINGSLISTSELECTIONDIALOG_H
112 ///@endcond