From c61d86e7b2ceedbe6c9afada2ab55ac39ce6b47b Mon Sep 17 00:00:00 2001 From: Skycoder42 Date: Sat, 16 Jun 2018 23:12:03 +0200 Subject: [PATCH] general code cleanups --- .qmake.conf | 2 +- src/imports/mvvmcore/mvvmcore.pro | 2 +- src/imports/mvvmcore/qqmlmvvmmessage.cpp | 10 ++-- .../mvvmdatasynccore/mvvmdatasynccore.pro | 2 +- .../mvvmdatasyncquick/mvvmdatasyncquick.pro | 2 +- src/imports/mvvmquick/androidfilechooser.cpp | 2 +- src/imports/mvvmquick/androidfilechooser.h | 2 +- .../mvvmquick/multifilterproxymodel.cpp | 2 +- src/imports/mvvmquick/qqmlquickpresenter.cpp | 5 +- src/imports/mvvmquick/qqmlquickpresenter.h | 4 +- src/imports/mvvmquick/settingsentrymodel.cpp | 14 ++--- src/imports/mvvmquick/settingsentrymodel.h | 2 +- .../mvvmquick/settingssectionmodel.cpp | 16 +++--- src/imports/mvvmquick/settingssectionmodel.h | 2 +- src/imports/mvvmquick/settingsuibuilder.cpp | 24 +++----- src/imports/mvvmquick/settingsuibuilder.h | 8 +-- src/mvvmcore/binding.cpp | 18 +++--- src/mvvmcore/binding_p.h | 12 ++-- src/mvvmcore/coreapp.cpp | 2 +- src/mvvmcore/coreapp.h | 2 +- src/mvvmcore/ipresenter.h | 2 + src/mvvmcore/message.cpp | 55 ++++++------------- src/mvvmcore/message.h | 8 ++- src/mvvmcore/message_p.h | 4 +- src/mvvmcore/qtmvvmcore_helpertypes.h | 18 +++--- src/mvvmcore/serviceregistry.cpp | 16 +++--- src/mvvmcore/serviceregistry.h | 12 ++-- src/mvvmcore/serviceregistry_p.h | 5 +- src/mvvmcore/settingssetup.h | 2 + src/mvvmcore/settingssetuploader.cpp | 23 ++++---- src/mvvmcore/settingssetuploader_p.h | 2 +- src/mvvmcore/settingsviewmodel.cpp | 2 +- src/mvvmcore/settingsviewmodel.h | 2 +- src/mvvmcore/viewmodel.cpp | 12 ++-- src/mvvmcore/viewmodel.h | 16 +++--- src/mvvmcore/viewmodel_p.h | 6 +- src/mvvmdatasynccore/accountmodel.cpp | 2 +- src/mvvmdatasynccore/accountmodel.h | 2 +- .../changeremoteviewmodel.cpp | 12 ++-- .../changeremoteviewmodel_p.h | 8 +-- src/mvvmdatasynccore/datasyncviewmodel.cpp | 34 +++++------- src/mvvmdatasynccore/datasyncviewmodel.h | 4 +- src/mvvmdatasynccore/datasyncviewmodel_p.h | 4 +- src/mvvmdatasynccore/exchangedevicesmodel.cpp | 7 ++- src/mvvmdatasynccore/exchangedevicesmodel.h | 2 +- src/mvvmdatasynccore/exportsetupviewmodel.cpp | 8 +-- src/mvvmdatasynccore/exportsetupviewmodel_p.h | 4 +- .../identityeditviewmodel.cpp | 7 +-- .../identityeditviewmodel_p.h | 4 +- .../networkexchangeviewmodel.cpp | 22 +++----- .../networkexchangeviewmodel.h | 2 +- .../networkexchangeviewmodel_p.h | 6 +- .../changeremotedialog.cpp | 2 +- .../changeremotedialog_p.h | 2 +- src/mvvmdatasyncwidgets/datasyncwindow.cpp | 2 +- src/mvvmdatasyncwidgets/datasyncwindow.h | 2 +- src/mvvmdatasyncwidgets/exportsetupdialog.cpp | 2 +- src/mvvmdatasyncwidgets/exportsetupdialog_p.h | 2 +- .../identityeditdialog.cpp | 2 +- .../identityeditdialog_p.h | 2 +- .../networkexchangewindow.cpp | 4 +- .../networkexchangewindow.h | 2 +- src/mvvmquick/inputviewfactory.cpp | 2 +- src/mvvmquick/inputviewfactory.h | 2 +- src/mvvmquick/quickpresenter.cpp | 13 +---- src/mvvmquick/quickpresenter.h | 2 +- src/mvvmquick/quickpresenter_p.h | 6 +- src/mvvmwidgets/inputwidgetfactory.cpp | 2 +- src/mvvmwidgets/inputwidgetfactory.h | 2 +- src/mvvmwidgets/ipresentingview.h | 2 + src/mvvmwidgets/selectcombobox.cpp | 2 +- src/mvvmwidgets/selectcombobox_p.h | 2 +- src/mvvmwidgets/settingsdialog.cpp | 30 +++++----- src/mvvmwidgets/settingsdialog.h | 2 +- src/mvvmwidgets/settingsdialog_p.h | 14 +++-- src/mvvmwidgets/widgetspresenter.cpp | 18 +++--- src/mvvmwidgets/widgetspresenter.h | 2 +- src/mvvmwidgets/widgetspresenter_p.h | 4 +- 78 files changed, 256 insertions(+), 317 deletions(-) diff --git a/.qmake.conf b/.qmake.conf index 05a1908..2b3a44a 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -7,6 +7,6 @@ DEFINES += QT_DEPRECATED_WARNINGS QT_ASCII_CAST_WARNINGS MODULE_VERSION_MAJOR = 1 MODULE_VERSION_MINOR = 0 -MODULE_VERSION_PATCH = 0 +MODULE_VERSION_PATCH = 2 MODULE_VERSION_IMPORT = $${MODULE_VERSION_MAJOR}.$${MODULE_VERSION_MINOR} MODULE_VERSION = $${MODULE_VERSION_MAJOR}.$${MODULE_VERSION_MINOR}.$${MODULE_VERSION_PATCH} diff --git a/src/imports/mvvmcore/mvvmcore.pro b/src/imports/mvvmcore/mvvmcore.pro index 6a42e54..30cfc77 100644 --- a/src/imports/mvvmcore/mvvmcore.pro +++ b/src/imports/mvvmcore/mvvmcore.pro @@ -20,7 +20,7 @@ OTHER_FILES += qmldir generate_qmltypes { typeextra1.target = qmltypes - typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$(LD_LIBRARY_PATH)" + typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$$[QT_INSTALL_LIBS]:$(LD_LIBRARY_PATH)" typeextra2.target = qmltypes typeextra2.depends += export QML2_IMPORT_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/qml/" QMAKE_EXTRA_TARGETS += typeextra1 typeextra2 diff --git a/src/imports/mvvmcore/qqmlmvvmmessage.cpp b/src/imports/mvvmcore/qqmlmvvmmessage.cpp index 2b732dc..c83b02e 100644 --- a/src/imports/mvvmcore/qqmlmvvmmessage.cpp +++ b/src/imports/mvvmcore/qqmlmvvmmessage.cpp @@ -55,7 +55,7 @@ void QQmlMvvmMessage::getInput(const QString &title, const QString &text, const { if(onResult.isCallable()) { auto engine = _engine; - QtMvvm::getInput(title, text, qUtf8Printable(inputType), this, [engine, onResult](QVariant result){ + QtMvvm::getInput(title, text, qUtf8Printable(inputType), this, [engine, onResult](const QVariant &result){ QJSValue(onResult).call({engine->toScriptValue(result)}); }, defaultValue, viewProperties, okText, cancelText); } else @@ -66,7 +66,7 @@ void QQmlMvvmMessage::getExistingDirectory(const QJSValue &onResult, const QStri { if(onResult.isCallable()) { auto engine = _engine; - QtMvvm::getExistingDirectory(this, [engine, onResult](QUrl url){ + QtMvvm::getExistingDirectory(this, [engine, onResult](const QUrl &url){ QJSValue(onResult).call({engine->toScriptValue(url)}); }, title, dir); } else @@ -77,7 +77,7 @@ void QQmlMvvmMessage::getOpenFile(const QJSValue &onResult, const QString &title { if(onResult.isCallable()) { auto engine = _engine; - QtMvvm::getOpenFile(this, [engine, onResult](QUrl url){ + QtMvvm::getOpenFile(this, [engine, onResult](const QUrl &url){ QJSValue(onResult).call({engine->toScriptValue(url)}); }, title, supportedMimeTypes, dir); } else @@ -88,7 +88,7 @@ void QQmlMvvmMessage::getOpenFiles(const QJSValue &onResult, const QString &titl { if(onResult.isCallable()) { auto engine = _engine; - QtMvvm::getOpenFiles(this, [engine, onResult](QList url){ + QtMvvm::getOpenFiles(this, [engine, onResult](const QList &url){ QJSValue(onResult).call({engine->toScriptValue(url)}); }, title, supportedMimeTypes, dir); } else @@ -99,7 +99,7 @@ void QQmlMvvmMessage::getSaveFile(const QJSValue &onResult, const QString &title { if(onResult.isCallable()) { auto engine = _engine; - QtMvvm::getSaveFile(this, [engine, onResult](QUrl url){ + QtMvvm::getSaveFile(this, [engine, onResult](const QUrl &url){ QJSValue(onResult).call({engine->toScriptValue(url)}); }, title, supportedMimeTypes, dir); } else diff --git a/src/imports/mvvmdatasynccore/mvvmdatasynccore.pro b/src/imports/mvvmdatasynccore/mvvmdatasynccore.pro index acd81c3..3e895ce 100644 --- a/src/imports/mvvmdatasynccore/mvvmdatasynccore.pro +++ b/src/imports/mvvmdatasynccore/mvvmdatasynccore.pro @@ -16,7 +16,7 @@ OTHER_FILES += qmldir generate_qmltypes { typeextra1.target = qmltypes - typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$(LD_LIBRARY_PATH)" + typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$$[QT_INSTALL_LIBS]:$(LD_LIBRARY_PATH)" typeextra2.target = qmltypes typeextra2.depends += export QML2_IMPORT_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/qml/" QMAKE_EXTRA_TARGETS += typeextra1 typeextra2 diff --git a/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro b/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro index 9c5cb9d..19e7858 100644 --- a/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro +++ b/src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro @@ -27,7 +27,7 @@ OTHER_FILES += qmldir generate_qmltypes { typeextra1.target = qmltypes - typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$(LD_LIBRARY_PATH)" + typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$$[QT_INSTALL_LIBS]:$(LD_LIBRARY_PATH)" typeextra2.target = qmltypes typeextra2.depends += export QML2_IMPORT_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/qml/" QMAKE_EXTRA_TARGETS += typeextra1 typeextra2 diff --git a/src/imports/mvvmquick/androidfilechooser.cpp b/src/imports/mvvmquick/androidfilechooser.cpp index a00379c..4a111f2 100644 --- a/src/imports/mvvmquick/androidfilechooser.cpp +++ b/src/imports/mvvmquick/androidfilechooser.cpp @@ -14,7 +14,7 @@ AndroidFileChooser::AndroidFileChooser(QObject *parent) : _result() {} -AndroidFileChooser::~AndroidFileChooser() {} +AndroidFileChooser::~AndroidFileChooser() = default; AndroidFileChooser::ChooserFlags AndroidFileChooser::chooserFlags() const { diff --git a/src/imports/mvvmquick/androidfilechooser.h b/src/imports/mvvmquick/androidfilechooser.h index 84cd929..9dfccb2 100644 --- a/src/imports/mvvmquick/androidfilechooser.h +++ b/src/imports/mvvmquick/androidfilechooser.h @@ -130,7 +130,7 @@ public: //! @private explicit AndroidFileChooser(QObject *parent = nullptr); - ~AndroidFileChooser(); + ~AndroidFileChooser() override; //! @private ChooserFlags chooserFlags() const; diff --git a/src/imports/mvvmquick/multifilterproxymodel.cpp b/src/imports/mvvmquick/multifilterproxymodel.cpp index c81b5ed..2266656 100644 --- a/src/imports/mvvmquick/multifilterproxymodel.cpp +++ b/src/imports/mvvmquick/multifilterproxymodel.cpp @@ -39,7 +39,7 @@ bool MultiFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex & auto rData = sourceModel()->data(sourceModel()->index(source_row, 0, source_parent), role); //try as stringlist auto strList = rData.toStringList(); - for(auto str : strList) { + for(const auto &str : strList) { if(_filterRegex.match(str).hasMatch()) return true; } diff --git a/src/imports/mvvmquick/qqmlquickpresenter.cpp b/src/imports/mvvmquick/qqmlquickpresenter.cpp index 2e20e55..cf574bc 100644 --- a/src/imports/mvvmquick/qqmlquickpresenter.cpp +++ b/src/imports/mvvmquick/qqmlquickpresenter.cpp @@ -51,7 +51,8 @@ QStringList QQmlQuickPresenter::mimeTypeFilters(const QStringList &mimeTypes) co { QMimeDatabase db; QStringList filters; - for(auto mime : mimeTypes) { + filters.reserve(mimeTypes.size()); + for(const auto &mime : mimeTypes) { auto mType = db.mimeTypeForName(mime); if(mType.isValid()) filters.append(mType.filterString()); @@ -183,7 +184,7 @@ void QQmlQuickPresenter::statusChanged(QQmlComponent::Status status) } } -void QQmlQuickPresenter::addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash ¶ms, QPointer parent) +void QQmlQuickPresenter::addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash ¶ms, const QPointer &parent) { if(!_qmlPresenter) { logWarning() << "No QML-Presenter registered! Unable to present viewModel of type" diff --git a/src/imports/mvvmquick/qqmlquickpresenter.h b/src/imports/mvvmquick/qqmlquickpresenter.h index dc0b130..e1dd42e 100644 --- a/src/imports/mvvmquick/qqmlquickpresenter.h +++ b/src/imports/mvvmquick/qqmlquickpresenter.h @@ -158,7 +158,7 @@ private Q_SLOTS: void statusChanged(QQmlComponent::Status status); private: - typedef std::tuple> PresentTuple; + using PresentTuple = std::tuple>; QQmlEngine *_engine; QPointer _qmlPresenter; @@ -166,7 +166,7 @@ private: QCache _componentCache; QHash _loadCache; - void addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash ¶ms, QPointer parent); + void addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash ¶ms, const QPointer &parent); }; } diff --git a/src/imports/mvvmquick/settingsentrymodel.cpp b/src/imports/mvvmquick/settingsentrymodel.cpp index d7a2008..0bb8df3 100644 --- a/src/imports/mvvmquick/settingsentrymodel.cpp +++ b/src/imports/mvvmquick/settingsentrymodel.cpp @@ -22,8 +22,8 @@ void SettingsEntryModel::setup(const SettingsElements::Section §ion, Setting _entries.clear(); _viewModel = viewModel; auto rIndex = 0; - for(auto group : section.groups) { - for(auto entry : group.entries) { + for(const auto &group : section.groups) { + for(const auto &entry : group.entries) { auto url = factory->getDelegate(entry.type, entry.properties); if(group.title.isEmpty()) // unnamed groups are presented first _entries.insert(rIndex++, EntryInfo{entry, url}); @@ -104,14 +104,14 @@ Qt::ItemFlags SettingsEntryModel::flags(const QModelIndex &index) const -SettingsEntryModel::EntryInfo::EntryInfo(SettingsElements::Entry entry, const QUrl &delegateUrl, SettingsElements::Group group) : - Entry(entry), - delegateUrl(delegateUrl), - group(group) +SettingsEntryModel::EntryInfo::EntryInfo(SettingsElements::Entry entry, QUrl delegateUrl, SettingsElements::Group group) : + Entry(std::move(entry)), + delegateUrl(std::move(delegateUrl)), + group(std::move(group)) { static const QRegularExpression nameRegex(QStringLiteral("&(?!&)"), QRegularExpression::DontCaptureOption | QRegularExpression::OptimizeOnFirstUsageOption); title.remove(nameRegex); - group.entries.clear(); + this->group.entries.clear(); } diff --git a/src/imports/mvvmquick/settingsentrymodel.h b/src/imports/mvvmquick/settingsentrymodel.h index a76f53e..123d63b 100644 --- a/src/imports/mvvmquick/settingsentrymodel.h +++ b/src/imports/mvvmquick/settingsentrymodel.h @@ -43,7 +43,7 @@ public: private: struct EntryInfo : public SettingsElements::Entry { public: - EntryInfo(SettingsElements::Entry entry = {}, const QUrl &delegateUrl = {}, SettingsElements::Group group = {}); + EntryInfo(SettingsElements::Entry entry = {}, QUrl delegateUrl = {}, SettingsElements::Group group = {}); QUrl delegateUrl; SettingsElements::Group group; diff --git a/src/imports/mvvmquick/settingssectionmodel.cpp b/src/imports/mvvmquick/settingssectionmodel.cpp index 92febcc..a6f11fd 100644 --- a/src/imports/mvvmquick/settingssectionmodel.cpp +++ b/src/imports/mvvmquick/settingssectionmodel.cpp @@ -21,12 +21,12 @@ void SettingsSectionModel::setup(const SettingsElements::Setup &setup) _sections.clear(); _hasSections = false; auto rIndex = 0; - for(auto category : setup.categories) { + for(const auto &category : setup.categories) { if(category.sections.size() == 1) { // single sects are always at the beginning _hasSections = true; _sections.insert(rIndex++, category); } else { - for(auto section : category.sections) + for(const auto §ion : category.sections) _sections.append(SectionInfo{section, category}); } } @@ -62,9 +62,9 @@ QVariant SettingsSectionModel::data(const QModelIndex &index, int role) const { const auto §ion = _sections[index.row()]; if(section.searchKeys.isEmpty()) { - for(auto group : section.groups) { + for(const auto &group : section.groups) { section.searchKeys.append(group.title); - for(auto entry : group.entries) { + for(const auto &entry : group.entries) { section.searchKeys.append(entry.title); section.searchKeys.append(entry.tooltip); section.searchKeys.append(entry.searchKeys); @@ -97,13 +97,13 @@ bool SettingsSectionModel::hasSections() const SettingsSectionModel::SectionInfo::SectionInfo(SettingsElements::Section section, SettingsElements::Category category) : - Section(section), - category(category) + Section(std::move(section)), + category(std::move(category)) { - category.sections.clear(); + this->category.sections.clear(); } -SettingsSectionModel::SectionInfo::SectionInfo(SettingsElements::Category category) : +SettingsSectionModel::SectionInfo::SectionInfo(const SettingsElements::Category &category) : Section{category.title, category.icon, category.tooltip, category.sections.first().groups, {}, {}}, category() {} diff --git a/src/imports/mvvmquick/settingssectionmodel.h b/src/imports/mvvmquick/settingssectionmodel.h index 7aafbc7..1d8595f 100644 --- a/src/imports/mvvmquick/settingssectionmodel.h +++ b/src/imports/mvvmquick/settingssectionmodel.h @@ -40,7 +40,7 @@ private: struct SectionInfo : public SettingsElements::Section { public: SectionInfo(SettingsElements::Section section = {}, SettingsElements::Category category = {}); - SectionInfo(SettingsElements::Category category); + SectionInfo(const SettingsElements::Category &category); SettingsElements::Category category; mutable QStringList searchKeys; diff --git a/src/imports/mvvmquick/settingsuibuilder.cpp b/src/imports/mvvmquick/settingsuibuilder.cpp index dc8d286..262a420 100644 --- a/src/imports/mvvmquick/settingsuibuilder.cpp +++ b/src/imports/mvvmquick/settingsuibuilder.cpp @@ -14,16 +14,10 @@ using namespace QtMvvm; SettingsUiBuilder::SettingsUiBuilder(QObject *parent) : QObject(parent), - _buildView(nullptr), - _viewModel(nullptr), - _filterText(), - _allowSearch(true), - _allowRestore(true), _sectionFilterModel(new MultiFilterProxyModel(this)), _sectionModel(new SettingsSectionModel(this)), _entryFilterModel(new MultiFilterProxyModel(this)), - _entryModel(new SettingsEntryModel(this)), - _currentSetup() + _entryModel(new SettingsEntryModel(this)) { _sectionFilterModel->setSourceModel(_sectionModel); _sectionFilterModel->addFilterRoles(SettingsSectionModel::FilterRoles); @@ -55,7 +49,7 @@ void SettingsUiBuilder::showDialog(const QString &key, const QString &title, con _viewModel->callAction(key, properties.value(QStringLiteral("args")).toMap()); else { qmlDebug(this) << "Creating input dialog for settings entry" << key; - getInput(title + tr(":"), QString(), qUtf8Printable(type), this, [this, key](QVariant value) { + getInput(title + tr(":"), QString(), qUtf8Printable(type), this, [this, key](const QVariant &value) { if(value.isValid()) _viewModel->saveValue(key, value); }, _viewModel->loadValue(key, defaultValue), properties); @@ -71,10 +65,10 @@ void SettingsUiBuilder::restoreDefaults() connect(result, &MessageResult::dialogDone, this, [this](MessageConfig::StandardButton btn) { if(btn != MessageConfig::Yes) return; - for(auto category : qAsConst(_currentSetup.categories)) { - for(auto section : category.sections) { - for(auto group : section.groups) { - for(auto entry : group.entries) + for(const auto &category : qAsConst(_currentSetup.categories)) { + for(const auto §ion : category.sections) { + for(const auto &group : section.groups) { + for(const auto &entry : group.entries) _viewModel->resetValue(entry.key); } } @@ -88,10 +82,10 @@ void SettingsUiBuilder::setFilterText(QString filterText) if (_filterText == filterText) return; - _filterText = filterText; - emit filterTextChanged(filterText); + _filterText = std::move(filterText); + emit filterTextChanged(_filterText); - QRegularExpression regex(filterText, + QRegularExpression regex(_filterText, QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption | QRegularExpression::DontCaptureOption); diff --git a/src/imports/mvvmquick/settingsuibuilder.h b/src/imports/mvvmquick/settingsuibuilder.h index 0db204c..ab3a921 100644 --- a/src/imports/mvvmquick/settingsuibuilder.h +++ b/src/imports/mvvmquick/settingsuibuilder.h @@ -51,12 +51,12 @@ private Q_SLOTS: void startBuildUi(); private: - QQuickItem* _buildView; - SettingsViewModel *_viewModel; + QQuickItem* _buildView = nullptr; + SettingsViewModel *_viewModel = nullptr; QString _filterText; - bool _allowSearch; - bool _allowRestore; + bool _allowSearch = true; + bool _allowRestore = true; MultiFilterProxyModel *_sectionFilterModel; SettingsSectionModel *_sectionModel; diff --git a/src/mvvmcore/binding.cpp b/src/mvvmcore/binding.cpp index 7504557..19cdc2c 100644 --- a/src/mvvmcore/binding.cpp +++ b/src/mvvmcore/binding.cpp @@ -90,10 +90,10 @@ Binding::Binding() : {} Binding::Binding(QPointer d_ptr) : - d(d_ptr) + d(std::move(d_ptr)) {} -Binding::~Binding() {} +Binding::~Binding() = default; bool Binding::isValid() const { @@ -110,26 +110,26 @@ void Binding::unbind() // ------------- Private Implementation ------------- -Binding BindingPrivate::bind(QObject *viewModel, const QMetaProperty &viewModelProperty, QObject *view, const QMetaProperty &viewProperty, Binding::BindingDirection type, const QMetaMethod &viewModelChangeSignal, const QMetaMethod &viewChangeSignal) +Binding BindingPrivate::bind(QObject *viewModel, QMetaProperty viewModelProperty, QObject *view, QMetaProperty viewProperty, Binding::BindingDirection type, QMetaMethod viewModelChangeSignal, QMetaMethod viewChangeSignal) { - QPointer binderPrivate = new BindingPrivate(viewModel, viewModelProperty, view, viewProperty); + QPointer binderPrivate = new BindingPrivate(viewModel, std::move(viewModelProperty), view, std::move(viewProperty)); if(type.testFlag(Binding::SingleInit)) binderPrivate->init(); if(type.testFlag(Binding::OneWayToView)) - binderPrivate->bindFrom(viewModelChangeSignal); + binderPrivate->bindFrom(std::move(viewModelChangeSignal)); if(type.testFlag(Binding::OneWayToViewModel)) - binderPrivate->bindTo(viewChangeSignal); + binderPrivate->bindTo(std::move(viewChangeSignal)); return binderPrivate; } -BindingPrivate::BindingPrivate(QObject *viewModel, const QMetaProperty &viewModelProperty, QObject *view, const QMetaProperty &viewProperty) : +BindingPrivate::BindingPrivate(QObject *viewModel, QMetaProperty viewModelProperty, QObject *view, QMetaProperty viewProperty) : QObject(view), viewModel(viewModel), view(view), - viewModelProperty(viewModelProperty), - viewProperty(viewProperty) + viewModelProperty(std::move(viewModelProperty)), + viewProperty(std::move(viewProperty)) { connect(viewModel, &QObject::destroyed, this, &BindingPrivate::deleteLater); diff --git a/src/mvvmcore/binding_p.h b/src/mvvmcore/binding_p.h index a0809d2..a8009c0 100644 --- a/src/mvvmcore/binding_p.h +++ b/src/mvvmcore/binding_p.h @@ -15,19 +15,19 @@ class BindingPrivate : public QObject Q_OBJECT public: - static Binding bind(QObject *viewModel, const QMetaProperty &viewModelProperty, - QObject *view, const QMetaProperty &viewProperty, + static Binding bind(QObject *viewModel, QMetaProperty viewModelProperty, + QObject *view, QMetaProperty viewProperty, Binding::BindingDirection type, - const QMetaMethod &viewModelChangeSignal, - const QMetaMethod &viewChangeSignal); + QMetaMethod viewModelChangeSignal, + QMetaMethod viewChangeSignal); private Q_SLOTS: void viewModelTrigger(); void viewTrigger(); private: - BindingPrivate(QObject *viewModel, const QMetaProperty &viewModelProperty, - QObject *view, const QMetaProperty &viewProperty); + BindingPrivate(QObject *viewModel, QMetaProperty viewModelProperty, + QObject *view, QMetaProperty viewProperty); void init(); void bindFrom(QMetaMethod changeSignal); diff --git a/src/mvvmcore/coreapp.cpp b/src/mvvmcore/coreapp.cpp index 3a211c8..c387504 100644 --- a/src/mvvmcore/coreapp.cpp +++ b/src/mvvmcore/coreapp.cpp @@ -15,7 +15,7 @@ CoreApp::CoreApp(QObject *parent) : d(new CoreAppPrivate()) {} -CoreApp::~CoreApp() {} +CoreApp::~CoreApp() = default; CoreApp *CoreApp::instance() { diff --git a/src/mvvmcore/coreapp.h b/src/mvvmcore/coreapp.h index 65870e5..1e1b98b 100644 --- a/src/mvvmcore/coreapp.h +++ b/src/mvvmcore/coreapp.h @@ -24,7 +24,7 @@ class Q_MVVMCORE_EXPORT CoreApp : public QObject public: //! Default Constructor explicit CoreApp(QObject *parent = nullptr); - ~CoreApp(); + ~CoreApp() override; //! Returns the current CoreApp instance static CoreApp *instance(); diff --git a/src/mvvmcore/ipresenter.h b/src/mvvmcore/ipresenter.h index c2c36eb..469bc5a 100644 --- a/src/mvvmcore/ipresenter.h +++ b/src/mvvmcore/ipresenter.h @@ -35,7 +35,9 @@ protected: //! The interface for a GUI view presenter class Q_MVVMCORE_EXPORT IPresenter { + Q_DISABLE_COPY(IPresenter) public: + inline IPresenter() = default; inline virtual ~IPresenter() = default; //! Called to present a viewmodel diff --git a/src/mvvmcore/message.cpp b/src/mvvmcore/message.cpp index bd5e341..4c8e969 100644 --- a/src/mvvmcore/message.cpp +++ b/src/mvvmcore/message.cpp @@ -30,17 +30,15 @@ MessageConfig::MessageConfig(const QByteArray &type, const QByteArray &subType) resetButtons(); } -MessageConfig::MessageConfig(const MessageConfig &other) : - d(other.d) -{} +MessageConfig::MessageConfig(MessageConfig &&other)= default; -MessageConfig::~MessageConfig() {} +MessageConfig::MessageConfig(const MessageConfig &other) = default; -MessageConfig &MessageConfig::operator=(const MessageConfig &other) -{ - d = other.d; - return (*this); -} +MessageConfig::~MessageConfig() = default; + +MessageConfig &MessageConfig::operator=(const MessageConfig &other) = default; + +MessageConfig &MessageConfig::operator=(MessageConfig &&other) = default; QByteArray MessageConfig::type() const { @@ -194,7 +192,7 @@ MessageResult::MessageResult() : d(new MessageResultPrivate()) {} -MessageResult::~MessageResult() {} +MessageResult::~MessageResult() = default; bool MessageResult::hasResult() const { @@ -256,7 +254,7 @@ void MessageResult::discardMessage() void MessageResult::setResult(QVariant result) { QMutexLocker lock(&d->mutex); - d->result = result; + d->result = std::move(result); } void MessageResult::setAutoDelete(bool autoDelete) @@ -270,29 +268,13 @@ void MessageResult::setAutoDelete(bool autoDelete) // ------------- Private Implementation ------------- -QtMvvm::MessageConfigPrivate::MessageConfigPrivate(const QByteArray &type, const QByteArray &subType) : +QtMvvm::MessageConfigPrivate::MessageConfigPrivate(QByteArray type, QByteArray subType) : QSharedData(), - type(type), - subType(subType), - title(), - text(), - buttons(MessageConfig::Ok), - buttonTexts(), - defaultValue(), - editProperties() + type(std::move(type)), + subType(std::move(subType)) {} -QtMvvm::MessageConfigPrivate::MessageConfigPrivate(const QtMvvm::MessageConfigPrivate &other) : - QSharedData(other), - type(other.type), - subType(other.subType), - title(other.title), - text(other.text), - buttons(other.buttons), - buttonTexts(other.buttonTexts), - defaultValue(other.defaultValue), - editProperties(other.editProperties) -{} +QtMvvm::MessageConfigPrivate::MessageConfigPrivate(const QtMvvm::MessageConfigPrivate &other) = default; // ------------- Namespace methods implementation ------------- @@ -409,8 +391,7 @@ MessageResult *QtMvvm::about(const QString &description, const QUrl &websiteUrl, config.setViewProperty(QStringLiteral("addQtVersion"), addQtVersion); config.setTitle(MessageConfig::tr("%1 — Version %2") - .arg(QGuiApplication::applicationDisplayName()) - .arg(QCoreApplication::applicationVersion())); + .arg(QGuiApplication::applicationDisplayName(), QCoreApplication::applicationVersion())); //create the content string: //basic text @@ -431,7 +412,7 @@ MessageResult *QtMvvm::about(const QString &description, const QUrl &websiteUrl, } if(!extraTopInfos.isEmpty()) { auto withBr = addQtVersion; - for(auto info : extraTopInfos) { + for(const auto &info : extraTopInfos) { text += info + (withBr ? br : QString()); withBr = true; } @@ -443,14 +424,12 @@ MessageResult *QtMvvm::about(const QString &description, const QUrl &websiteUrl, .arg(companyName.isEmpty() ? QCoreApplication::organizationName() : companyName); if(websiteUrl.isValid()) { text += br + MessageConfig::tr("Project Website: %2") - .arg(QString::fromUtf8(websiteUrl.toEncoded())) - .arg(websiteUrl.toString()); + .arg(QString::fromUtf8(websiteUrl.toEncoded()), websiteUrl.toString()); } if(!licenseName.isEmpty()) { if(licenseUrl.isValid()) { text += br + MessageConfig::tr("License: %2") - .arg(QString::fromUtf8(licenseUrl.toEncoded())) - .arg(licenseName); + .arg(QString::fromUtf8(licenseUrl.toEncoded()), licenseName); } else { text += br + MessageConfig::tr("License: %1") .arg(licenseName); diff --git a/src/mvvmcore/message.h b/src/mvvmcore/message.h index a82ed57..a875296 100644 --- a/src/mvvmcore/message.h +++ b/src/mvvmcore/message.h @@ -112,10 +112,12 @@ public: MessageConfig(const QByteArray &type = TypeMessageBox, const QByteArray &subType = {}); //! Copy constructor MessageConfig(const MessageConfig &other); + MessageConfig(MessageConfig &&other); ~MessageConfig(); //! Assignment operator MessageConfig &operator=(const MessageConfig &other); + MessageConfig &operator=(MessageConfig &&other); //! @readAcFn{MessageConfig::type} QByteArray type() const; @@ -180,7 +182,7 @@ class Q_MVVMCORE_EXPORT MessageResult : public QObject public: explicit MessageResult(); - ~MessageResult(); + ~MessageResult() override; //! Checks if the dialog has a result bool hasResult() const; @@ -361,7 +363,7 @@ inline void getInput(const QString &title, const QVariantMap &viewProperties = {}, const QString &okText = {}, const QString &cancelText = {}) { - getInput(title, text, QMetaType::typeName(qMetaTypeId()), scope, [onResult](QVariant v) { + getInput(title, text, QMetaType::typeName(qMetaTypeId()), scope, [onResult](const QVariant &v) { onResult(v.template value(), v.isValid()); }, QVariant::fromValue(defaultValue), viewProperties, okText, cancelText); } @@ -374,7 +376,7 @@ inline void getInput(const QString &title, const QVariantMap &viewProperties = {}, const QString &okText = {}, const QString &cancelText = {}) { - getInput(title, text, QMetaType::typeName(qMetaTypeId()), [onResult](QVariant v) { + getInput(title, text, QMetaType::typeName(qMetaTypeId()), [onResult](const QVariant &v) { onResult(v.template value(), v.isValid()); }, QVariant::fromValue(defaultValue), viewProperties, okText, cancelText); } diff --git a/src/mvvmcore/message_p.h b/src/mvvmcore/message_p.h index 4fb63ea..f588ecc 100644 --- a/src/mvvmcore/message_p.h +++ b/src/mvvmcore/message_p.h @@ -14,14 +14,14 @@ namespace QtMvvm { class MessageConfigPrivate : public QSharedData { public: - MessageConfigPrivate(const QByteArray &type, const QByteArray &subType); + MessageConfigPrivate(QByteArray type, QByteArray subType); MessageConfigPrivate(const MessageConfigPrivate &other); QByteArray type; QByteArray subType; QString title; QString text; - MessageConfig::StandardButtons buttons; + MessageConfig::StandardButtons buttons = MessageConfig::Ok; QHash buttonTexts; QVariant defaultValue; QVariantMap editProperties; diff --git a/src/mvvmcore/qtmvvmcore_helpertypes.h b/src/mvvmcore/qtmvvmcore_helpertypes.h index d921bfe..c06b136 100644 --- a/src/mvvmcore/qtmvvmcore_helpertypes.h +++ b/src/mvvmcore/qtmvvmcore_helpertypes.h @@ -44,22 +44,22 @@ inline QByteArray inject_iid() { } template -inline std::function pack_function_imp(const TFunc &fn, QByteArrayList &injectables); +inline std::function pack_function_imp(TFunc fn, QByteArrayList &injectables); template -inline std::function pack_function_imp(const TFunc &fn, QByteArrayList &injectables); +inline std::function pack_function_imp(TFunc fn, QByteArrayList &injectables); template -inline std::function pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { +inline std::function pack_function_imp(TFunc fn, QByteArrayList &injectables) { injectables.append(inject_iid()); auto subFn = [fn](const QObjectList ¶ms, int index, TArgs... tArgs) { --index; return fn(params, index, qobject_cast(params[index]), tArgs...); }; - return pack_function_imp(subFn, injectables); + return pack_function_imp(std::move(subFn), injectables); } template -inline std::function pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { +inline std::function pack_function_imp(TFunc fn, QByteArrayList &injectables) { Q_UNUSED(injectables) return [fn](const QObjectList ¶ms) { return fn(params, params.size()); @@ -73,19 +73,19 @@ template struct fn_info { template - static inline std::function pack(const TFunctor &fn, QByteArrayList &injectables) { + static inline std::function pack(TFunctor fn, QByteArrayList &injectables) { auto subFn = [fn](const QObjectList ¶ms, int index, TArgs... args) -> QObject* { Q_UNUSED(params) Q_ASSERT_X(index == 0, Q_FUNC_INFO, "number of params does not equal recursion depth"); return fn(args...); }; - return pack_function_imp(subFn, injectables); + return pack_function_imp(std::move(subFn), injectables); } }; template -inline std::function pack_function(const TFunc &fn, QByteArrayList &injectables) { - return fn_info::pack(fn, injectables); +inline std::function pack_function(TFunc fn, QByteArrayList &injectables) { + return fn_info::pack(std::move(fn), injectables); } diff --git a/src/mvvmcore/serviceregistry.cpp b/src/mvvmcore/serviceregistry.cpp index 2871576..fbc846a 100644 --- a/src/mvvmcore/serviceregistry.cpp +++ b/src/mvvmcore/serviceregistry.cpp @@ -17,7 +17,7 @@ ServiceRegistry::ServiceRegistry(ServiceRegistryPrivate *d_ptr) : d(d_ptr) {} -ServiceRegistry::~ServiceRegistry() {} +ServiceRegistry::~ServiceRegistry() = default; ServiceRegistry *ServiceRegistry::instance() { @@ -58,14 +58,12 @@ QObject *ServiceRegistry::serviceObj(const QByteArray &iid) void ServiceRegistry::injectServices(QObject *object) { - auto &d = ServiceRegistry::instance()->d; QMutexLocker _(&d->serviceMutex); d->injectLocked(object); } QObject *ServiceRegistry::constructInjected(const QMetaObject *metaObject, QObject *parent) { - auto &d = ServiceRegistry::instance()->d; QMutexLocker _(&d->serviceMutex); return d->constructInjectedLocked(metaObject, parent); } @@ -138,8 +136,7 @@ void ServiceRegistryPrivate::injectLocked(QObject *object) ServiceRegistryPrivate::ServiceInfo::ServiceInfo(bool weak) : - _weak(weak), - _instance(nullptr) + _weak{weak} {} ServiceRegistryPrivate::ServiceInfo::~ServiceInfo() @@ -174,16 +171,17 @@ QObject *ServiceRegistryPrivate::ServiceInfo::instance(ServiceRegistryPrivate *d -ServiceRegistryPrivate::FnServiceInfo::FnServiceInfo(const std::function &creator, const QByteArrayList &injectables, bool weak) : +ServiceRegistryPrivate::FnServiceInfo::FnServiceInfo(std::function creator, QByteArrayList injectables, bool weak) : ServiceInfo(weak), - creator(creator), - injectables(injectables) + creator(std::move(creator)), + injectables(std::move(injectables)) {} QObject *ServiceRegistryPrivate::FnServiceInfo::construct(ServiceRegistryPrivate *d) const { QObjectList params; - for(auto iid : injectables) { + params.reserve(injectables.size()); + for(const auto &iid : injectables) { auto ref = d->services.value(iid); if(!ref) throw ServiceDependencyException(iid); diff --git a/src/mvvmcore/serviceregistry.h b/src/mvvmcore/serviceregistry.h index 335e1a2..3326ad6 100644 --- a/src/mvvmcore/serviceregistry.h +++ b/src/mvvmcore/serviceregistry.h @@ -35,7 +35,7 @@ public: void registerInterface(bool weak = false); //! Register a service for its interface via a constructor function template - void registerInterface(const TFunc &fn, bool weak = false); + void registerInterface(TFunc fn, bool weak = false); //! Register a service for its interface via an already existing instance template void registerInterface(TService *service, bool weak = false); @@ -44,7 +44,7 @@ public: void registerObject(bool weak = false); //! Register a service via a constructor function template - void registerObject(const TFunc &fn, bool weak = false); + void registerObject(TFunc fn, bool weak = false); //! Register a service via an already existing instance template void registerObject(TService *service, bool weak = false); @@ -159,11 +159,11 @@ void ServiceRegistry::registerInterface(bool weak) } template -void ServiceRegistry::registerInterface(const TFunc &fn, bool weak) +void ServiceRegistry::registerInterface(TFunc fn, bool weak) { QTMVVM_SERVICE_ASSERT(TInterface, TService) QByteArrayList injectables; - auto packed_fn = __helpertypes::pack_function(fn, injectables); + auto packed_fn = __helpertypes::pack_function(std::move(fn), injectables); registerService(qobject_interface_iid(), packed_fn, injectables, weak); } @@ -189,11 +189,11 @@ void ServiceRegistry::registerObject(bool weak) } template -void ServiceRegistry::registerObject(const TFunc &fn, bool weak) +void ServiceRegistry::registerObject(TFunc fn, bool weak) { QTMVVM_SERVICE_ASSERT(TService) QByteArrayList injectables; - auto packed_fn = __helpertypes::pack_function(fn, injectables); + auto packed_fn = __helpertypes::pack_function(std::move(fn), injectables); registerService(__helpertypes::qobject_iid(), packed_fn, injectables, weak); } diff --git a/src/mvvmcore/serviceregistry_p.h b/src/mvvmcore/serviceregistry_p.h index 2679ea9..390a273 100644 --- a/src/mvvmcore/serviceregistry_p.h +++ b/src/mvvmcore/serviceregistry_p.h @@ -13,6 +13,7 @@ class ServiceRegistryPrivate { public: class ServiceInfo { + Q_DISABLE_COPY(ServiceInfo) public: ServiceInfo(bool weak); virtual ~ServiceInfo(); @@ -25,12 +26,12 @@ public: private: const bool _weak; - QObject *_instance; + QObject *_instance = nullptr; }; class FnServiceInfo : public ServiceInfo { public: - FnServiceInfo(const std::function &creator, const QByteArrayList &injectables, bool weak); + FnServiceInfo(std::function creator, QByteArrayList injectables, bool weak); protected: QObject *construct(ServiceRegistryPrivate *d) const final; diff --git a/src/mvvmcore/settingssetup.h b/src/mvvmcore/settingssetup.h index 8438387..35a97c5 100644 --- a/src/mvvmcore/settingssetup.h +++ b/src/mvvmcore/settingssetup.h @@ -114,7 +114,9 @@ class SettingsLoaderException : public QException {}; //! An interface for a generic settings setup loader class ISettingsSetupLoader { + Q_DISABLE_COPY(ISettingsSetupLoader) public: + inline ISettingsSetupLoader() = default; virtual inline ~ISettingsSetupLoader() = default; //! Can be used to overwrite the default icon for categories diff --git a/src/mvvmcore/settingssetuploader.cpp b/src/mvvmcore/settingssetuploader.cpp index 770797d..83d9731 100644 --- a/src/mvvmcore/settingssetuploader.cpp +++ b/src/mvvmcore/settingssetuploader.cpp @@ -20,9 +20,7 @@ using namespace QtMvvm::SettingsElements; #define trctx(x) QCoreApplication::translate("qtmvvm_settings_xml", qUtf8Printable(x)) SettingsSetupLoader::SettingsSetupLoader(QObject *parent) : - QObject(parent), - _defaultIcon(QStringLiteral("qrc:/de/skycoder42/qtmvvm/icons/settings.svg")), - _cache() + QObject{parent} {} void SettingsSetupLoader::changeDefaultIcon(const QUrl &defaultIcon) @@ -344,29 +342,29 @@ QVariant SettingsSetupLoader::readElement(QXmlStreamReader &reader) const bool SettingsSetupLoader::readCategoryInclude(QXmlStreamReader &reader, Category &category, const QFileSelector *selector) const { - return readInclude(reader, [this, &category, selector](QXmlStreamReader &reader){ - category = readCategory(reader, selector); + return readInclude(reader, [this, &category, selector](QXmlStreamReader &mReader){ + category = readCategory(mReader, selector); }, QStringLiteral("Category"), selector); } bool SettingsSetupLoader::readSectionInclude(QXmlStreamReader &reader, Section §ion, const QFileSelector *selector) const { - return readInclude(reader, [this, §ion, selector](QXmlStreamReader &reader){ - section = readSection(reader, selector); + return readInclude(reader, [this, §ion, selector](QXmlStreamReader &mReader){ + section = readSection(mReader, selector); }, QStringLiteral("Section"), selector); } bool SettingsSetupLoader::readGroupInclude(QXmlStreamReader &reader, Group &group, const QFileSelector *selector) const { - return readInclude(reader, [this, &group, selector](QXmlStreamReader &reader){ - group = readGroup(reader, selector); + return readInclude(reader, [this, &group, selector](QXmlStreamReader &mReader){ + group = readGroup(mReader, selector); }, QStringLiteral("Group"), selector); } bool SettingsSetupLoader::readEntryInclude(QXmlStreamReader &reader, Entry &entry, const QFileSelector *selector) const { - return readInclude(reader, [this, &entry](QXmlStreamReader &reader){ - entry = readEntry(reader); + return readInclude(reader, [this, &entry](QXmlStreamReader &mReader){ + entry = readEntry(mReader); }, QStringLiteral("Entry"), selector); } @@ -504,8 +502,7 @@ SettingsXmlException::SettingsXmlException(QXmlStreamReader &reader, const QByte SettingsXmlException::SettingsXmlException(const QFile &fileError) : SettingsLoaderException(), _what(QStringLiteral("Failed to open file \"%1\" with error: %2") - .arg(fileError.fileName()) - .arg(fileError.errorString()) + .arg(fileError.fileName(), fileError.errorString()) .toUtf8()) {} diff --git a/src/mvvmcore/settingssetuploader_p.h b/src/mvvmcore/settingssetuploader_p.h index cd13e64..dd8c573 100644 --- a/src/mvvmcore/settingssetuploader_p.h +++ b/src/mvvmcore/settingssetuploader_p.h @@ -28,7 +28,7 @@ public: bool event(QEvent *event) override; private: - QUrl _defaultIcon; + QUrl _defaultIcon{QStringLiteral("qrc:/de/skycoder42/qtmvvm/icons/settings.svg")}; mutable QCache _cache; //Functions to read the settings XML diff --git a/src/mvvmcore/settingsviewmodel.cpp b/src/mvvmcore/settingsviewmodel.cpp index eb666dc..8bab8c0 100644 --- a/src/mvvmcore/settingsviewmodel.cpp +++ b/src/mvvmcore/settingsviewmodel.cpp @@ -14,7 +14,7 @@ SettingsViewModel::SettingsViewModel(QObject *parent) : d(new SettingsViewModelPrivate()) {} -SettingsViewModel::~SettingsViewModel() {} +SettingsViewModel::~SettingsViewModel() = default; QVariantHash SettingsViewModel::showParams(QSettings *settings, const QString &setupFile) { diff --git a/src/mvvmcore/settingsviewmodel.h b/src/mvvmcore/settingsviewmodel.h index 28f9925..2ce4496 100644 --- a/src/mvvmcore/settingsviewmodel.h +++ b/src/mvvmcore/settingsviewmodel.h @@ -38,7 +38,7 @@ public: //! Invokable constructor Q_INVOKABLE explicit SettingsViewModel(QObject *parent = nullptr); - ~SettingsViewModel(); + ~SettingsViewModel() override; //! @readAcFn{SettingsViewModel::canRestoreDefaults} virtual bool canRestoreDefaults() const; diff --git a/src/mvvmcore/viewmodel.cpp b/src/mvvmcore/viewmodel.cpp index 0148810..f5819de 100644 --- a/src/mvvmcore/viewmodel.cpp +++ b/src/mvvmcore/viewmodel.cpp @@ -9,7 +9,7 @@ ViewModel::ViewModel(QObject *parent) : d(new ViewModelPrivate()) {} -ViewModel::~ViewModel() {} +ViewModel::~ViewModel() = default; void ViewModel::onInit(const QVariantHash &) {} @@ -64,15 +64,11 @@ void ViewModel::showForResult(quint32 requestCode, const QMetaObject *viewMetaOb showImp(viewMetaObject, params, const_cast(this), requestCode); } -void ViewModel::showImp(const QMetaObject *metaObject, const QVariantHash ¶ms, QPointer parent, quint32 requestCode) +void ViewModel::showImp(const QMetaObject *metaObject, QVariantHash params, QPointer parent, quint32 requestCode) { QMetaObject::invokeMethod(CoreAppPrivate::dInstance().data(), "showViewModel", Qt::QueuedConnection, Q_ARG(const QMetaObject*, metaObject), - Q_ARG(QVariantHash, params), - Q_ARG(QPointer, parent), + Q_ARG(QVariantHash, std::move(params)), + Q_ARG(QPointer, std::move(parent)), Q_ARG(quint32, requestCode)); } - -// ------------- Private Implementation ------------- - -ViewModelPrivate::ViewModelPrivate() {} diff --git a/src/mvvmcore/viewmodel.h b/src/mvvmcore/viewmodel.h index 6c60a1f..9c74b8a 100644 --- a/src/mvvmcore/viewmodel.h +++ b/src/mvvmcore/viewmodel.h @@ -24,7 +24,7 @@ class Q_MVVMCORE_EXPORT ViewModel : public QObject public: //! Default constructor with parent explicit ViewModel(QObject *parent = nullptr); - ~ViewModel(); + ~ViewModel() override; public Q_SLOTS: //! Called by the presenter to initialize the viewmodel @@ -39,14 +39,14 @@ Q_SIGNALS: protected: //! Show another viewmodel as a child of this one template - inline void show(const QVariantHash ¶ms = {}) const; + inline void show(QVariantHash params = {}) const; //! @copybrief ViewModel::show(const QVariantHash &) const void show(const char *viewModelName, const QVariantHash ¶ms = {}) const; //! @copybrief ViewModel::show(const QVariantHash &) const void show(const QMetaObject *viewMetaObject, const QVariantHash ¶ms = {}) const; //! Show another viewmodel as a child of this one and expect its result template - inline void showForResult(quint32 requestCode, const QVariantHash ¶ms = {}) const; + inline void showForResult(quint32 requestCode, QVariantHash params = {}) const; //! @copybrief ViewModel::showForResult(quint32, const QVariantHash &) const void showForResult(quint32 requestCode, const char *viewModelName, const QVariantHash ¶ms = {}) const; //! @copybrief ViewModel::showForResult(quint32, const QVariantHash &) const @@ -57,23 +57,23 @@ private: QScopedPointer d; - static void showImp(const QMetaObject *metaObject, const QVariantHash ¶ms, QPointer parent, quint32 requestCode = 0); + static void showImp(const QMetaObject *metaObject, QVariantHash params, QPointer parent, quint32 requestCode = 0); }; // ------------- Generic Implementation ------------- template -inline void ViewModel::show(const QVariantHash ¶ms) const +inline void ViewModel::show(QVariantHash params) const { static_assert(std::is_base_of::value, "TViewModel must extend QtMvvm::ViewModel"); - showImp(&TViewModel::staticMetaObject, params, const_cast(this)); + showImp(&TViewModel::staticMetaObject, std::move(params), const_cast(this)); } template -void ViewModel::showForResult(quint32 requestCode, const QVariantHash ¶ms) const +void ViewModel::showForResult(quint32 requestCode, QVariantHash params) const { static_assert(std::is_base_of::value, "TViewModel must extend QtMvvm::ViewModel"); - showImp(&TViewModel::staticMetaObject, params, const_cast(this), requestCode); + showImp(&TViewModel::staticMetaObject, std::move(params), const_cast(this), requestCode); } } diff --git a/src/mvvmcore/viewmodel_p.h b/src/mvvmcore/viewmodel_p.h index d08c3f1..431425b 100644 --- a/src/mvvmcore/viewmodel_p.h +++ b/src/mvvmcore/viewmodel_p.h @@ -6,11 +6,7 @@ namespace QtMvvm { -class ViewModelPrivate -{ -public: - ViewModelPrivate(); -}; +class ViewModelPrivate {}; } diff --git a/src/mvvmdatasynccore/accountmodel.cpp b/src/mvvmdatasynccore/accountmodel.cpp index 8044a3f..2aa8962 100644 --- a/src/mvvmdatasynccore/accountmodel.cpp +++ b/src/mvvmdatasynccore/accountmodel.cpp @@ -18,7 +18,7 @@ AccountModel::AccountModel(QObject *parent) : d(new AccountModelPrivate()) {} -AccountModel::~AccountModel() {} +AccountModel::~AccountModel() = default; void AccountModel::setup(AccountManager *accountManager, SyncManager *syncManager) { diff --git a/src/mvvmdatasynccore/accountmodel.h b/src/mvvmdatasynccore/accountmodel.h index e095d46..d9b3fe5 100644 --- a/src/mvvmdatasynccore/accountmodel.h +++ b/src/mvvmdatasynccore/accountmodel.h @@ -27,7 +27,7 @@ public: //! Default constructor explicit AccountModel(QObject *parent = nullptr); - ~AccountModel(); + ~AccountModel() override; //! Setups up the model to use the account and a sync manager. Automatically loads devices Q_INVOKABLE void setup(QtDataSync::AccountManager *accountManager, diff --git a/src/mvvmdatasynccore/changeremoteviewmodel.cpp b/src/mvvmdatasynccore/changeremoteviewmodel.cpp index cbd261d..c26e75a 100644 --- a/src/mvvmdatasynccore/changeremoteviewmodel.cpp +++ b/src/mvvmdatasynccore/changeremoteviewmodel.cpp @@ -11,10 +11,6 @@ std::tuple ChangeRemoteViewModel::result(const QVariant &dat ChangeRemoteViewModel::ChangeRemoteViewModel(QObject *parent) : ViewModel(parent), - _url(), - _accessKey(), - _keepAlive(), - _keepData(true), _headerModel(new QStandardItemModel(0, 2, this)) { _headerModel->setHorizontalHeaderLabels({tr("Key"), tr("Value")}); @@ -83,21 +79,21 @@ bool ChangeRemoteViewModel::completeSetup() return true; } -void ChangeRemoteViewModel::setUrl(const QUrl &url) +void ChangeRemoteViewModel::setUrl(QUrl url) { if (_url == url) return; - _url = url; + _url = std::move(url); emit urlChanged(_url); } -void ChangeRemoteViewModel::setAccessKey(const QString &accessKey) +void ChangeRemoteViewModel::setAccessKey(QString accessKey) { if (_accessKey == accessKey) return; - _accessKey = accessKey; + _accessKey = std::move(accessKey); emit accessKeyChanged(_accessKey); } diff --git a/src/mvvmdatasynccore/changeremoteviewmodel_p.h b/src/mvvmdatasynccore/changeremoteviewmodel_p.h index 49884b3..a3f0523 100644 --- a/src/mvvmdatasynccore/changeremoteviewmodel_p.h +++ b/src/mvvmdatasynccore/changeremoteviewmodel_p.h @@ -44,8 +44,8 @@ public: public Q_SLOTS: bool completeSetup(); - void setUrl(const QUrl &url); - void setAccessKey(const QString &accessKey); + void setUrl(QUrl url); + void setAccessKey(QString accessKey); void setKeepAlive(int keepAlive); void setKeepData(bool keepData); @@ -62,8 +62,8 @@ Q_SIGNALS: private: QUrl _url; QString _accessKey; - int _keepAlive; - bool _keepData; + int _keepAlive = 1; + bool _keepData = true; QStandardItemModel *_headerModel; }; diff --git a/src/mvvmdatasynccore/datasyncviewmodel.cpp b/src/mvvmdatasynccore/datasyncviewmodel.cpp index 51f5025..a46d9cd 100644 --- a/src/mvvmdatasynccore/datasyncviewmodel.cpp +++ b/src/mvvmdatasynccore/datasyncviewmodel.cpp @@ -58,7 +58,7 @@ DataSyncViewModel::DataSyncViewModel(QObject *parent) : resetColorMap(); } -DataSyncViewModel::~DataSyncViewModel() {} +DataSyncViewModel::~DataSyncViewModel() = default; SyncManager *DataSyncViewModel::syncManager() const { @@ -115,6 +115,7 @@ QSortFilterProxyModel *DataSyncViewModel::sortedModel() const QString DataSyncViewModel::formatFingerPrint(const QByteArray &fingerPrint) { QByteArrayList res; + res.reserve(fingerPrint.size()); for(char c : fingerPrint) res.append(QByteArray(1, c).toHex().toUpper()); return QString::fromUtf8(res.join(':')); @@ -148,7 +149,7 @@ void DataSyncViewModel::startExport() void DataSyncViewModel::startImport() { auto home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); - getOpenFile(this, [this](QUrl url) { + getOpenFile(this, [this](const QUrl &url) { if(url.isValid()) { logDebug() << "Importing from URL" << url; @@ -168,8 +169,7 @@ void DataSyncViewModel::startImport() if(!device->open(QIODevice::ReadOnly | QIODevice::Text)) { critical(tr("Import failed"), tr("Failed to open URL \"%1\" with error: %2") - .arg(url.toString()) - .arg(device->errorString())); + .arg(url.toString(), device->errorString())); return; } auto data = device->readAll(); @@ -275,7 +275,7 @@ void DataSyncViewModel::setColorMap(DataSyncViewModel::ColorMap colorMap) if (d->colorMap == colorMap) return; - d->colorMap = colorMap; + d->colorMap = std::move(colorMap); emit colorMapChanged(d->colorMap, {}); } @@ -303,9 +303,8 @@ void DataSyncViewModel::showImportDialog(LoginRequest request) "

