Tulip  5.2.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 = nullptr);
42  ~CSVParserConfigurationWidget() override;
43  /**
44  * @brief Generate a csv parser in function of the parameters in the widget. User define the
45  *range of line to import.
46  * The user takes the ownership of the widget.
47  **/
48  CSVParser *buildParser(unsigned int firstLine = 0, unsigned int lastLine = UINT_MAX) const;
49 
50  std::string getFile() const;
51  bool isValid() const;
52  QString getSeparator() const;
53  char getTextSeparator() const;
54  char getDecimalMark() const;
55  std::string getEncoding() const;
56  bool invertMatrix() const;
57  bool getMergeSeparator() const;
58  void initWithLastOpenedFile();
59  int getFirstLineIndex() const;
60  void setNbIgnoredLines(int);
61 
62 public slots:
63  void setFileToOpen(const QString &fileToOpen);
64 
65 protected:
66  void fillEncodingComboBox();
67 
68 protected slots:
69  void changeFileNameButtonPressed();
70  void encodingChanged();
71  void changeSeparator(int index);
72  void ignoreFirstLines(int checkState);
73 
74 private:
75  QString getSeparator(int index) const;
76 
77  Ui::CSVParserConfigurationWidget *ui;
78  static QString lastOpenedFile;
79 
80 signals:
81  void parserChanged();
82 };
83 }
84 #endif // CSVPARSERCONFIGURATIONWIDGET_H
85 ///@endcond