Редакция 3 | Редакция 6 | К новейшей редакции | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 3 | Редакция 4 | ||
---|---|---|---|
Строка 16... | Строка 16... | ||
16 | dbLayout->addWidget(dbLabel); |
16 | dbLayout->addWidget(dbLabel); |
17 | dbLayout->addWidget(dbCombo); |
17 | dbLayout->addWidget(dbCombo); |
18 | dbLayout->addWidget(dbPrefButton); |
18 | dbLayout->addWidget(dbPrefButton); |
19 | dbLayout->addWidget(dbConnectButton); |
19 | dbLayout->addWidget(dbConnectButton); |
20 | 20 | ||
- | 21 | QGroupBox *queryGroup = new QGroupBox("Query"); |
|
21 | queryEdit = new QTextEdit; |
22 | queryEdit = new QTextEdit; |
22 | QPushButton *queryExecButton = new QPushButton("Exec"); |
23 | QPushButton *queryExecButton = new QPushButton("Exec"); |
23 | QHBoxLayout *queryLayout = new QHBoxLayout; |
24 | QHBoxLayout *queryLayout = new QHBoxLayout; |
24 | queryLayout->addWidget(queryEdit); |
25 | queryLayout->addWidget(queryEdit); |
25 | queryLayout->addWidget(queryExecButton); |
26 | queryLayout->addWidget(queryExecButton); |
- | 27 | queryGroup->setLayout(queryLayout); |
|
26 | 28 | ||
- | 29 | QGroupBox *logGroup = new QGroupBox("Log"); |
|
- | 30 | logEdit = new QTextEdit; |
|
- | 31 | logEdit->setReadOnly(true); |
|
- | 32 | QHBoxLayout *logLayout = new QHBoxLayout; |
|
- | 33 | logLayout->addWidget(logEdit); |
|
- | 34 | logGroup->setLayout(logLayout); |
|
- | 35 | ||
- | 36 | QGroupBox *resultGroup = new QGroupBox("Result"); |
|
27 | resultTable = new QTableView; |
37 | resultTable = new QTableView; |
28 | resultModel = new QSqlQueryModel; |
38 | resultModel = new QSqlQueryModel; |
- | 39 | QHBoxLayout *resultLayout = new QHBoxLayout; |
|
- | 40 | resultLayout->addWidget(resultTable); |
|
- | 41 | resultGroup->setLayout(resultLayout); |
|
29 | 42 | ||
30 | QWidget *mainWidget = new QWidget; |
43 | QWidget *mainWidget = new QWidget; |
31 | QVBoxLayout *mainLayout = new QVBoxLayout; |
44 | QVBoxLayout *mainLayout = new QVBoxLayout; |
32 | mainLayout->addLayout(dbLayout); |
45 | mainLayout->addLayout(dbLayout); |
33 | mainLayout->addLayout(queryLayout); |
46 | mainLayout->addWidget(queryGroup); |
- | 47 | mainLayout->addWidget(logGroup); |
|
34 | mainLayout->addWidget(resultTable); |
48 | mainLayout->addWidget(resultGroup); |
35 | 49 | ||
36 | mainWidget->setLayout(mainLayout); |
50 | mainWidget->setLayout(mainLayout); |
37 | setCentralWidget(mainWidget); |
51 | setCentralWidget(mainWidget); |
38 | 52 | ||
39 | connect(queryExecButton,SIGNAL(clicked()),this,SLOT(queryExec())); |
53 | connect(queryExecButton,SIGNAL(clicked()),this,SLOT(queryExec())); |
Строка 47... | Строка 61... | ||
47 | 61 | ||
48 | }
|
62 | }
|
49 | 63 | ||
50 | void MainWindow::queryExec() |
64 | void MainWindow::queryExec() |
51 | {
|
65 | {
|
- | 66 | statusBar()->showMessage("SQL process..."); |
|
52 | resultModel->setQuery(queryEdit->toPlainText()); |
67 | resultModel->setQuery(queryEdit->toPlainText()); |
53 | resultTable->setModel(resultModel); |
68 | resultTable->setModel(resultModel); |
54 | resultTable->show(); |
69 | resultTable->show(); |
- | 70 | ||
- | 71 | if(resultModel->lastError().isValid()) |
|
55 | statusBar()->showMessage(resultModel->lastError().text()); |
72 | logEdit->insertPlainText(resultModel->lastError().text()); |
- | 73 | else logEdit->insertPlainText("No error."); |
|
- | 74 | logEdit->insertPlainText("\n"); |
|
- | 75 | statusBar()->showMessage("Ready"); |
|
56 | }
|
76 | }
|
57 | 77 | ||
58 | void MainWindow::settingsDB() |
78 | void MainWindow::settingsDB() |
59 | {
|
79 | {
|
60 | DbConfigDialog *dbc = new DbConfigDialog(); |
80 | DbConfigDialog *dbc = new DbConfigDialog(); |