Name: %1
" "Fingerprint: %2

" "

Do you want accept the request?

") - .arg(request.device().name()) - .arg(formatFingerPrint(request.device().fingerprint())), - this, [this, request](bool ok) { + .arg(request.device().name(), formatFingerPrint(request.device().fingerprint())), + this, [request](bool ok) { auto req = request; if(!req.handled()) { if(ok) @@ -331,14 +330,13 @@ void DataSyncViewModel::showAccessGranted(const QUuid &id) void DataSyncViewModel::triggerGranted(const QList &devices) { - for(auto device : devices) { + for(const auto &device : devices) { if(d->pendingGrants.remove(device.deviceId())) { information(tr("Account access granted"), tr("

Account access has been granted to device:

" "

Name: %1
" "Fingerprint: %2

") - .arg(device.name()) - .arg(formatFingerPrint(device.fingerprint()))); + .arg(device.name(), formatFingerPrint(device.fingerprint()))); } } } @@ -410,9 +408,6 @@ void DataSyncViewModel::onResult(quint32 requestCode, const QVariant &result) QtMvvm::DataSyncViewModelPrivate::DataSyncViewModelPrivate(DataSyncViewModel *q_ptr) : q(q_ptr), - syncManager(nullptr), - accountManager(nullptr), - colorMap(), accountModel(new AccountModel(q_ptr)), sortedModel(new QSortFilterProxyModel(q_ptr)) {} @@ -420,7 +415,7 @@ QtMvvm::DataSyncViewModelPrivate::DataSyncViewModelPrivate(DataSyncViewModel *q_ void DataSyncViewModelPrivate::performExport(bool trusted, bool includeServer, const QString &password) { auto home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); - getSaveFile(q, [this, trusted, includeServer, password](QUrl url) { + getSaveFile(q, [this, trusted, includeServer, password](const QUrl &url) { if(url.isValid()) { logDebug() << "Exporting to URL" << url; @@ -441,13 +436,12 @@ void DataSyncViewModelPrivate::performExport(bool trusted, bool includeServer, c if(!device->open(QIODevice::WriteOnly | QIODevice::Text)) { critical(DataSyncViewModel::tr("Export failed"), DataSyncViewModel::tr("Failed to open URL \"%1\" with error: %2") - .arg(url.toString()) - .arg(device->errorString())); + .arg(url.toString(), device->errorString())); return; } QPointer qPtr(q); - auto resFn = [this, qPtr, device](QByteArray data) { + auto resFn = [qPtr, device](const QByteArray &data) { if(!qPtr) return; device->write(data); @@ -455,7 +449,7 @@ void DataSyncViewModelPrivate::performExport(bool trusted, bool includeServer, c information(DataSyncViewModel::tr("Export completed"), DataSyncViewModel::tr("Data was successfully exported.")); }; - auto errFn = [this, qPtr, device](QString error){ + auto errFn = [qPtr, device](const QString &error){ if(!qPtr) return; critical(DataSyncViewModel::tr("Export failed"), error); @@ -474,7 +468,7 @@ void DataSyncViewModelPrivate::performExport(bool trusted, bool includeServer, c void DataSyncViewModelPrivate::performImport(bool trusted, const QString &password, const QByteArray &data, bool keepData) { QPointer qPtr(q); - auto resFn = [this, qPtr](bool ok, QString error) { + auto resFn = [qPtr](bool ok, const QString &error) { if(!qPtr) return; if(ok) { diff --git a/src/mvvmdatasynccore/datasyncviewmodel.h b/src/mvvmdatasynccore/datasyncviewmodel.h index 5d53b48..7689b73 100644 --- a/src/mvvmdatasynccore/datasyncviewmodel.h +++ b/src/mvvmdatasynccore/datasyncviewmodel.h @@ -40,7 +40,7 @@ class Q_MVVMDATASYNCCORE_EXPORT DataSyncViewModel : public ViewModel public: //! A mapping from sync states to a text color - typedef QMap ColorMap; + using ColorMap = QMap; //! The parameter for a setup name for the onInit() method static const QString paramSetup; @@ -54,7 +54,7 @@ public: //! Invokable constructor Q_INVOKABLE explicit DataSyncViewModel(QObject *parent = nullptr); - ~DataSyncViewModel(); + ~DataSyncViewModel() override; //! @readAcFn{DataSyncViewModel::syncManager} QtDataSync::SyncManager* syncManager() const; diff --git a/src/mvvmdatasynccore/datasyncviewmodel_p.h b/src/mvvmdatasynccore/datasyncviewmodel_p.h index 00dc967..fb69c14 100644 --- a/src/mvvmdatasynccore/datasyncviewmodel_p.h +++ b/src/mvvmdatasynccore/datasyncviewmodel_p.h @@ -17,8 +17,8 @@ public: DataSyncViewModelPrivate(DataSyncViewModel *q_ptr); DataSyncViewModel *q; - QtDataSync::SyncManager *syncManager; - QtDataSync::AccountManager *accountManager; + QtDataSync::SyncManager *syncManager = nullptr; + QtDataSync::AccountManager *accountManager = nullptr; DataSyncViewModel::ColorMap colorMap; AccountModel *accountModel; QSortFilterProxyModel *sortedModel; diff --git a/src/mvvmdatasynccore/exchangedevicesmodel.cpp b/src/mvvmdatasynccore/exchangedevicesmodel.cpp index 7291746..3717c64 100644 --- a/src/mvvmdatasynccore/exchangedevicesmodel.cpp +++ b/src/mvvmdatasynccore/exchangedevicesmodel.cpp @@ -23,7 +23,7 @@ ExchangeDevicesModel::ExchangeDevicesModel(QObject *parent) : d(new ExchangeDevicesModelPrivate()) {} -ExchangeDevicesModel::~ExchangeDevicesModel() {} +ExchangeDevicesModel::~ExchangeDevicesModel() = default; void ExchangeDevicesModel::setup(QtDataSync::UserExchangeManager *exchangeManager) { @@ -34,7 +34,7 @@ void ExchangeDevicesModel::setup(QtDataSync::UserExchangeManager *exchangeManage d->exchangeManager = exchangeManager; d->devices.clear(); d->devices.reserve(d->exchangeManager->devices().size()); - for(auto device : d->exchangeManager->devices()) + for(const auto &device : d->exchangeManager->devices()) d->devices.append(device); endResetModel(); @@ -149,7 +149,8 @@ void ExchangeDevicesModel::updateDevices(const QList &devices) { //find new devices and update existing QList addList; - for(auto device : devices) { + addList.reserve(devices.size()); + for(const auto &device : devices) { auto dIndex = d->devices.indexOf(device); if(dIndex != -1) { if(device.name() != d->devices[dIndex].name()) { diff --git a/src/mvvmdatasynccore/exchangedevicesmodel.h b/src/mvvmdatasynccore/exchangedevicesmodel.h index 217ad44..f598d34 100644 --- a/src/mvvmdatasynccore/exchangedevicesmodel.h +++ b/src/mvvmdatasynccore/exchangedevicesmodel.h @@ -28,7 +28,7 @@ public: //! Default constructor explicit ExchangeDevicesModel(QObject *parent = nullptr); - ~ExchangeDevicesModel(); + ~ExchangeDevicesModel() override; //! Setups up the model to use the exchange manager. Automatically displays all devices of the manager Q_INVOKABLE void setup(QtDataSync::UserExchangeManager *exchangeManager); diff --git a/src/mvvmdatasynccore/exportsetupviewmodel.cpp b/src/mvvmdatasynccore/exportsetupviewmodel.cpp index bd15486..c2eb463 100644 --- a/src/mvvmdatasynccore/exportsetupviewmodel.cpp +++ b/src/mvvmdatasynccore/exportsetupviewmodel.cpp @@ -17,11 +17,7 @@ std::tuple ExportSetupViewModel::result(const QVariant &dat } ExportSetupViewModel::ExportSetupViewModel(QObject *parent) : - ViewModel(parent), - _label(), - _trusted(false), - _password(), - _includeServer(false) + ViewModel(parent) { connect(this, &ExportSetupViewModel::trustedChanged, this, &ExportSetupViewModel::validChanged); @@ -90,7 +86,7 @@ void ExportSetupViewModel::setPassword(QString password) if (_password == password) return; - _password = password; + _password = std::move(password); emit passwordChanged(_password); } diff --git a/src/mvvmdatasynccore/exportsetupviewmodel_p.h b/src/mvvmdatasynccore/exportsetupviewmodel_p.h index 1f9ad49..8a3441a 100644 --- a/src/mvvmdatasynccore/exportsetupviewmodel_p.h +++ b/src/mvvmdatasynccore/exportsetupviewmodel_p.h @@ -51,9 +51,9 @@ protected: private: QString _label; - bool _trusted; + bool _trusted = false; QString _password; - bool _includeServer; + bool _includeServer = false; }; } diff --git a/src/mvvmdatasynccore/identityeditviewmodel.cpp b/src/mvvmdatasynccore/identityeditviewmodel.cpp index 51cbf95..f2b7e71 100644 --- a/src/mvvmdatasynccore/identityeditviewmodel.cpp +++ b/src/mvvmdatasynccore/identityeditviewmodel.cpp @@ -4,8 +4,7 @@ using namespace QtMvvm; using namespace QtDataSync; IdentityEditViewModel::IdentityEditViewModel(QObject *parent) : - ViewModel(parent), - _manager(nullptr) + ViewModel(parent) { connect(this, &IdentityEditViewModel::nameChanged, this, &IdentityEditViewModel::validChanged); @@ -41,12 +40,12 @@ void IdentityEditViewModel::save() _manager->setDeviceName(_nameBuffer); } -void IdentityEditViewModel::setName(const QString &name) +void IdentityEditViewModel::setName(QString name) { if (_nameBuffer == name) return; - _nameBuffer = name; + _nameBuffer = std::move(name); emit nameChanged(_nameBuffer); } diff --git a/src/mvvmdatasynccore/identityeditviewmodel_p.h b/src/mvvmdatasynccore/identityeditviewmodel_p.h index 2a8c5a5..4ddb8f0 100644 --- a/src/mvvmdatasynccore/identityeditviewmodel_p.h +++ b/src/mvvmdatasynccore/identityeditviewmodel_p.h @@ -29,7 +29,7 @@ public: public Q_SLOTS: void save(); - void setName(const QString &name); + void setName(QString name); Q_SIGNALS: void nameChanged(const QString &name); @@ -40,7 +40,7 @@ protected: void onInit(const QVariantHash &showParams) override; private: - QtDataSync::AccountManager *_manager; + QtDataSync::AccountManager *_manager = nullptr; QString _nameBuffer; }; diff --git a/src/mvvmdatasynccore/networkexchangeviewmodel.cpp b/src/mvvmdatasynccore/networkexchangeviewmodel.cpp index d874245..60b97ab 100644 --- a/src/mvvmdatasynccore/networkexchangeviewmodel.cpp +++ b/src/mvvmdatasynccore/networkexchangeviewmodel.cpp @@ -45,7 +45,7 @@ NetworkExchangeViewModel::NetworkExchangeViewModel(QObject *parent) : d->sortedModel->setSourceModel(d->deviceModel); } -NetworkExchangeViewModel::~NetworkExchangeViewModel() {} +NetworkExchangeViewModel::~NetworkExchangeViewModel() = default; UserExchangeManager *NetworkExchangeViewModel::userExchangeManager() const { @@ -91,8 +91,7 @@ void NetworkExchangeViewModel::exportTo(int sortedIndex) d->activeExports.insert(exCode, info); showForResult(exCode, ExportSetupViewModel::showParams(tr("Export accont data to device \"%1\" with address \"%1\":") - .arg(info.name()) - .arg(ExchangeDevicesModel::fullAddress(info)))); + .arg(info.name(), ExchangeDevicesModel::fullAddress(info)))); } } @@ -111,7 +110,7 @@ void NetworkExchangeViewModel::setDeviceName(QString deviceName) this->deviceName() == deviceName) return; - d->exchangeManager->accountManager()->setDeviceName(deviceName); + d->exchangeManager->accountManager()->setDeviceName(std::move(deviceName)); } void NetworkExchangeViewModel::setActive(bool active) @@ -136,7 +135,7 @@ void NetworkExchangeViewModel::onInit(const QVariantHash ¶ms) } connect(d->exchangeManager->accountManager(), &AccountManager::deviceNameChanged, - this, PSIGARG(&NetworkExchangeViewModel::deviceNameChanged, QString)); + this, PSIGARG(&NetworkExchangeViewModel::deviceNameChanged, const QString &)); connect(d->exchangeManager, &UserExchangeManager::userDataReceived, this, &NetworkExchangeViewModel::newUserData); connect(d->exchangeManager, &UserExchangeManager::exchangeError, @@ -179,7 +178,7 @@ void NetworkExchangeViewModel::exchangeError(const QString &errorString) void NetworkExchangeViewModel::newUserData(const UserInfo &userInfo, bool trusted) { QPointer qPtr(this); - auto importDoneHandler = [this, qPtr](bool ok, QString error) { + auto importDoneHandler = [qPtr](bool ok, const QString &error) { if(!qPtr) return; if(ok) { @@ -194,8 +193,7 @@ void NetworkExchangeViewModel::newUserData(const UserInfo &userInfo, bool truste config.setTitle(tr("Import account data")) .setText(tr("Enter the password to decrypt the account data received from \"%1\" with address \"%2\". " "Then choose whether you want to keep you local data or not:") - .arg(userInfo.name()) - .arg(ExchangeDevicesModel::fullAddress(userInfo))) + .arg(userInfo.name(), ExchangeDevicesModel::fullAddress(userInfo))) .setButtons(MessageConfig::YesToAll | MessageConfig::Yes | MessageConfig::Cancel) .setButtonText(MessageConfig::YesToAll, tr("Reset data")) .setButtonText(MessageConfig::Yes, tr("Keep data")) @@ -222,8 +220,7 @@ void NetworkExchangeViewModel::newUserData(const UserInfo &userInfo, bool truste config.setTitle(tr("Import account data")) .setText(tr("Do you want to import data received from \"%1\" with address \"%2\"? " "Keep the local data after changing the account?") - .arg(userInfo.name()) - .arg(ExchangeDevicesModel::fullAddress(userInfo))) + .arg(userInfo.name(), ExchangeDevicesModel::fullAddress(userInfo))) .setButtons(MessageConfig::YesToAll | MessageConfig::Yes | MessageConfig::Cancel) .setButtonText(MessageConfig::YesToAll, tr("Reset data")) .setButtonText(MessageConfig::Yes, tr("Keep data")); @@ -248,9 +245,6 @@ void NetworkExchangeViewModel::newUserData(const UserInfo &userInfo, bool truste // ------------- Private Implementation ------------- NetworkExchangeViewModelPrivate::NetworkExchangeViewModelPrivate(NetworkExchangeViewModel *q_ptr) : - exchangeManager(nullptr), deviceModel(new ExchangeDevicesModel(q_ptr)), - sortedModel(new QSortFilterProxyModel(q_ptr)), - port(UserExchangeManager::DataExchangePort), - activeExports() + sortedModel(new QSortFilterProxyModel(q_ptr)) {} diff --git a/src/mvvmdatasynccore/networkexchangeviewmodel.h b/src/mvvmdatasynccore/networkexchangeviewmodel.h index 7b2c95d..1a878bd 100644 --- a/src/mvvmdatasynccore/networkexchangeviewmodel.h +++ b/src/mvvmdatasynccore/networkexchangeviewmodel.h @@ -46,7 +46,7 @@ public: //! Invokable constructor Q_INVOKABLE explicit NetworkExchangeViewModel(QObject *parent = nullptr); - ~NetworkExchangeViewModel(); + ~NetworkExchangeViewModel() override; //! @readAcFn{NetworkExchangeViewModel::userExchangeManager} QtDataSync::UserExchangeManager* userExchangeManager() const; diff --git a/src/mvvmdatasynccore/networkexchangeviewmodel_p.h b/src/mvvmdatasynccore/networkexchangeviewmodel_p.h index 570694b..0cf175c 100644 --- a/src/mvvmdatasynccore/networkexchangeviewmodel_p.h +++ b/src/mvvmdatasynccore/networkexchangeviewmodel_p.h @@ -1,6 +1,8 @@ #ifndef QTMVVM_NETWORKEXCHANGEVIEWMODEL_P_H #define QTMVVM_NETWORKEXCHANGEVIEWMODEL_P_H +#include + #include "qtmvvmdatasynccore_global.h" #include "networkexchangeviewmodel.h" @@ -13,10 +15,10 @@ public: NetworkExchangeViewModelPrivate(NetworkExchangeViewModel *q_ptr); - QtDataSync::UserExchangeManager *exchangeManager; + QtDataSync::UserExchangeManager *exchangeManager = nullptr; ExchangeDevicesModel *deviceModel; QSortFilterProxyModel *sortedModel; - quint16 port; + quint16 port = QtDataSync::UserExchangeManager::DataExchangePort; QHash activeExports; }; diff --git a/src/mvvmdatasyncwidgets/changeremotedialog.cpp b/src/mvvmdatasyncwidgets/changeremotedialog.cpp index e96ed90..ce3f04a 100644 --- a/src/mvvmdatasyncwidgets/changeremotedialog.cpp +++ b/src/mvvmdatasyncwidgets/changeremotedialog.cpp @@ -50,7 +50,7 @@ ChangeRemoteDialog::ChangeRemoteDialog(ViewModel *viewModel, QWidget *parent) : ui->treeView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); } -ChangeRemoteDialog::~ChangeRemoteDialog() {} +ChangeRemoteDialog::~ChangeRemoteDialog() = default; void ChangeRemoteDialog::accept() { diff --git a/src/mvvmdatasyncwidgets/changeremotedialog_p.h b/src/mvvmdatasyncwidgets/changeremotedialog_p.h index f89c819..1c3d7cb 100644 --- a/src/mvvmdatasyncwidgets/changeremotedialog_p.h +++ b/src/mvvmdatasyncwidgets/changeremotedialog_p.h @@ -21,7 +21,7 @@ class Q_MVVMDATASYNCWIDGETS_EXPORT ChangeRemoteDialog : public QDialog public: Q_INVOKABLE explicit ChangeRemoteDialog(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr); - ~ChangeRemoteDialog(); + ~ChangeRemoteDialog() override; public Q_SLOTS: void accept() override; diff --git a/src/mvvmdatasyncwidgets/datasyncwindow.cpp b/src/mvvmdatasyncwidgets/datasyncwindow.cpp index 049dc21..e9e14ce 100644 --- a/src/mvvmdatasyncwidgets/datasyncwindow.cpp +++ b/src/mvvmdatasyncwidgets/datasyncwindow.cpp @@ -42,7 +42,7 @@ DataSyncWindow::DataSyncWindow(QtMvvm::ViewModel *viewModel, QWidget *parent) : this, &DataSyncWindow::viewModelReady); } -DataSyncWindow::~DataSyncWindow() {} +DataSyncWindow::~DataSyncWindow() = default; double DataSyncWindow::syncProgress() const { diff --git a/src/mvvmdatasyncwidgets/datasyncwindow.h b/src/mvvmdatasyncwidgets/datasyncwindow.h index ff85644..ef1f846 100644 --- a/src/mvvmdatasyncwidgets/datasyncwindow.h +++ b/src/mvvmdatasyncwidgets/datasyncwindow.h @@ -25,7 +25,7 @@ class Q_MVVMDATASYNCWIDGETS_EXPORT DataSyncWindow : public QWidget public: //! View constructor Q_INVOKABLE explicit DataSyncWindow(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr); - ~DataSyncWindow(); + ~DataSyncWindow() override; //! @readAcFn{DataSyncWindow::syncProgress} double syncProgress() const; diff --git a/src/mvvmdatasyncwidgets/exportsetupdialog.cpp b/src/mvvmdatasyncwidgets/exportsetupdialog.cpp index b3f81d3..da59619 100644 --- a/src/mvvmdatasyncwidgets/exportsetupdialog.cpp +++ b/src/mvvmdatasyncwidgets/exportsetupdialog.cpp @@ -33,7 +33,7 @@ ExportSetupDialog::ExportSetupDialog(ViewModel *viewModel, QWidget *parent) : Binding::OneWayToView); } -ExportSetupDialog::~ExportSetupDialog() {} +ExportSetupDialog::~ExportSetupDialog() = default; void ExportSetupDialog::accept() { diff --git a/src/mvvmdatasyncwidgets/exportsetupdialog_p.h b/src/mvvmdatasyncwidgets/exportsetupdialog_p.h index 151d317..4b6052a 100644 --- a/src/mvvmdatasyncwidgets/exportsetupdialog_p.h +++ b/src/mvvmdatasyncwidgets/exportsetupdialog_p.h @@ -21,7 +21,7 @@ class Q_MVVMDATASYNCWIDGETS_EXPORT ExportSetupDialog : public QDialog public: Q_INVOKABLE explicit ExportSetupDialog(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr); - ~ExportSetupDialog(); + ~ExportSetupDialog() override; public Q_SLOTS: void accept() override; diff --git a/src/mvvmdatasyncwidgets/identityeditdialog.cpp b/src/mvvmdatasyncwidgets/identityeditdialog.cpp index d9b2784..c46b7fd 100644 --- a/src/mvvmdatasyncwidgets/identityeditdialog.cpp +++ b/src/mvvmdatasyncwidgets/identityeditdialog.cpp @@ -30,7 +30,7 @@ IdentityEditDialog::IdentityEditDialog(ViewModel *viewModel, QWidget *parent) : Binding::OneWayToView); } -IdentityEditDialog::~IdentityEditDialog() {} +IdentityEditDialog::~IdentityEditDialog() = default; void IdentityEditDialog::accept() { diff --git a/src/mvvmdatasyncwidgets/identityeditdialog_p.h b/src/mvvmdatasyncwidgets/identityeditdialog_p.h index 060414e..312d58e 100644 --- a/src/mvvmdatasyncwidgets/identityeditdialog_p.h +++ b/src/mvvmdatasyncwidgets/identityeditdialog_p.h @@ -21,7 +21,7 @@ class Q_MVVMDATASYNCWIDGETS_EXPORT IdentityEditDialog : public QDialog public: Q_INVOKABLE explicit IdentityEditDialog(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr); - ~IdentityEditDialog(); + ~IdentityEditDialog() override; public Q_SLOTS: void accept() override; diff --git a/src/mvvmdatasyncwidgets/networkexchangewindow.cpp b/src/mvvmdatasyncwidgets/networkexchangewindow.cpp index fdf7f93..f7b94a9 100644 --- a/src/mvvmdatasyncwidgets/networkexchangewindow.cpp +++ b/src/mvvmdatasyncwidgets/networkexchangewindow.cpp @@ -21,12 +21,12 @@ NetworkExchangeWindow::NetworkExchangeWindow(ViewModel *viewModel, QWidget *pare nullptr, "editingFinished()"); bind(d->viewModel, "active", d->ui->exchangeCheckBox, "checked", - Binding::OneWayToViewModel);//NOTE workaround because of buggy active property in datasync + Binding::OneWayToViewModel); d->ui->treeView->setModel(d->viewModel->sortedModel()); } -NetworkExchangeWindow::~NetworkExchangeWindow() {} +NetworkExchangeWindow::~NetworkExchangeWindow() = default; void NetworkExchangeWindow::activated(const QModelIndex &index) { diff --git a/src/mvvmdatasyncwidgets/networkexchangewindow.h b/src/mvvmdatasyncwidgets/networkexchangewindow.h index efffb51..6d8a323 100644 --- a/src/mvvmdatasyncwidgets/networkexchangewindow.h +++ b/src/mvvmdatasyncwidgets/networkexchangewindow.h @@ -20,7 +20,7 @@ class Q_MVVMDATASYNCWIDGETS_EXPORT NetworkExchangeWindow : public QWidget public: //! View constructor Q_INVOKABLE explicit NetworkExchangeWindow(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr); - ~NetworkExchangeWindow(); + ~NetworkExchangeWindow() override; private Q_SLOTS: void activated(const QModelIndex &index); diff --git a/src/mvvmquick/inputviewfactory.cpp b/src/mvvmquick/inputviewfactory.cpp index 7f012ab..23c5993 100644 --- a/src/mvvmquick/inputviewfactory.cpp +++ b/src/mvvmquick/inputviewfactory.cpp @@ -15,7 +15,7 @@ InputViewFactory::InputViewFactory(QObject *parent) : d(new InputViewFactoryPrivate()) {} -InputViewFactory::~InputViewFactory() {} +InputViewFactory::~InputViewFactory() = default; QUrl InputViewFactory::getInputUrl(const QByteArray &type, const QVariantMap &viewProperties) { diff --git a/src/mvvmquick/inputviewfactory.h b/src/mvvmquick/inputviewfactory.h index 61d8174..a0bd5bf 100644 --- a/src/mvvmquick/inputviewfactory.h +++ b/src/mvvmquick/inputviewfactory.h @@ -19,7 +19,7 @@ class Q_MVVMQUICK_EXPORT InputViewFactory : public QObject public: //! Default constructor Q_INVOKABLE InputViewFactory(QObject *parent = nullptr); - virtual ~InputViewFactory(); + ~InputViewFactory() override; //! Find the input view URL of the given input type Q_INVOKABLE virtual QUrl getInputUrl(const QByteArray &type, const QVariantMap &viewProperties); diff --git a/src/mvvmquick/quickpresenter.cpp b/src/mvvmquick/quickpresenter.cpp index e468cda..1e1b354 100644 --- a/src/mvvmquick/quickpresenter.cpp +++ b/src/mvvmquick/quickpresenter.cpp @@ -42,7 +42,7 @@ QuickPresenter::QuickPresenter(QObject *parent) : initResources(); } -QuickPresenter::~QuickPresenter() {} +QuickPresenter::~QuickPresenter() = default; void QuickPresenter::addViewSearchDir(const QString &dirPath) { @@ -124,7 +124,7 @@ QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType) QUrl resUrl; auto shortest = std::numeric_limits::max(); - for(auto dir : qAsConst(d->searchDirs)) { + for(const auto &dir : qAsConst(d->searchDirs)) { QDir searchDir(dir, QStringLiteral("%1*.qml").arg(QString::fromLatin1(cName)), QDir::NoSort, @@ -196,13 +196,6 @@ bool QuickPresenter::nameOrClassContains(const QObject *obj, const QString &cont // ------------- Private Implementation ------------- -QuickPresenterPrivate::QuickPresenterPrivate() : - qmlPresenter(nullptr), - inputViewFactory(nullptr), - explicitMappings(), - searchDirs({QStringLiteral(":/qtmvvm/views")}) -{} - QuickPresenter *QuickPresenterPrivate::currentPresenter() { try { @@ -213,7 +206,7 @@ QuickPresenter *QuickPresenterPrivate::currentPresenter() #endif return static_cast(ServiceRegistry::instance()->service()); } catch(QException &e) { - qFatal(e.what()); + qFatal("%s", e.what()); } } diff --git a/src/mvvmquick/quickpresenter.h b/src/mvvmquick/quickpresenter.h index c5ea44d..29e1d70 100644 --- a/src/mvvmquick/quickpresenter.h +++ b/src/mvvmquick/quickpresenter.h @@ -28,7 +28,7 @@ class Q_MVVMQUICK_EXPORT QuickPresenter : public QObject, public IPresenter public: //! Invokable constructor Q_INVOKABLE explicit QuickPresenter(QObject *parent = nullptr); - ~QuickPresenter(); + ~QuickPresenter() override; //! Register a subclass of the QuickPresenter as the active presenter for the CoreApp template diff --git a/src/mvvmquick/quickpresenter_p.h b/src/mvvmquick/quickpresenter_p.h index aa3b40b..665ce9d 100644 --- a/src/mvvmquick/quickpresenter_p.h +++ b/src/mvvmquick/quickpresenter_p.h @@ -14,17 +14,15 @@ class Q_MVVMQUICK_EXPORT QuickPresenterPrivate friend class QtMvvm::QuickPresenter; public: - QuickPresenterPrivate(); - static QuickPresenter *currentPresenter(); static void setQmlPresenter(QObject *presenter); private: QPointer qmlPresenter; - InputViewFactory *inputViewFactory; + InputViewFactory *inputViewFactory = nullptr; QHash explicitMappings; - QStringList searchDirs; + QStringList searchDirs{QStringLiteral(":/qtmvvm/views")}; }; } diff --git a/src/mvvmwidgets/inputwidgetfactory.cpp b/src/mvvmwidgets/inputwidgetfactory.cpp index 82f4e04..33da596 100644 --- a/src/mvvmwidgets/inputwidgetfactory.cpp +++ b/src/mvvmwidgets/inputwidgetfactory.cpp @@ -23,7 +23,7 @@ InputWidgetFactory::InputWidgetFactory(QObject *parent) : d(new InputWidgetFactoryPrivate()) {} -InputWidgetFactory::~InputWidgetFactory() {} +InputWidgetFactory::~InputWidgetFactory() = default; QWidget *InputWidgetFactory::createInput(const QByteArray &type, QWidget *parent, const QVariantMap &viewProperties) { diff --git a/src/mvvmwidgets/inputwidgetfactory.h b/src/mvvmwidgets/inputwidgetfactory.h index efda352..c8936dc 100644 --- a/src/mvvmwidgets/inputwidgetfactory.h +++ b/src/mvvmwidgets/inputwidgetfactory.h @@ -21,7 +21,7 @@ class InputWidgetFactory : public QObject public: //! Default constructor Q_INVOKABLE explicit InputWidgetFactory(QObject *parent = nullptr); - virtual ~InputWidgetFactory(); + ~InputWidgetFactory() override; //! Create a new input widget of the given input type virtual QWidget *createInput(const QByteArray &type, QWidget *parent, const QVariantMap &viewProperties); diff --git a/src/mvvmwidgets/ipresentingview.h b/src/mvvmwidgets/ipresentingview.h index a2e8b93..e339843 100644 --- a/src/mvvmwidgets/ipresentingview.h +++ b/src/mvvmwidgets/ipresentingview.h @@ -10,7 +10,9 @@ namespace QtMvvm { //! A simple interface to make it possible for any view to present subviews class Q_MVVMWIDGETS_EXPORT IPresentingView { + Q_DISABLE_COPY(IPresentingView) public: + inline IPresentingView() = default; inline virtual ~IPresentingView() = default; //! Is called to try to present a view diff --git a/src/mvvmwidgets/selectcombobox.cpp b/src/mvvmwidgets/selectcombobox.cpp index a62549d..9de3a7b 100644 --- a/src/mvvmwidgets/selectcombobox.cpp +++ b/src/mvvmwidgets/selectcombobox.cpp @@ -48,7 +48,7 @@ void SelectComboBox::setCurrentValue(const QVariant &data) void SelectComboBox::setListElements(const QVariantList &listElements) { clear(); - for(auto item : listElements) { + for(const auto &item : listElements) { if(item.type() == QVariant::String) addItem(item.toString(), item); else { diff --git a/src/mvvmwidgets/selectcombobox_p.h b/src/mvvmwidgets/selectcombobox_p.h index 5939d75..6ea24c1 100644 --- a/src/mvvmwidgets/selectcombobox_p.h +++ b/src/mvvmwidgets/selectcombobox_p.h @@ -28,7 +28,7 @@ public Q_SLOTS: Q_SIGNALS: void currentValueChanged(); - void listElementsChanged(QVariantList listElements); + void listElementsChanged(const QVariantList &listElements); }; } diff --git a/src/mvvmwidgets/settingsdialog.cpp b/src/mvvmwidgets/settingsdialog.cpp index 769d5b4..1072ba8 100644 --- a/src/mvvmwidgets/settingsdialog.cpp +++ b/src/mvvmwidgets/settingsdialog.cpp @@ -58,7 +58,7 @@ SettingsDialog::SettingsDialog(ViewModel *viewModel, QWidget *parent) : d, &SettingsDialogPrivate::createUi); } -SettingsDialog::~SettingsDialog() {} +SettingsDialog::~SettingsDialog() = default; QString SettingsDialog::labelFilterStyleSheet() const { @@ -82,14 +82,10 @@ SettingsDialogPrivate::SettingsDialogPrivate(SettingsDialog *q_ptr, ViewModel *v QObject(q_ptr), q(q_ptr), viewModel(static_cast(viewModel)), - ui(new Ui::SettingsDialog()), - delegate(nullptr), - maxWidthBase(0), - entryMap(), - changedEntries() + ui(new Ui::SettingsDialog()) {} -SettingsDialogPrivate::~SettingsDialogPrivate() {} +SettingsDialogPrivate::~SettingsDialogPrivate() = default; void SettingsDialogPrivate::createUi() { @@ -101,7 +97,7 @@ void SettingsDialogPrivate::createUi() ui->filterLineEdit->setVisible(setup.allowSearch); ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setVisible(setup.allowRestore && viewModel->canRestoreDefaults()); - for(auto category : setup.categories) + for(const auto &category : qAsConst(setup.categories)) createCategory(category); resetListSize(); @@ -121,7 +117,7 @@ void SettingsDialogPrivate::createCategory(const SettingsElements::Category &cat ui->contentStackWidget->addWidget(tab); ui->categoryListWidget->addItem(item); - for(auto section : category.sections) + for(const auto §ion : category.sections) createSection(section, tab); } @@ -148,7 +144,7 @@ void SettingsDialogPrivate::createSection(const SettingsElements::Section §i tabWidget->tabBar()->setTabToolTip(index, tooltip); tabWidget->tabBar()->setTabWhatsThis(index, tooltip); - for(auto group : section.groups) + for(const auto &group : section.groups) createGroup(group, scrollContent, layout); } @@ -168,7 +164,7 @@ void SettingsDialogPrivate::createGroup(const SettingsElements::Group &group, QW groupBox->setLayout(sectionLayout); } - for(auto entry : group.entries) + for(const auto &entry : group.entries) createEntry(entry, sectionWidget, sectionLayout); } @@ -237,7 +233,7 @@ void SettingsDialogPrivate::saveValues() void SettingsDialogPrivate::restoreValues() { - for(auto info : entryMap) + for(const auto &info : qAsConst(entryMap)) viewModel->resetValue(info.first.key); } @@ -393,7 +389,7 @@ bool SettingsDialogPrivate::searchInEntry(const QRegularExpression ®ex, QLabe auto keys = entryMap.value(content).first.searchKeys; keys.append(label->text()); - for(auto key : keys) { + for(const auto &key : keys) { if(regex.match(key).hasMatch()) { label->setStyleSheet(q->labelFilterStyleSheet()); return true; @@ -427,8 +423,8 @@ void SettingsDialogPrivate::buttonBoxClicked(QAbstractButton *button) case QDialogButtonBox::RestoreDefaults: if(viewModel->canRestoreDefaults()) { auto result = CoreApp::showDialog(viewModel->restoreConfig()); - connect(result, &MessageResult::dialogDone, this, [this](MessageConfig::StandardButton result) { - if(result == MessageConfig::Yes) { + connect(result, &MessageResult::dialogDone, this, [this](MessageConfig::StandardButton btnResult) { + if(btnResult == MessageConfig::Yes) { restoreValues(); q->accept(); } @@ -452,10 +448,10 @@ void SettingsDialogPrivate::filterTextChanged(const QString &searchText) -CategoryItemDelegate::CategoryItemDelegate(const std::function &updateFunc, const QSize &iconSize, int layoutSpacing, QObject *parent) : +CategoryItemDelegate::CategoryItemDelegate(std::function updateFunc, QSize iconSize, int layoutSpacing, QObject *parent) : QStyledItemDelegate(parent), _iconSize(iconSize + QSize(0, layoutSpacing)), - _updateFunc(updateFunc) + _updateFunc(std::move(updateFunc)) {} QSize CategoryItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const diff --git a/src/mvvmwidgets/settingsdialog.h b/src/mvvmwidgets/settingsdialog.h index 5306638..839b28d 100644 --- a/src/mvvmwidgets/settingsdialog.h +++ b/src/mvvmwidgets/settingsdialog.h @@ -20,7 +20,7 @@ class Q_MVVMWIDGETS_EXPORT SettingsDialog : public QDialog public: //! View constructor Q_INVOKABLE explicit SettingsDialog(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr); - ~SettingsDialog(); + ~SettingsDialog() override; protected: //! Returns the stylesheet used highlight labels found when searching diff --git a/src/mvvmwidgets/settingsdialog_p.h b/src/mvvmwidgets/settingsdialog_p.h index 4a7b2a8..101cd02 100644 --- a/src/mvvmwidgets/settingsdialog_p.h +++ b/src/mvvmwidgets/settingsdialog_p.h @@ -23,9 +23,11 @@ namespace QtMvvm { class CategoryItemDelegate : public QStyledItemDelegate { + Q_OBJECT + public: - CategoryItemDelegate(const std::function &updateFunc, - const QSize &iconSize, + CategoryItemDelegate(std::function updateFunc, + QSize iconSize, int layoutSpacing, QObject *parent = nullptr); @@ -42,17 +44,17 @@ class SettingsDialogPrivate : public QObject public: SettingsDialogPrivate(SettingsDialog *q_ptr, ViewModel *viewModel); - ~SettingsDialogPrivate(); + ~SettingsDialogPrivate() override; static const QString TabContentId; SettingsDialog *q; SettingsViewModel *viewModel; QScopedPointer ui; - CategoryItemDelegate *delegate; - int maxWidthBase; + CategoryItemDelegate *delegate = nullptr; + int maxWidthBase = 0; - typedef QPair EntryInfo; + using EntryInfo = QPair; QHash entryMap; QSet changedEntries; diff --git a/src/mvvmwidgets/widgetspresenter.cpp b/src/mvvmwidgets/widgetspresenter.cpp index 57c2d73..e9161a2 100644 --- a/src/mvvmwidgets/widgetspresenter.cpp +++ b/src/mvvmwidgets/widgetspresenter.cpp @@ -53,7 +53,7 @@ WidgetsPresenter::WidgetsPresenter(QObject *parent) : initResources(); } -WidgetsPresenter::~WidgetsPresenter() {} +WidgetsPresenter::~WidgetsPresenter() = default; void WidgetsPresenter::registerView(const QMetaObject *viewType) { @@ -148,7 +148,7 @@ const QMetaObject *WidgetsPresenter::findWidgetMetaObject(const QMetaObject *vie auto shortest = std::numeric_limits::max(); const QMetaObject *res = nullptr; - for(auto metaObject : d->implicitMappings) { + for(auto metaObject : qAsConst(d->implicitMappings)) { QByteArray vName = metaObject->className(); //strip namespaces lIndex = vName.lastIndexOf("::"); @@ -349,7 +349,7 @@ void WidgetsPresenter::presentInputDialog(const MessageConfig &config, QPointer< dialog->done(btnBox->standardButton(btn)); }); QObject::connect(dialog, &QDialog::finished, - dialog, [dialog, input, property, result](int resCode){ + dialog, [input, property, result](int resCode){ if(result) { result->complete(static_cast(resCode), property.read(input)); @@ -408,7 +408,7 @@ void WidgetsPresenter::presentFileDialog(const MessageConfig &config, QPointersetResult(QVariant::fromValue(dialog->selectedUrls())); else if(!dialog->selectedUrls().isEmpty()) - result->setResult(dialog->selectedUrls().first()); + result->setResult(dialog->selectedUrls().value(0)); result->complete(MessageConfig::Ok); } else result->complete(MessageConfig::Cancel); @@ -431,9 +431,7 @@ void WidgetsPresenter::presentOtherDialog(const MessageConfig &config, QPointer< // ------------- Private Implementation ------------- WidgetsPresenterPrivate::WidgetsPresenterPrivate() : - inputViewFactory(nullptr), - implicitMappings({&SettingsDialog::staticMetaObject}), - explicitMappings() + implicitMappings{&SettingsDialog::staticMetaObject} {} WidgetsPresenter *WidgetsPresenterPrivate::currentPresenter() @@ -446,11 +444,11 @@ WidgetsPresenter *WidgetsPresenterPrivate::currentPresenter() #endif return static_cast(ServiceRegistry::instance()->service()); } catch(QException &e) { - qFatal(e.what()); + qFatal("%s", e.what()); } } -QValidator *QtMvvm::createUrlValidator(const QStringList &schemes, QObject *parent) +QValidator *QtMvvm::createUrlValidator(QStringList schemes, QObject *parent) { - return new QUrlValidator(schemes, parent); + return new QUrlValidator(std::move(schemes), parent); } diff --git a/src/mvvmwidgets/widgetspresenter.h b/src/mvvmwidgets/widgetspresenter.h index 4245805..e23b140 100644 --- a/src/mvvmwidgets/widgetspresenter.h +++ b/src/mvvmwidgets/widgetspresenter.h @@ -28,7 +28,7 @@ class Q_MVVMWIDGETS_EXPORT WidgetsPresenter : public QObject, public IPresenter public: //! Invokable constructor Q_INVOKABLE explicit WidgetsPresenter(QObject *parent = nullptr); - ~WidgetsPresenter(); + ~WidgetsPresenter() override; //! Register a subclass of the WidgetsPresenter as the active presenter for the CoreApp template diff --git a/src/mvvmwidgets/widgetspresenter_p.h b/src/mvvmwidgets/widgetspresenter_p.h index fac617a..ae994a7 100644 --- a/src/mvvmwidgets/widgetspresenter_p.h +++ b/src/mvvmwidgets/widgetspresenter_p.h @@ -17,12 +17,12 @@ public: static WidgetsPresenter *currentPresenter(); - InputWidgetFactory* inputViewFactory; + InputWidgetFactory* inputViewFactory = nullptr; QSet implicitMappings; QHash explicitMappings; }; -Q_MVVMWIDGETS_EXPORT QValidator *createUrlValidator(const QStringList &schemes, QObject* parent = nullptr); +Q_MVVMWIDGETS_EXPORT QValidator *createUrlValidator(QStringList schemes, QObject* parent = nullptr); }