After an insert, update, delete the number of rows affected is reported.

This also makes it clearer the command was executed succesfully.

Times are now printed with no more then two decimals. This prevents confusion
between thousand and decimal seperators.
This commit is contained in:
Eelke Klein 2017-01-16 18:56:07 +01:00
parent 5831f18008
commit fa9787adfd
5 changed files with 68 additions and 36 deletions

View file

@ -25,7 +25,7 @@ namespace {
{
QString unit;
float val;
int deci = 3;
int deci = 2;
if (ms < 1.0f) {
val = ms * 1000.f;
//result = QString::asprintf("%0.3f", ms * 1000.0f);
@ -53,14 +53,15 @@ namespace {
unit = "ms";
}
if (val >= 1000.f) {
// if (val >= 1000.f) {
// deci = 0;
// }
// else
if (val >= 100.f) {
deci = 0;
}
else if (val >= 100.f) {
deci = 1;
}
else if (val >= 10.f) {
deci = 2;
deci = 1;
}
QString result = QString::asprintf("%0.*f", deci, val);
return result + unit;
@ -238,38 +239,46 @@ void MainWindow::query_ready(std::shared_ptr<Pgsql::Result> dbres)
statusBar()->showMessage(tr("Query ready."));
}
else {
if (st == PGRES_EMPTY_QUERY) {
statusBar()->showMessage(tr("Empty query."));
}
else if (st == PGRES_COMMAND_OK) {
if (st == PGRES_COMMAND_OK) {
statusBar()->showMessage(tr("Command OK."));
}
else if (st == PGRES_COPY_OUT) {
statusBar()->showMessage(tr("COPY OUT."));
}
else if (st == PGRES_COPY_IN) {
statusBar()->showMessage(tr("COPY IN."));
}
else if (st == PGRES_BAD_RESPONSE) {
statusBar()->showMessage(tr("BAD RESPONSE."));
}
else if (st == PGRES_NONFATAL_ERROR) {
statusBar()->showMessage(tr("NON FATAL ERROR."));
}
else if (st == PGRES_FATAL_ERROR) {
statusBar()->showMessage(tr("FATAL ERROR."));
}
else if (st == PGRES_COPY_BOTH) {
statusBar()->showMessage(tr("COPY BOTH shouldn't happen is for replication."));
}
else if (st == PGRES_SINGLE_TUPLE) {
statusBar()->showMessage(tr("SINGLE TUPLE result."));
QString msg = tr("Query returned succesfully: %1 rows affected, %2 execution time.")
.arg(QString::number(dbres->tuplesAffected()))
.arg(msfloatToHumanReadableString(elapsedTime.count()));
ui->messagesEdit->append(msg);
ui->tabWidget->setCurrentWidget(ui->messageTab);
}
else {
statusBar()->showMessage(tr("No tuples returned, possibly an error..."));
if (st == PGRES_EMPTY_QUERY) {
statusBar()->showMessage(tr("Empty query."));
}
else if (st == PGRES_COPY_OUT) {
statusBar()->showMessage(tr("COPY OUT."));
}
else if (st == PGRES_COPY_IN) {
statusBar()->showMessage(tr("COPY IN."));
}
else if (st == PGRES_BAD_RESPONSE) {
statusBar()->showMessage(tr("BAD RESPONSE."));
}
else if (st == PGRES_NONFATAL_ERROR) {
statusBar()->showMessage(tr("NON FATAL ERROR."));
}
else if (st == PGRES_FATAL_ERROR) {
statusBar()->showMessage(tr("FATAL ERROR."));
}
else if (st == PGRES_COPY_BOTH) {
statusBar()->showMessage(tr("COPY BOTH shouldn't happen is for replication."));
}
else if (st == PGRES_SINGLE_TUPLE) {
statusBar()->showMessage(tr("SINGLE TUPLE result."));
}
else {
statusBar()->showMessage(tr("No tuples returned, possibly an error..."));
}
ui->tabWidget->setCurrentWidget(ui->messageTab);
receiveNotice(dbres->diagDetails());
}
ui->tabWidget->setCurrentWidget(ui->messageTab);
receiveNotice(dbres->diagDetails());
}
}
else {
@ -382,6 +391,7 @@ void MainWindow::updateTimer()
{
auto nu = std::chrono::steady_clock::now();
std::chrono::duration<float, std::milli> diff = nu - m_startTime;
elapsedTime = diff;
m_timeElapsedLabel->setText(msfloatToHumanReadableString(diff.count()));