-
Notifications
You must be signed in to change notification settings - Fork 0
/
databasewidget.h
111 lines (95 loc) · 3.48 KB
/
databasewidget.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef DATABASEWIDGET_H
#define DATABASEWIDGET_H
#include <QWidget>
#include <QFileDialog>
#include <QtConcurrentRun>
#include <QtConcurrentMap>
#include <QFutureWatcher>
#include <QFuture>
#include <QProgressDialog>
#include <QScopedPointer>
#include <QMessageBox>
#include "database.h"
#include "defines.h"
#include "xlsparser.h"
namespace Ui {
class DatabaseWidget;
}
// ********************* class DatabaseWidget ********************
/**
* \class DatabaseWidget
* \brief Класс для работы пользователя с БД
*/
class DatabaseWidget : public QWidget
{
Q_OBJECT
public:
explicit DatabaseWidget(QWidget *parent = 0);
~DatabaseWidget();
Database *getDatabase();
public slots:
/**
* \fn bool open();
* \brief Производит парсинг и открытие БД из csv-файла.
* \return статус открытия БД
*/
bool open();
/**
* \fn void openExisting(QString fname);
* \brief Производит открытие сохраненной и распарсенной БД из файла DefaultBaseName.
*
* Если DefaultBaseName отсутсвует, то отображает окно с выбором дальнейших действий
*/
void openExisting();
/**
* \fn void openExisting(QString fname);
* \brief Производит открытие сохраненной и распарсенной БД из файла fname.
* \param[in] fname имя распарсенной БД (.db)
*/
void openExisting(QString fname);
private slots:
void onBaseOpening();
void onBaseOpened();
void onFindButtonClicked();
void onParseButtonClicked();
void onClearButtonClicked();
void onSelectedRows(int count);
void onProcessOfOpenFinished();
void onProcessOfParsingFinished();
void on__pushButtonOpen_clicked();
void on__pushButtonParseAddr_clicked();
void on__pushButtonFindParsAddr_clicked();
void on__pushButtonClear_clicked();
void on__pushButtonDelete_clicked();
signals:
void toDebug(QString, QString);
void exitSignal();
void selectAddress(Address a);
void updateModel();
private:
Ui::DatabaseWidget *_ui;
Database *_db;
XlsParser *_parser;
QFutureWatcher<ListAddress> _futureWatcher;
QFutureWatcher<void> _futureWatcherParser;
QScopedPointer<ListAddress> _paddr;
QString _csvFileName;
QThread *_thread;
void readCsvBase(QString openFilename);
};
/**
* \fn ListAddress readFile(QString &filename, int maxCount);
* \brief Производит чтение заданного количества строк из БД (csv-файла)
* \param[in] filename имя csv-файла
* \param[in] maxCount число строк, которое необходимо прочитать (0 - читать все)
*/
ListAddress readFile(QString &filename, int maxCount);
/**
* \fn void parsingAddress(Address &a);
* \brief Производит парсинг адреса по паттерну BaseRegPattern.
* \param[in/out] a адрес
*
* Значение адреса для обработки берется из getRawAddressString()
*/
void parsingAddress(Address &a);
#endif // DATABASEWIDGET_H