-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmoreinfordlg.cpp
More file actions
140 lines (112 loc) · 3.19 KB
/
moreinfordlg.cpp
File metadata and controls
140 lines (112 loc) · 3.19 KB
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
#include "moreinfordlg.h"
#include "ui_moreinfordlg.h"
#include "mainwindow.h"
#include "main.h"
#include <QFileDialog>
//#include <QAxWidget>
extern bool RemoteDB;
MoreInforDlg::MoreInforDlg(QWidget *parent) :
QDialog(parent),
ui(new Ui::MoreInforDlg)
{
ui->setupUi(this);
Qt::WindowFlags flags = Qt::Dialog;
flags |= Qt::WindowMinimizeButtonHint;
flags |= Qt::WindowMaximizeButtonHint;
flags |= Qt::WindowCloseButtonHint;
setWindowFlags(flags);
if(QSqlDatabase::contains("MoreInfoDB"))
{
MoreInfoDB = QSqlDatabase::database("MoreInfoDB");
}
else
{
MoreInfoDB = QSqlDatabase::addDatabase("QSQLITE","MoreInfoDB");
}
qDebug() << MoreInfoDB;
if(RemoteDB)
{
QString DBString ="Q:\\Asia\\Shanghai\\workgrps\\Engineering\\public\\test report\\LabEquipmentsDatabase\\Equipments.db";
MoreInfoDB.setDatabaseName(DBString);
}
else
{
MoreInfoDB.setDatabaseName("Equipments.db"); // æ•°æ®åº“å与路å¾?, æ¤æ—¶æ˜¯æ”¾åœ¨åŒç›®å½•ä¸?
}
}
MoreInforDlg::~MoreInforDlg()
{
delete ui;
}
void MoreInforDlg::updateUI_MoreInfrDlg(QString SQLReceive)
{
TableModelMoreInfo = new QStandardItemModel;
ui->tableView_MoreInfo->setModel(TableModelMoreInfo);
MoreInfoDB.open();
QSqlQuery queryMoreInfo(MoreInfoDB);
TableModelMoreInfo->clear();
if(queryMoreInfo.exec(SQLReceive))
{
qDebug("SQL exec : successful!");
}
else
{
qDebug("SQL exec : Failed!");
}
int columnNum = queryMoreInfo.record().count();
TableModelMoreInfo->setColumnCount(columnNum);
int i = 0;
for(i = 0;i < columnNum; i++)
{
TableModelMoreInfo->setHeaderData(i,Qt::Horizontal,queryMoreInfo.record().fieldName(i));
}
QStandardItem *item[columnNum];
QList <QStandardItem*>ItemList;
if(queryMoreInfo.isActive())
{
qDebug("queryCalVer is active!");
}
else
{
qDebug("queryCalVer is inactive!");
}
while((bool)queryMoreInfo.next())//
{
for(i = 0;i < columnNum; i++)
{
item[i] = new QStandardItem(queryMoreInfo.value(i).toString());
ItemList << item[i];
}
TableModelMoreInfo->appendRow(ItemList);
ItemList.clear();
}
ui->tableView_MoreInfo->setModel(TableModelMoreInfo);
ui->tableView_MoreInfo->resizeColumnsToContents();
}
void MoreInforDlg::on_pushButton_Cancel_clicked()
{
this->close();
}
void MoreInforDlg::on_pushButton_Export_clicked()
{
QAbstractItemModel* View;
QString Filename;
View = ui->tableView_MoreInfo->model();
QFileDialog saveDlg;
Filename = saveDlg.getSaveFileName(this, tr("Save File"),"./export/*.xlsx",
tr("Excel File (*.xlsx *.xls *.csv)"));
qDebug() << Filename;
if (Filename.isEmpty())
{
qDebug("Please fill the file name.");
return;
}
else
{
emit Signal_ExportfromMoreInfor(View,Filename);
}
// QAxWidget excel("Excel.Application");
// excel.setProperty("Visible", true);
// QAxObject *workbooks = excel.querySubObject("WorkBooks");
// workbooks->dynamicCall("Open (const QString&)", Filename);
}