summaryrefslogtreecommitdiff
path: root/src/export-import/CsvImportDialog.h
blob: bc3a9d1cf33e04b41da4e6e4ec36a9c203f106b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef CSVIMPORTDIALOG_H
#define CSVIMPORTDIALOG_H

#include <QtCore>
#include <QtWidgets>

#include "CsvData.h"
#include "CsvDialog.h"

class DictTableView;
class Dictionary;
class DicCsvReader;
class DictTableModel;
class AppModel;

class CsvImportDialog: public CsvDialog
{
    Q_OBJECT

public:
    CsvImportDialog(QWidget* parent, QString filePath, const AppModel* appModel );
    ~CsvImportDialog();

    Dictionary* getDictionary() { return dictionary; }

protected:
    QLayout* createLeftGroupLayout();
    QString getLeftGroupTitle() { return tr("Input"); }
    QLayout* createSeparatorsLayout();
    QLayout* createPreviewLt();

protected slots:
    void updatePreview();

private slots:
    void UpdateCommentCharacterCombo();
    void DeleteDictionary();

private:
    QWidget* createFromLineSpin();
    QWidget* createColsToImportSpin();
    QWidget* createFirstLineIsHeaderCB();
    void createSeparationRadioButtons();
    FieldSeparationMode getSeparationMode();
    QWidget* createCommentCharBox();
    QWidget* createPreview();

private:
    QString filePath;
    Dictionary* dictionary;   // not own, created here
    const AppModel* appModel;
    DicCsvReader* dicReader;
    DictTableModel* iPreviewModel;
    QSpinBox* fromLineSpin; // 1-based
    QSpinBox* colsToImportSpin; // 1-based; 0 = all
    QCheckBox* firstLineIsHeaderCB;
    QRadioButton* anyCharacterRB;
    QRadioButton* anyCombinationRB;
    QRadioButton* exactStringRB;
    QCheckBox* commentCharCB;
    DictTableView* previewTable;
};

#endif