Tulip 6.1.0
Large graphs analysis and drawing
Loading...
Searching...
No Matches
CSVImportWizard.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 CSVIMPORTWIZARD_H
22#define CSVIMPORTWIZARD_H
23
24#include <QWizard>
25#include <QWizardPage>
26
27#include <tulip/tulipconf.h>
28#include <tulip/CSVContentHandler.h>
29
30namespace Ui {
31class CSVImportWizard;
32}
33namespace tlp {
34
35class Graph;
36class CSVParser;
37class CSVParserConfigurationWidget;
38class CSVTableWidget;
39class CSVImportConfigurationWidget;
40class CSVToGraphDataMapping;
41class CSVGraphMappingConfigurationWidget;
42class CSVImportParameters;
43
44/**
45 * @brief QWIzardPage encapsulating a CSVParserConfigurationWidget and a preview.
46 **/
47class CSVParsingConfigurationQWizardPage : public QWizardPage, public CSVContentHandler {
48 Q_OBJECT
49public:
50 CSVParsingConfigurationQWizardPage(QWidget *parent = nullptr);
51 bool begin() override;
52 bool line(unsigned int row, const std::vector<CSVToken> &lineTokens) override;
53 bool end(unsigned int rowNumber, unsigned int columnNumber) override;
54 bool isComplete() const override;
55 bool validatePage() override;
56 CSVParser *buildParser(int firstLine = 0) const;
57 int getFirstLineIndex() const;
58
59private:
60 void updatePreview();
61 CSVParserConfigurationWidget *parserConfigurationWidget;
62 CSVTableWidget *previewTableWidget;
63 unsigned int previewLineNumber, columnCount;
64 bool validColumnCount;
65
66private slots:
67 void parserChanged();
68};
69
70class CSVImportConfigurationQWizardPage : public QWizardPage {
71 Q_OBJECT
72public:
73 CSVImportConfigurationQWizardPage(QWidget *parent = nullptr);
74 void initializePage() override;
75 CSVImportParameters getImportParameters() const;
76
77private:
78 CSVImportConfigurationWidget *importConfigurationWidget;
79};
80
81class CSVGraphMappingConfigurationQWizardPage : public QWizardPage {
82 Q_OBJECT
83public:
84 CSVGraphMappingConfigurationQWizardPage(QWidget *parent = nullptr);
85 void initializePage() override;
86 bool isComplete() const override;
87 CSVToGraphDataMapping *buildMappingObject() const;
88
89private:
90 CSVGraphMappingConfigurationWidget *graphMappingConfigurationWidget;
91};
92
93class TLP_QT_SCOPE CSVImportWizard : public QWizard {
94 Q_OBJECT
95
96public:
97 explicit CSVImportWizard(QWidget *parent = nullptr);
98 ~CSVImportWizard() override;
99
100 CSVParsingConfigurationQWizardPage *getParsingConfigurationPage() const;
101 CSVImportConfigurationQWizardPage *getImportConfigurationPage() const;
102 CSVGraphMappingConfigurationQWizardPage *getMappingConfigurationPage() const;
103
104 static void setGraph(Graph *g) {
105 graph = g;
106 }
107
108 static Graph *getGraph() {
109 return graph;
110 }
111
112public slots:
113 void accept() override;
114
115private:
116 Ui::CSVImportWizard *ui;
117 static tlp::Graph *graph;
118};
119} // namespace tlp
120#endif // CSVIMPORTWIZARD_H
121///@endcond