/
configration_form.cpp
200 lines (180 loc) · 6.03 KB
/
configration_form.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include "configration_form.h"
#include "ui_configration_form.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
extern MainWindow *pMain;
Configration_Form::Configration_Form(QWidget *parent) :
QWidget(parent),
ui(new Ui::Configration_Form)
{
ui->setupUi(this);
Init();
}
Configration_Form::~Configration_Form()
{
delete ui;
}
void Configration_Form::resizeEvent(QResizeEvent *)
{
/*화면크기에 따른 폰트사이즈 조정*/
QFont font;
font.setPointSizeF(this->width()/40);
if(font.pointSizeF()<=12)
{
font.setPointSizeF(12);
}
ui->label_Title->setFont(font);
}
void Configration_Form::Init() //초기화
{
connect(pMain,SIGNAL(Retranslator()),this,SLOT(Retranslator()));
connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(TitleShow(int)));
Retranslator();
TitleShow(0);
DatabaseSettingMode(DB_INIT);
DatabaseSettingMode(DB_LOAD);
}
void Configration_Form::DatabaseSettingMode(int Mode)
{
switch(Mode)
{
case DB_INIT:
DatabaseSettingInit();
break;
case DB_SAVE:
DatabaseSettingSave();
break;
case DB_LOAD:
DatabaseSettingLoad();
break;
}
}
void Configration_Form::DatabaseSettingInit()
{
QSqlDatabase LocalDB=QSqlDatabase::database("LocalDB");
QSqlQuery query(LocalDB);
query.exec("CREATE TABLE IF NOT EXISTS systemset (remotedbip TEXT,"
"remotedbport TEXT,"
"remotedbname TEXT,"
"version INTEGER,"
"remotedbusername TEXT,"
"remotedbpassword TEXT,"
"current_macine_name TEXT,"
"language INTEGER"
");");
query.exec("insert into systemset(remotedbip,"
"remotedbport,"
"remotedbname,"
"version,"
"remotedbusername,"
"remotedbpassword,"
"current_macine_name,"
"language)"
"select \'127.0.0.1\',"
"\'3306\',"
"\'QCproject\',"
"1,"
"\'QCmen\',"
"\'1234\', "
"\'select\',"
"0 "
"where not exists(select * from systemset);");
query.exec("CREATE TABLE IF NOT EXISTS [temp_setindex]("
"[ID] INT NOT NULL DEFAULT 1, "
"[temp1] INT NOT NULL DEFAULT 0, "
"[temp2] INT NOT NULL DEFAULT 0, "
"[temp3] INT NOT NULL DEFAULT 0, "
"[temp4] INT NOT NULL DEFAULT 0, "
"[temp5] INT NOT NULL DEFAULT 0, "
"[temp6] INT NOT NULL DEFAULT 0, "
"[temp7] INT NOT NULL DEFAULT 0, "
"[temp8] INT NOT NULL DEFAULT 0, "
"[temp9] INT NOT NULL DEFAULT 0, "
"[temp10] INT NOT NULL DEFAULT 0, "
"[temp11] INT NOT NULL DEFAULT 0, "
"[temp12] INT NOT NULL DEFAULT 0, "
"[temp13] INT NOT NULL DEFAULT 0, "
"[temp14] INT NOT NULL DEFAULT 0, "
"[temp15] INT NOT NULL DEFAULT 0);"
);
query.exec("insert into temp_setindex(temp1) select 0 where not exists(select * from temp_setindex);");
}
void Configration_Form::DatabaseSettingSave()
{
QSqlDatabase LocalDB=QSqlDatabase::database("LocalDB");
QSqlQuery query(LocalDB);
query.exec(QString("update systemset set remotedbip='%1',remotedbport='%2',version=1,remotedbname='%3',remotedbusername='%4',remotedbpassword='%5'")
.arg(ui->lineEdit_IPAddress->text(),ui->lineEdit_Port->text(),ui->lineEdit_DBName->text(),ui->lineEdit_UserName->text(),ui->lineEdit_Password->text()));
}
void Configration_Form::DatabaseSettingCheck()
{
if(ui->lineEdit_IPAddress->text().isEmpty() || ui->lineEdit_Port->text().isEmpty() || ui->lineEdit_UserName->text().isEmpty()
|| ui->lineEdit_DBName->text().isEmpty()|| ui->lineEdit_Password->text().isEmpty())
{
QMessageBox::warning(this,tr("Warning"),tr("Configration is empty."),QMessageBox::Ok);
}
else
{
DatabaseSettingMode(DB_SAVE);
QMessageBox::information(this,tr("Apply"),tr("Configration Applied."),QMessageBox::Ok);
}
}
void Configration_Form::DatabaseSettingLoad()
{
QSqlDatabase LocalDB=QSqlDatabase::database("LocalDB");
QSqlQuery query(LocalDB);
query.exec("select * from systemset");
while(query.next())
{
for(int i=0; i<7; i++)
{
switch(i)
{
case LOCALDB_REMOTEDBIP:
ui->lineEdit_IPAddress->setText(query.value(LOCALDB_REMOTEDBIP).toString());
break;
case LOCALDB_REMOTEDBPORT:
ui->lineEdit_Port->setText(query.value(LOCALDB_REMOTEDBPORT).toString());
break;
case LOCALDB_REMOTEDBNAME:
ui->lineEdit_DBName->setText(query.value(LOCALDB_REMOTEDBNAME).toString());
break;
case LOCALDB_VERSION:
break;
case LOCALDB_REMOTEDBUSERNAME:
ui->lineEdit_UserName->setText(query.value(LOCALDB_REMOTEDBUSERNAME).toString());
break;
case LOCALDB_REMOTEDBPASSWORD:
ui->lineEdit_Password->setText(query.value(LOCALDB_REMOTEDBIP).toString());
break;
case LOCALDB_CURRENT_MACHINE_NAME:
break;
}
}
}
}
void Configration_Form::on_pushButton_Check_clicked()
{
DatabaseSettingCheck();
pMain->ui->mdiArea->closeActiveSubWindow();
}
void Configration_Form::on_pushButton_Apply_clicked()
{
DatabaseSettingCheck();
}
void Configration_Form::on_pushButton_Cancel_clicked()
{
QMessageBox::information(this,tr("Cancel"),tr("Configration Canceled."),QMessageBox::Ok);
pMain->ui->mdiArea->closeActiveSubWindow();
}
void Configration_Form::Retranslator()
{
ui->retranslateUi(this);
}
void Configration_Form::TitleShow(int Changed)
{
ui->label_Title->setText(ui->tabWidget->tabText(Changed));
}
void Configration_Form::on_pushButton_clicked()
{
}