Notices and errors are as before switch might need still some work.
This commit is contained in:
parent
a36bf5f7f4
commit
2502aea9e5
4 changed files with 49 additions and 33 deletions
|
|
@ -29,7 +29,6 @@ const char * test_query =
|
|||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
// , queryCancel(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
|
@ -59,6 +58,11 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
{
|
||||
QueueTask([this, st]() { connectionStateChanged(st); });
|
||||
});
|
||||
|
||||
m_dbConnection.setNoticeCallback([this](Pgsql::ErrorDetails details)
|
||||
{
|
||||
QueueTask([this, details]() { receiveNotice(details); });
|
||||
});
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
|
@ -171,7 +175,7 @@ void MainWindow::query_ready(std::shared_ptr<Pgsql::Result> dbres)
|
|||
else {
|
||||
statusBar()->showMessage(tr("No tuples returned, possibly an error..."));
|
||||
}
|
||||
//receiveNotice(dbres->diagDetails());
|
||||
receiveNotice(dbres->diagDetails());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -236,29 +240,22 @@ void MainWindow::cancel_query()
|
|||
m_dbConnection.cancel();
|
||||
}
|
||||
|
||||
//void MainWindow::processNotice(const PGresult *result)
|
||||
//{
|
||||
// qRegisterMetaType<Pgsql::ErrorDetails>("Pgsql::ErrorDetails");
|
||||
// pg::ErrorDetails details = pg::ErrorDetails::createErrorDetailsFromPGresult(result);
|
||||
// QMetaObject::invokeMethod(this, "receiveNotice", Qt::AutoConnection, Q_ARG(Pgsql::ErrorDetails, details)); // queues on main thread
|
||||
//}
|
||||
|
||||
//void MainWindow::receiveNotice(Pgsql::ErrorDetails notice)
|
||||
//{
|
||||
// QTextCursor cursor = ui->messagesEdit->textCursor();
|
||||
// cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||
void MainWindow::receiveNotice(Pgsql::ErrorDetails notice)
|
||||
{
|
||||
QTextCursor cursor = ui->messagesEdit->textCursor();
|
||||
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||
|
||||
|
||||
//// QString msg;
|
||||
//// cursor.insertText("TEST\r\n");
|
||||
// QString msg;
|
||||
// cursor.insertText("TEST\r\n");
|
||||
|
||||
// QTextTable *table = cursor.insertTable(4, 2);
|
||||
// if (table) {
|
||||
// table->cellAt(1, 0).firstCursorPosition().insertText("State");
|
||||
// table->cellAt(1, 1).firstCursorPosition().insertText(QString::fromStdString(notice.state));
|
||||
// table->cellAt(2, 0).firstCursorPosition().insertText("Primary");
|
||||
// table->cellAt(2, 1).firstCursorPosition().insertText(QString::fromStdString(notice.messagePrimary));
|
||||
// table->cellAt(3, 0).firstCursorPosition().insertText("Detail");
|
||||
// table->cellAt(3, 1).firstCursorPosition().insertText(QString::fromStdString(notice.messageDetail));
|
||||
// }
|
||||
//}
|
||||
QTextTable *table = cursor.insertTable(4, 2);
|
||||
if (table) {
|
||||
table->cellAt(1, 0).firstCursorPosition().insertText("State");
|
||||
table->cellAt(1, 1).firstCursorPosition().insertText(QString::fromStdString(notice.state));
|
||||
table->cellAt(2, 0).firstCursorPosition().insertText("Primary");
|
||||
table->cellAt(2, 1).firstCursorPosition().insertText(QString::fromStdString(notice.messagePrimary));
|
||||
table->cellAt(3, 0).firstCursorPosition().insertText("Detail");
|
||||
table->cellAt(3, 1).firstCursorPosition().insertText(QString::fromStdString(notice.messageDetail));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue