Tulip  5.1.0
Large graphs analysis and drawing
CSVParserConfigurationWidget.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 CSVPARSERCONFIGURATIONWIDGET_H
22 #define CSVPARSERCONFIGURATIONWIDGET_H
23 
24 #include <climits>
25 
26 #include <QWidget>
27 
28 #include <tulip/tulipconf.h>
29 
30 namespace Ui {
31 class CSVParserConfigurationWidget;
32 }
33 
34 namespace tlp {
35 
36 class CSVParser;
37 
38 class TLP_QT_SCOPE CSVParserConfigurationWidget : public QWidget {
39  Q_OBJECT
40 public:
41  CSVParserConfigurationWidget(QWidget *parent = NULL);
42  ~CSVParserConfigurationWidget();
43  /**
44  * @brief Generate a csv parser in function of the parameters in the widget. User define the range of line to import.
45  * The user takes the ownership of the widget.
46  **/
47  CSVParser* buildParser(unsigned int firstLine=0, unsigned int lastLine=UINT_MAX)const;
48 
49  std::string getFile()const;
50  bool isValid()const;
51  QString getSeparator()const;
52  char getTextSeparator()const;
53  char getDecimalMark()const;
54  std::string getEncoding()const;
55  bool invertMatrix()const;
56  bool getMergeSeparator() const;
57  void initWithLastOpenedFile();
58  int getFirstLineIndex() const;
59  void setNbIgnoredLines(int);
60 
61 public slots:
62  void setFileToOpen(const QString& fileToOpen);
63 protected:
64  void fillEncodingComboBox();
65 
66 protected slots:
67  void changeFileNameButtonPressed();
68  void encodingChanged();
69  void changeSeparator(int index);
70  void ignoreFirstLines(int checkState);
71 
72 private:
73 
74  QString getSeparator(int index)const;
75 
76  Ui::CSVParserConfigurationWidget *ui;
77  static QString lastOpenedFile;
78 
79 signals:
80  void parserChanged();
81 };
82 }
83 #endif // CSVPARSERCONFIGURATIONWIDGET_H
84 ///@endcond