summaryrefslogtreecommitdiffstats
path: root/examples/sql/masterdetail/dialog.cpp
diff options
context:
space:
mode:
authorMichael Winkelmann <Michael.winkelmann@qt.io>2017-07-20 16:39:01 +0200
committerTopi Reiniö <topi.reinio@qt.io>2017-09-14 10:48:48 +0000
commit3d67793a9ec01f15e3dcf6b59e6e0df5f59bdfad (patch)
treee8bd72349e2580e2dfb4908a96653f3fa3644922 /examples/sql/masterdetail/dialog.cpp
parent590e71a69cc74b4e7da1ccb19a1304047dbaecb8 (diff)
Revamp SQL examples to C++11
Changed signals and slots to new syntax, used nullptr and replaced foreach with new C++11 range based for loops. Also fixed a few minor flaws. Task-number: QTBUG-60633 Change-Id: Ice4030133971912f96752d9d84c638c70fd73e35 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/sql/masterdetail/dialog.cpp')
-rw-r--r--examples/sql/masterdetail/dialog.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/sql/masterdetail/dialog.cpp b/examples/sql/masterdetail/dialog.cpp
index 5bb213230e..bb1812eace 100644
--- a/examples/sql/masterdetail/dialog.cpp
+++ b/examples/sql/masterdetail/dialog.cpp
@@ -155,12 +155,12 @@ int Dialog::addNewAlbum(const QString &title, int artistId)
return id;
}
-void Dialog::addTracks(int albumId, QStringList tracks)
+void Dialog::addTracks(int albumId, const QStringList &tracks)
{
QDomElement albumNode = albumDetails.createElement("album");
albumNode.setAttribute("id", albumId);
- for (int i = 0; i < tracks.count(); i++) {
+ for (int i = 0; i < tracks.count(); ++i) {
QString trackNumber = QString::number(i);
if (i < 10)
trackNumber.prepend('0');
@@ -254,9 +254,9 @@ QDialogButtonBox *Dialog::createButtons()
closeButton->setDefault(true);
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
- connect(revertButton, SIGNAL(clicked()), this, SLOT(revert()));
- connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
+ connect(closeButton, &QPushButton::clicked, this, &Dialog::close);
+ connect(revertButton, &QPushButton::clicked, this, &Dialog::revert);
+ connect(submitButton, &QPushButton::clicked, this, &Dialog::submit);
QDialogButtonBox *buttonBox = new QDialogButtonBox;
buttonBox->addButton(submitButton, QDialogButtonBox::ResetRole);
@@ -270,7 +270,7 @@ QModelIndex Dialog::indexOfArtist(const QString &artist)
{
QSqlTableModel *artistModel = model->relationModel(2);
- for (int i = 0; i < artistModel->rowCount(); i++) {
+ for (int i = 0; i < artistModel->rowCount(); ++i) {
QSqlRecord record = artistModel->record(i);
if (record.value("artist") == artist)
return artistModel->index(i, 1);