Tulip  6.0.0
Large graphs analysis and drawing
CSVParserConfigurationWidget.h
1 /*
2  *
3  * This file is part of Tulip (https://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  void clearFile();
52  bool isValid() const;
53  QString getSeparator() const;
54  char getTextSeparator() const;
55  char getDecimalMark() const;
56  std::string getEncoding() const;
57  bool invertMatrix() const;
58  bool getMergeSeparator() const;
59  bool getConsiderAsString() const;
60  void initWithLastOpenedFile();
61  int getFirstLineIndex() const;
62  void setNbIgnoredLines(int);
63 
64 public slots:
65  void setFileToOpen(const QString &fileToOpen);
66 
67 protected:
68  void fillEncodingComboBox();
69 
70 protected slots:
71  void changeFileNameButtonPressed();
72  void encodingChanged();
73  void changeSeparator(int index);
74  void ignoreFirstLines(int checkState);
75 
76 private:
77  QString getSeparator(int index) const;
78 
79  Ui::CSVParserConfigurationWidget *ui;
80  static QString lastOpenedFile;
81 
82 signals:
83  void parserChanged();
84 };
85 } // namespace tlp
86 #endif // CSVPARSERCONFIGURATIONWIDGET_H
87 ///@endcond