-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
66 lines (47 loc) · 1.6 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "modelloader.h"
#include "fsqlrelationaldelegate.h"
#include "sqlutil.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlRecord>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow), m_model(0)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_btnOpen_clicked()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
db.setHostName("10.154.126.13");
db.setPort(1521);
db.setDatabaseName("DEV");
db.setUserName("epccq");
db.setPassword("epccq");
Sql::addGlobalFilter("_CNTR_CODIGO", "EXXI-EXT2");
if(db.open()) qDebug("Banco de dados aberto");
else qDebug("Falha oa abrir o banco de dados");
}
void MainWindow::on_btnRefresh_clicked()
{
if(!m_model)
{
m_model = new FBaseSqlTableModel(this);
m_model->setTable("folha_servico_medicao");
m_model->setRelation("FOSM_UNME_ID", "UNIDADE_MEDIDA", "UNME_ID", "UNME_NOME");
// m_model->setTable("MENSAGEM_SISTEMA_IDIOMA");
// m_model->sort(m_model->record().indexOf("MSID_ID"), Qt::AscendingOrder);
m_model->setRelation("MSID_MSGS_ID", "MENSAGEM_SISTEMA", "MSGS_ID", "MSGS_CODIGO");
m_model->setRelation("MSID_IDIO_ID", "IDIOMA", "IDIO_ID", "IDIO_NOME");
ui->tableView->setModel(m_model);
ui->tableView->setItemDelegate(new FSqlRelationalDelegate(ui->tableView));
}
m_model->select(FBaseSqlTableModel::ParallelFetch);
//qDebug() << Sql::getGlobalFilter(m_model->tableName(), m_model->database());
}