-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfrmpartitions.cpp
53 lines (36 loc) · 1.29 KB
/
frmpartitions.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
#include "frmpartitions.h"
#include <QtSql/QSqlQuery>
#define GETPARTITIONS "select distinct partition.partitionname, partition.partitionid from partition, StateHistory, CurrentState where StateHistory.partitionid=Partition.partitionId and StateHistory.stateHistoryId=CurrentState.stateHistoryId order by partition.partitionid DESC"
Partitions::Partitions(QWidget* parent):
QDialog(parent),
selectedPartitionName("")
{
setupUi(this);
model = new QStringListModel(this);
listPartitions->setModel(model);
connect(listPartitions, SIGNAL(clicked(const QModelIndex)), this, SLOT(partitionClicked(QModelIndex)));
}
Partitions::~Partitions() {
}
void Partitions::populatePartitions() {
QString myQuery = QString(GETPARTITIONS);
QSqlQuery query(myQuery);
QStringList partList;
while (query.next()) {
QString partitionName = query.value(0).toString();
partList << partitionName;
}
model->setStringList(partList);
}
void Partitions::on_btnOk_clicked() {
this->accept();
}
void Partitions::on_btnCancel_clicked() {
this->reject();
}
const QString& Partitions::selectedPartition() {
return selectedPartitionName;
}
void Partitions::partitionClicked(QModelIndex current) {
selectedPartitionName = current.data().toString();
}