Commit 06022b76 authored by Hugo Hörnquist's avatar Hugo Hörnquist

Add sqlQueryBuffer remove button

parent 838fdc30
......@@ -1064,3 +1064,23 @@ void MainWindow::on_sqlPrint_clicked()
connect(&dialog, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printTable(QPrinter*)));
dialog.exec();
}
void MainWindow::on_sqlBufferDeleteButton_clicked()
{
QSqlTableModel* model = (QSqlTableModel*) ui->sqlBufferList->model();
QSqlQuery query;
query.prepare("delete from sql_queries where id = ?");
QVariantList ids;
foreach (QModelIndex index, ui->sqlBufferList->selectionModel()->selectedRows())
{
ids << model->data(model->index(index.row(), 0));
}
query.addBindValue(ids);
if (!query.execBatch())
qDebug() << query.lastError();
model->select();
}
......@@ -98,6 +98,8 @@ private slots:
void printTable(QPrinter* printer);
void on_sqlBufferDeleteButton_clicked();
private:
Ui::MainWindow *ui;
QSqlTableModel* model;
......
......@@ -1020,6 +1020,30 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sqlBufferDeleteButton">
<property name="text">
<string>Ta bort</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment