From 3d67793a9ec01f15e3dcf6b59e6e0df5f59bdfad Mon Sep 17 00:00:00 2001 From: Michael Winkelmann Date: Thu, 20 Jul 2017 16:39:01 +0200 Subject: Revamp SQL examples to C++11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: André Hartmann Reviewed-by: Friedemann Kleint --- examples/sql/masterdetail/dialog.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'examples/sql/masterdetail/dialog.cpp') 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); -- cgit v1.2.3