aboutsummaryrefslogtreecommitdiff
path: root/importdialog.h
blob: 68ae7ae70e95101270deb336277d065ba0a53da1 (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
#ifndef IMPORTDIALOG_H
#define IMPORTDIALOG_H

#include <QDialog>
#include <QTableWidget>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QRadioButton>
#include <QButtonGroup>
#include <QList>
#include <QStringList>
#include "transaction.h"
#include "database.h"

class ImportDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ImportDialog(Database *db, QWidget *parent = nullptr);
    ~ImportDialog();
    
    QList<Transaction> getImportedTransactions() const;

private slots:
    void onBrowseFile();
    void onColumnMappingChanged();
    void onImport();
    void onSelectAll();
    void onDeselectAll();

private:
    Database *database;
    QTableWidget *previewTable;
    QPushButton *browseBtn;
    QPushButton *importBtn;
    QPushButton *selectAllBtn;
    QPushButton *deselectAllBtn;
    
    QComboBox *dateColumnCombo;
    QComboBox *amountColumnCombo;
    QComboBox *withdrawalColumnCombo;
    QComboBox *depositColumnCombo;
    QComboBox *descriptionColumnCombo;
    QComboBox *accountCombo;
    QComboBox *categoryCombo;
    
    QStringList csvHeaders;
    QList<QStringList> csvRows;
    QList<Transaction> importedTransactions;
    
    void loadCsvFile(const QString &filePath);
    void updatePreview();
    Transaction parseRow(int rowIndex);
};

#endif // IMPORTDIALOG_H