Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
CSVGraphMappingConfigurationWidget.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 #ifndef CSVGRAPHMAPPINGCONFIGURATIONWIDGET_H
22 #define CSVGRAPHMAPPINGCONFIGURATIONWIDGET_H
23 
24 #include <QComboBox>
25 
26 #include <tulip/tulipconf.h>
27 
28 namespace Ui {
29 class CSVGraphMappingConfigurationWidget;
30 }
31 
32 namespace tlp {
33 
34 class Graph;
35 class CSVGraphImport;
36 class CSVImportParameters;
37 class CSVToGraphDataMapping;
38 
39 /**
40  * @brief Combo box used to select a CSV column.
41  **/
42 class TLP_QT_SCOPE CSVColumnComboBox : public QComboBox {
43 public:
44  CSVColumnComboBox(QWidget* parent=NULL);
45  /**
46  * @brief Fill the combobox with the CSV parameters.
47  *
48  * The first item is not a valid choice it's just a label.
49  **/
50  void setCsvProperties(const CSVImportParameters& csvProperties);
51  /**
52  * @brief Get column selected by user or UINT_MAX if no valid column is selected.
53  * @return The column selected by the user.
54  *
55  **/
56  unsigned int getSelectedColumnIndex()const;
57  /**
58  * @brief Allow user to define it's default text.
59  **/
60  void setDefaultText(const QString& newDefaultText);
61 private:
62  QString defaultText;
63 };
64 
65 /**
66  * @brief Combo box for property selection and creation in a graph.
67  *
68  * If the combo box is editable and if user enter the name of a property that does not exist this will create it.
69  * A popup will querry user for the type of the property to create.
70  * There is no way to delete a created property in this widget.
71  **/
72 class TLP_QT_SCOPE GraphPropertiesSelectionComboBox : public QComboBox {
73  Q_OBJECT
74 public:
75  GraphPropertiesSelectionComboBox(QWidget* parent=NULL);
76  /**
77  * @brief Fill the combobox with the properties in the given graph.
78  **/
79  void setGraph(tlp::Graph*);
80  /**
81  * @brief return the name of the property selected by the user. If the label is selected an empty string will be returned.
82  * @return The name of the selected property or an empty string if no valid property is selected.
83  **/
84  std::string getSelectedGraphProperty()const;
85 
86  /**
87  * @brief Select the property with the given name in the list
88  **/
89  void selectProperty(const std::string& propertyName);
90  /**
91  * @brief Allow user to define it's default text.
92  **/
93  void setDefaultText(const QString& newDefaultText);
94 
95 private:
96  tlp::Graph *currentGraph;
97  QString defaultText;
98 
99 };
100 
101 
102 /**
103  * @brief Widget generating the CSVToGraphDataMapping object.
104  *
105  * This widget allow user to configure a CSVToGraphDataMapping object. This object is used during the CSV import process to map CSV columns to graph elements like nodes or edges.
106  **/
107 class TLP_QT_SCOPE CSVGraphMappingConfigurationWidget : public QWidget {
108  Q_OBJECT
109 public:
110  CSVGraphMappingConfigurationWidget(QWidget *parent = NULL);
111  ~CSVGraphMappingConfigurationWidget();
112 
113  /**
114  * @brief Configure the widget with the CSV import parameters.
115  **/
116  void updateWidget(tlp::Graph* graph,const CSVImportParameters& importParameters);
117  /**
118  * @brief Build the mapping object between the CSV columns and the graph elements.
119  **/
120  CSVToGraphDataMapping *buildMappingObject() const;
121 
122  /**
123  * @brief Check if the values entered by user are valid.
124  *
125  * If return true you are sure that buildMappingObject never return a NULL object.
126  **/
127  bool isValid()const;
128 
129 protected:
130  tlp::Graph* graph;
131 
132 private:
133  Ui::CSVGraphMappingConfigurationWidget *ui;
134 
135 private slots:
136  void createNewProperty();
137 
138 signals:
139  void mappingChanged();
140 };
141 }
142 #endif // CSVGRAPHMAPPINGCONFIGURATIONWIDGET_H
143 ///@endcond