partial selects and a hotkey for execute query

show the correct queryPart
also add some thoughts of me
This commit is contained in:
Peinthor Rene
2013-03-27 08:12:56 +01:00
parent c6d5391672
commit 7644364130
2 changed files with 26 additions and 5 deletions

View File

@@ -743,9 +743,20 @@ void MainWindow::doubleClickTable(const QModelIndex& index)
editText(index.row(), index.column());
}
/*
* I'm still not happy how the results are represented to the user
* right now you only see the result of the last executed statement.
* A better experiance would be tabs on the bottom with query results
* for all the executed statements.
* Or at least a some way the use could see results/status message
* per executed statement.
*/
void MainWindow::executeQuery()
{
QString query = ui->sqlTextEdit->toPlainText().trimmed();
// if a part of the query is selected, we will only execute this part
QString query = ui->sqlTextEdit->textCursor().selectedText();
if(query.isEmpty())
query = ui->sqlTextEdit->toPlainText().trimmed();
if (query.isEmpty())
return;
@@ -765,9 +776,10 @@ void MainWindow::executeQuery()
queryResultListModel->setHorizontalHeaderLabels(QStringList());
queryResultListModel->setVerticalHeaderLabels(QStringList());
QString queryPart = tail;
const char* qbegin = tail;
sql3status = sqlite3_prepare_v2(db._db,tail,utf8Query.length(),
&vm, &tail);
QString queryPart = QString::fromUtf8(qbegin, tail - qbegin);
if (sql3status == SQLITE_OK){
int rownum = 0;
bool mustCreateColumns = true;
@@ -800,12 +812,15 @@ void MainWindow::executeQuery()
} while ( sqlite3_step(vm) == SQLITE_ROW );
sql3status = SQLITE_OK;
}
break;
case SQLITE_DONE:
statusMessage = tr("%1 Rows returned from: %2").arg(rownum).arg(queryPart);
case SQLITE_OK:
{
if( !queryPart.trimmed().startsWith("SELECT", Qt::CaseInsensitive))
{
db.setRestorePoint();
statusMessage = tr("Query executed successfully: %1").arg(queryPart);
}
}
break;
default:

View File

@@ -798,7 +798,10 @@
</size>
</property>
<property name="toolTip">
<string>Execute SQL query</string>
<string>Execute SQL query (CTRL+E)</string>
</property>
<property name="statusTip">
<string>Execute SQL query (CTRL+E)</string>
</property>
<property name="whatsThis">
<string>This button is used to execute the SQL query entered in the text area above.</string>
@@ -806,12 +809,15 @@
<property name="text">
<string>Execute query</string>
</property>
<property name="shortcut">
<string>Ctrl+E</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Error message from database engine:</string>
<string>Status:</string>
</property>
<property name="buddy">
<cstring>queryErrorLineEdit</cstring>