Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
CSVParserConfigurationWidget.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 CSVPARSERCONFIGURATIONWIDGET_H
22 #define CSVPARSERCONFIGURATIONWIDGET_H
23 
24 #include <QtGui/QWidget>
25 #include <QtGui/QComboBox>
26 #include <tulip/CSVParser.h>
27 #include <tulip/CSVContentHandler.h>
28 
29 namespace Ui {
30 class CSVParserConfigurationWidget;
31 }
32 
33 namespace tlp {
34 
35 
36 class CSVParserConfigurationWidgetEditableComboBox : public QComboBox {
37  Q_OBJECT
38 public :
39  CSVParserConfigurationWidgetEditableComboBox(QWidget * parent = NULL);
40 protected:
41  //Qt workaround avoiding QDialog to close automatically when pressing return or enter.
42  void keyPressEvent(QKeyEvent *e);
43 };
44 
45 class TLP_QT_SCOPE CSVParserConfigurationWidget : public QWidget {
46  Q_OBJECT
47 public:
48  CSVParserConfigurationWidget(QWidget *parent = NULL);
49  ~CSVParserConfigurationWidget();
50  /**
51  * @brief Generate a csv parser in function of the parameters in the widget. User define the range of line to import.
52  * The user takes the ownership of the widget.
53  **/
54  CSVParser * buildParser(unsigned int firstLine=0, unsigned int lastLine=UINT_MAX)const;
55 
56  std::string getFile()const;
57  bool isValid()const;
58  std::string getSeparator()const;
59  char getTextSeparator()const;
60  std::string getEncoding()const;
61  bool invertMatrix()const;
62 
63 public slots:
64  void setFileToOpen(const QString& fileToOpen);
65 protected:
66  void fillEncodingComboBox();
67  void changeEvent(QEvent *e);
68 
69 protected slots:
70  void changeFileNameButtonPressed();
71  void encodingChanged();
72 
73 private:
74 
75  QString getSeparator(int index)const;
76 
77  Ui::CSVParserConfigurationWidget *ui;
78 
79 signals:
80  void parserChanged();
81 };
82 }
83 #endif // CSVPARSERCONFIGURATIONWIDGET_H
84 ///@endcond