forked from e8tools/tool1cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
120 lines (103 loc) · 2.94 KB
/
mainwindow.cpp
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
112
113
114
115
116
117
118
119
120
/*
GTool1CD provides GUI front end to Tool1CD library
Copyright © 2009-2017 awa
Copyright © 2017-2018 E8 Tools contributors
This file is part of GTool1CD.
GTool1CD is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GTool1CD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GTool1CD. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QDebug>
#include <QStringListModel>
#include "starter.h"
#include "cache.h"
#include "table_fields_window.h"
#include "table_data_window.h"
#include "models/tables_list_model.h"
#include "configurations_window.h"
#include "about_dialog.h"
void MainWindow::AddDetailedMessage(
const std::string &description,
const MessageState mstate,
const TStringList *param)
{
this->addLogMessage(QString(description.c_str()));
}
void MainWindow::Status(const std::string& message)
{
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
configurationsWindow(nullptr)
{
ui->setupUi(this);
ui->logList->setModel(new QStringListModel(logData));
ui->logList->setVisible(false);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::open(T_1CD *database)
{
db = database;
ui->tableListView->setModel(new TablesListModel(db));
setWindowTitle(QString::fromStdWString(db->get_filepath().wstring()));
// refresh data
}
void MainWindow::addLogMessage(const QString &message)
{
logData.append(message);
}
void MainWindow::on_exitAction_triggered()
{
for (auto w : table_windows) {
delete w;
}
close();
}
void MainWindow::on_openDatabaseFileAction_triggered()
{
StarterWindow *w = new StarterWindow();
w->setCache(new Cache());
w->show();
}
void MainWindow::on_tableListView_doubleClicked(const QModelIndex &index)
{
Table *t = db->get_table(index.row());
if (table_windows.find(t) == table_windows.end()) {
table_windows[t] = new TableDataWindow(this, t);
}
table_windows[t]->show();
table_windows[t]->activateWindow();
}
void MainWindow::on_configurationsButton_clicked()
{
if (configurationsWindow == nullptr) {
configurationsWindow = new ConfigurationsWindow(db, this);
}
configurationsWindow->show();
configurationsWindow->activateWindow();
}
void MainWindow::on_tableListView_activated(const QModelIndex &index)
{
emit ui->tableListView->doubleClicked(index);
}
void MainWindow::on_aboutAction_triggered()
{
if (about_window == nullptr) {
about_window = new AboutDialog(this);
}
about_window->show();
}