From 9e26cfa167778f3d9444aedcb23c8476683b3785 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 19 Sep 2017 15:30:48 +0200 Subject: examples: minor code revamping in recipes Task-number: QTBUG-60660 Change-Id: I396f64c770f4ccbf5b2bbd6240ccb4618df70b23 Reviewed-by: Friedemann Kleint --- examples/xmlpatterns/recipes/querymainwindow.cpp | 17 +++++++++-------- examples/xmlpatterns/recipes/querymainwindow.h | 2 +- examples/xmlpatterns/shared/xmlsyntaxhighlighter.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/xmlpatterns/recipes/querymainwindow.cpp b/examples/xmlpatterns/recipes/querymainwindow.cpp index 9a543d5..f24185b 100644 --- a/examples/xmlpatterns/recipes/querymainwindow.cpp +++ b/examples/xmlpatterns/recipes/querymainwindow.cpp @@ -38,15 +38,15 @@ ** ****************************************************************************/ -#include -#include +#include +#include #include #include "querymainwindow.h" #include "xmlsyntaxhighlighter.h" //! [0] -QueryMainWindow::QueryMainWindow() : ui_defaultQueries(0) +QueryMainWindow::QueryMainWindow() { setupUi(this); @@ -55,14 +55,15 @@ QueryMainWindow::QueryMainWindow() : ui_defaultQueries(0) ui_defaultQueries = findChild("defaultQueries"); QMetaObject::connectSlotsByName(this); - connect(ui_defaultQueries, SIGNAL(currentIndexChanged(int)), SLOT(displayQuery(int))); + + connect(ui_defaultQueries, QOverload::of(&QComboBox::currentIndexChanged), + this, &QueryMainWindow::displayQuery); loadInputFile(); const QStringList queries(QDir(":/files/", "*.xq").entryList()); - int len = queries.count(); - for(int i = 0; i < len; ++i) - ui_defaultQueries->addItem(queries.at(i)); - if (len > 0) + for (const auto &query : queries) + ui_defaultQueries->addItem(query); + if (queries.count() > 0) displayQuery(0); } //! [0] diff --git a/examples/xmlpatterns/recipes/querymainwindow.h b/examples/xmlpatterns/recipes/querymainwindow.h index 25ffaab..7961d88 100644 --- a/examples/xmlpatterns/recipes/querymainwindow.h +++ b/examples/xmlpatterns/recipes/querymainwindow.h @@ -62,7 +62,7 @@ public slots: void displayQuery(int index); private: - QComboBox* ui_defaultQueries; + QComboBox *ui_defaultQueries = nullptr; void evaluate(const QString &str); void loadInputFile(); diff --git a/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h index 7a104d5..bdd379c 100644 --- a/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h +++ b/examples/xmlpatterns/shared/xmlsyntaxhighlighter.h @@ -47,7 +47,7 @@ class XmlSyntaxHighlighter : public QSyntaxHighlighter { public: - XmlSyntaxHighlighter(QTextDocument *parent = 0); + explicit XmlSyntaxHighlighter(QTextDocument *parent = nullptr); protected: virtual void highlightBlock(const QString &text); -- cgit v1.2.1