diff options
author | Arno <arno@disconnect.de> | 2017-12-31 21:53:06 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-12-31 21:53:06 +0100 |
commit | 640ffd5ce718b97148ad0260a7ac5d356a095b7a (patch) | |
tree | a4c0f726b0ffdf72fc71ee8aac079964383b71c8 /dbanalyzer.cpp | |
parent | 98819e4ce68fef0f02eddb6728a1eb9fa322fade (diff) | |
download | SheMov-640ffd5ce718b97148ad0260a7ac5d356a095b7a.tar.gz SheMov-640ffd5ce718b97148ad0260a7ac5d356a095b7a.tar.bz2 SheMov-640ffd5ce718b97148ad0260a7ac5d356a095b7a.zip |
Give DbAnalyzer some love
* use type-safe connect syntax
* remove unnecessary includes
* remove Q_FOREACH
* inline selectionModel()
Diffstat (limited to 'dbanalyzer.cpp')
-rw-r--r-- | dbanalyzer.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/dbanalyzer.cpp b/dbanalyzer.cpp index c0b47ff..1818e49 100644 --- a/dbanalyzer.cpp +++ b/dbanalyzer.cpp @@ -6,19 +6,12 @@ */ #include <QSqlQuery> -#include <QtWidgets/QPushButton> -#include <QtWidgets/QLabel> -#include <QtWidgets/QMenu> -#include <QtWidgets/QStackedLayout> - +#include <QPushButton> +#include <QLabel> +#include <QStackedLayout> #include <QStandardItemModel> -#include <QItemSelectionModel> #include "dbanalyzer.h" -#include "smtreemodel.h" -#include "smtreeitem.h" -#include "smglobals.h" -#include "smtreeview.h" DbEmptyDialog::DbEmptyDialog(const QString &caption, QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ mDb = QSqlDatabase::database("treedb"); @@ -29,15 +22,15 @@ DbEmptyDialog::DbEmptyDialog(const QString &caption, QWidget *parent, Qt::Window mModel = new QStandardItemModel; mView->setModel(mModel); - mDelete = new QPushButton(tr("Delete")); - connect(mDelete, SIGNAL(clicked()), this, SLOT(deleteItem())); - mClose = new QPushButton(tr("Close")); - connect(mClose, SIGNAL(clicked()), this, SLOT(accept())); + QPushButton *deleteBtn = new QPushButton(tr("Delete")); + connect(deleteBtn, &QPushButton::clicked, this, &DbEmptyDialog::deleteItem); + QPushButton *closeBtn = new QPushButton(tr("Close")); + connect(closeBtn, &QPushButton::clicked, this, &DbEmptyDialog::accept); QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addWidget(mDelete); + buttonLayout->addWidget(deleteBtn); buttonLayout->addStretch(); - buttonLayout->addWidget(mClose); + buttonLayout->addWidget(closeBtn); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(l); @@ -46,10 +39,6 @@ DbEmptyDialog::DbEmptyDialog(const QString &caption, QWidget *parent, Qt::Window setLayout(mainLayout); } -QItemSelectionModel *DbEmptyDialog::selectionModel(){ - return mView->selectionModel(); -} - void DbEmptyDialog::populate(){ return; } @@ -83,7 +72,7 @@ void EmptyActorsDialog::deleteItem(){ } QSqlQuery deleteQ(db()); deleteQ.prepare("DELETE FROM actors WHERE iactors_id = :id"); - foreach(QModelIndex i, sel){ + for(const QModelIndex &i : sel){ QStandardItem *item = model()->itemFromIndex(i); deleteQ.bindValue(":id", item->data()); deleteQ.exec(); @@ -116,7 +105,7 @@ void EmptyGenresDialog::deleteItem(){ } QSqlQuery deleteQ(db()); deleteQ.prepare("DELETE FROM genres WHERE igenres_id = :id"); - foreach(QModelIndex i, sel){ + for(const QModelIndex &i : sel){ QStandardItem *item = model()->itemFromIndex(i); deleteQ.bindValue(":id", item->data()); deleteQ.exec(); @@ -148,7 +137,7 @@ void EmptySeriesDialog::deleteItem(){ } QSqlQuery deleteQ(db()); deleteQ.prepare("DELETE FROM series WHERE iseries_id = :id"); - foreach(QModelIndex i, sel){ + for(const QModelIndex &i : sel){ QStandardItem *item = model()->itemFromIndex(i); deleteQ.bindValue(":id", item->data()); deleteQ.exec(); @@ -188,7 +177,7 @@ void EmptyPartsDialog::deleteItem(){ } QSqlQuery deleteQ(db()); deleteQ.prepare("DELETE FROM seriesparts WHERE iseriesparts_id = :id"); - foreach(QModelIndex i, sel){ + for(const QModelIndex &i : sel){ QStandardItem *item = model()->itemFromIndex(i); deleteQ.bindValue(":id", item->data()); deleteQ.exec(); |