Browse Source

general code cleanups

pull/2/head
Skycoder42 7 years ago
parent
commit
c61d86e7b2
No known key found for this signature in database GPG Key ID: 8E01AD9EF0578D2B
  1. 2
      .qmake.conf
  2. 2
      src/imports/mvvmcore/mvvmcore.pro
  3. 10
      src/imports/mvvmcore/qqmlmvvmmessage.cpp
  4. 2
      src/imports/mvvmdatasynccore/mvvmdatasynccore.pro
  5. 2
      src/imports/mvvmdatasyncquick/mvvmdatasyncquick.pro
  6. 2
      src/imports/mvvmquick/androidfilechooser.cpp
  7. 2
      src/imports/mvvmquick/androidfilechooser.h
  8. 2
      src/imports/mvvmquick/multifilterproxymodel.cpp
  9. 5
      src/imports/mvvmquick/qqmlquickpresenter.cpp
  10. 4
      src/imports/mvvmquick/qqmlquickpresenter.h
  11. 14
      src/imports/mvvmquick/settingsentrymodel.cpp
  12. 2
      src/imports/mvvmquick/settingsentrymodel.h
  13. 16
      src/imports/mvvmquick/settingssectionmodel.cpp
  14. 2
      src/imports/mvvmquick/settingssectionmodel.h
  15. 24
      src/imports/mvvmquick/settingsuibuilder.cpp
  16. 8
      src/imports/mvvmquick/settingsuibuilder.h
  17. 18
      src/mvvmcore/binding.cpp
  18. 12
      src/mvvmcore/binding_p.h
  19. 2
      src/mvvmcore/coreapp.cpp
  20. 2
      src/mvvmcore/coreapp.h
  21. 2
      src/mvvmcore/ipresenter.h
  22. 55
      src/mvvmcore/message.cpp
  23. 8
      src/mvvmcore/message.h
  24. 4
      src/mvvmcore/message_p.h
  25. 18
      src/mvvmcore/qtmvvmcore_helpertypes.h
  26. 16
      src/mvvmcore/serviceregistry.cpp
  27. 12
      src/mvvmcore/serviceregistry.h
  28. 5
      src/mvvmcore/serviceregistry_p.h
  29. 2
      src/mvvmcore/settingssetup.h
  30. 23
      src/mvvmcore/settingssetuploader.cpp
  31. 2
      src/mvvmcore/settingssetuploader_p.h
  32. 2
      src/mvvmcore/settingsviewmodel.cpp
  33. 2
      src/mvvmcore/settingsviewmodel.h
  34. 12
      src/mvvmcore/viewmodel.cpp
  35. 16
      src/mvvmcore/viewmodel.h
  36. 6
      src/mvvmcore/viewmodel_p.h
  37. 2
      src/mvvmdatasynccore/accountmodel.cpp
  38. 2
      src/mvvmdatasynccore/accountmodel.h
  39. 12
      src/mvvmdatasynccore/changeremoteviewmodel.cpp
  40. 8
      src/mvvmdatasynccore/changeremoteviewmodel_p.h
  41. 34
      src/mvvmdatasynccore/datasyncviewmodel.cpp
  42. 4
      src/mvvmdatasynccore/datasyncviewmodel.h
  43. 4
      src/mvvmdatasynccore/datasyncviewmodel_p.h
  44. 7
      src/mvvmdatasynccore/exchangedevicesmodel.cpp
  45. 2
      src/mvvmdatasynccore/exchangedevicesmodel.h
  46. 8
      src/mvvmdatasynccore/exportsetupviewmodel.cpp
  47. 4
      src/mvvmdatasynccore/exportsetupviewmodel_p.h
  48. 7
      src/mvvmdatasynccore/identityeditviewmodel.cpp
  49. 4
      src/mvvmdatasynccore/identityeditviewmodel_p.h
  50. 22
      src/mvvmdatasynccore/networkexchangeviewmodel.cpp
  51. 2
      src/mvvmdatasynccore/networkexchangeviewmodel.h
  52. 6
      src/mvvmdatasynccore/networkexchangeviewmodel_p.h
  53. 2
      src/mvvmdatasyncwidgets/changeremotedialog.cpp
  54. 2
      src/mvvmdatasyncwidgets/changeremotedialog_p.h
  55. 2
      src/mvvmdatasyncwidgets/datasyncwindow.cpp
  56. 2
      src/mvvmdatasyncwidgets/datasyncwindow.h
  57. 2
      src/mvvmdatasyncwidgets/exportsetupdialog.cpp
  58. 2
      src/mvvmdatasyncwidgets/exportsetupdialog_p.h
  59. 2
      src/mvvmdatasyncwidgets/identityeditdialog.cpp
  60. 2
      src/mvvmdatasyncwidgets/identityeditdialog_p.h
  61. 4
      src/mvvmdatasyncwidgets/networkexchangewindow.cpp
  62. 2
      src/mvvmdatasyncwidgets/networkexchangewindow.h
  63. 2
      src/mvvmquick/inputviewfactory.cpp
  64. 2
      src/mvvmquick/inputviewfactory.h
  65. 13
      src/mvvmquick/quickpresenter.cpp
  66. 2
      src/mvvmquick/quickpresenter.h
  67. 6
      src/mvvmquick/quickpresenter_p.h
  68. 2
      src/mvvmwidgets/inputwidgetfactory.cpp
  69. 2
      src/mvvmwidgets/inputwidgetfactory.h
  70. 2
      src/mvvmwidgets/ipresentingview.h
  71. 2
      src/mvvmwidgets/selectcombobox.cpp
  72. 2
      src/mvvmwidgets/selectcombobox_p.h
  73. 30
      src/mvvmwidgets/settingsdialog.cpp
  74. 2
      src/mvvmwidgets/settingsdialog.h
  75. 14
      src/mvvmwidgets/settingsdialog_p.h
  76. 18
      src/mvvmwidgets/widgetspresenter.cpp
  77. 2
      src/mvvmwidgets/widgetspresenter.h
  78. 4
      src/mvvmwidgets/widgetspresenter_p.h

2
.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}

2
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

10
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<QUrl> url){
QtMvvm::getOpenFiles(this, [engine, onResult](const QList<QUrl> &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

2
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

2
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

2
src/imports/mvvmquick/androidfilechooser.cpp

@ -14,7 +14,7 @@ AndroidFileChooser::AndroidFileChooser(QObject *parent) :
_result()
{}
AndroidFileChooser::~AndroidFileChooser() {}
AndroidFileChooser::~AndroidFileChooser() = default;
AndroidFileChooser::ChooserFlags AndroidFileChooser::chooserFlags() const
{

2
src/imports/mvvmquick/androidfilechooser.h

@ -130,7 +130,7 @@ public:
//! @private
explicit AndroidFileChooser(QObject *parent = nullptr);
~AndroidFileChooser();
~AndroidFileChooser() override;
//! @private
ChooserFlags chooserFlags() const;

2
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;
}

5
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 &params, QPointer<ViewModel> parent)
void QQmlQuickPresenter::addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash &params, const QPointer<ViewModel> &parent)
{
if(!_qmlPresenter) {
logWarning() << "No QML-Presenter registered! Unable to present viewModel of type"

4
src/imports/mvvmquick/qqmlquickpresenter.h

@ -158,7 +158,7 @@ private Q_SLOTS:
void statusChanged(QQmlComponent::Status status);
private:
typedef std::tuple<ViewModel*, QVariantHash, QPointer<ViewModel>> PresentTuple;
using PresentTuple = std::tuple<ViewModel*, QVariantHash, QPointer<ViewModel>>;
QQmlEngine *_engine;
QPointer<QObject> _qmlPresenter;
@ -166,7 +166,7 @@ private:
QCache<QUrl, QQmlComponent> _componentCache;
QHash<QQmlComponent*, PresentTuple> _loadCache;
void addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash &params, QPointer<ViewModel> parent);
void addObject(QQmlComponent *component, ViewModel *viewModel, const QVariantHash &params, const QPointer<ViewModel> &parent);
};
}

14
src/imports/mvvmquick/settingsentrymodel.cpp

@ -22,8 +22,8 @@ void SettingsEntryModel::setup(const SettingsElements::Section &section, 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();
}

2
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;

16
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 &section : category.sections)
_sections.append(SectionInfo{section, category});
}
}
@ -62,9 +62,9 @@ QVariant SettingsSectionModel::data(const QModelIndex &index, int role) const
{
const auto &section = _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()
{}

2
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;

24
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 &section : 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);

8
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;

18
src/mvvmcore/binding.cpp

@ -90,10 +90,10 @@ Binding::Binding() :
{}
Binding::Binding(QPointer<BindingPrivate> 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<BindingPrivate> binderPrivate = new BindingPrivate(viewModel, viewModelProperty, view, viewProperty);
QPointer<BindingPrivate> 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);

12
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);

2
src/mvvmcore/coreapp.cpp

@ -15,7 +15,7 @@ CoreApp::CoreApp(QObject *parent) :
d(new CoreAppPrivate())
{}
CoreApp::~CoreApp() {}
CoreApp::~CoreApp() = default;
CoreApp *CoreApp::instance()
{

2
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();

2
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

55
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: <a href=\"%1\">%2</a>")
.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: <a href=\"%1\">%2</a>")
.arg(QString::fromUtf8(licenseUrl.toEncoded()))
.arg(licenseName);
.arg(QString::fromUtf8(licenseUrl.toEncoded()), licenseName);
} else {
text += br + MessageConfig::tr("License: %1")
.arg(licenseName);

8
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<TEdit>()), scope, [onResult](QVariant v) {
getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), scope, [onResult](const QVariant &v) {
onResult(v.template value<TEdit>(), 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<TEdit>()), [onResult](QVariant v) {
getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), [onResult](const QVariant &v) {
onResult(v.template value<TEdit>(), v.isValid());
}, QVariant::fromValue(defaultValue), viewProperties, okText, cancelText);
}

4
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<MessageConfig::StandardButton, QString> buttonTexts;
QVariant defaultValue;
QVariantMap editProperties;

18
src/mvvmcore/qtmvvmcore_helpertypes.h

@ -44,22 +44,22 @@ inline QByteArray inject_iid() {
}
template <typename TFunc, typename T1, typename... TArgs>
inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables);
inline std::function<QObject*(QObjectList)> pack_function_imp(TFunc fn, QByteArrayList &injectables);
template <typename TFunc>
inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables);
inline std::function<QObject*(QObjectList)> pack_function_imp(TFunc fn, QByteArrayList &injectables);
template <typename TFunc, typename T1, typename... TArgs>
inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) {
inline std::function<QObject*(QObjectList)> pack_function_imp(TFunc fn, QByteArrayList &injectables) {
injectables.append(inject_iid<T1>());
auto subFn = [fn](const QObjectList &params, int index, TArgs... tArgs) {
--index;
return fn(params, index, qobject_cast<T1>(params[index]), tArgs...);
};
return pack_function_imp<decltype(subFn), TArgs...>(subFn, injectables);
return pack_function_imp<decltype(subFn), TArgs...>(std::move(subFn), injectables);
}
template <typename TFunc>
inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) {
inline std::function<QObject*(QObjectList)> pack_function_imp(TFunc fn, QByteArrayList &injectables) {
Q_UNUSED(injectables)
return [fn](const QObjectList &params) {
return fn(params, params.size());
@ -73,19 +73,19 @@ template <typename TClass, typename TRet, typename... TArgs>
struct fn_info<TRet(TClass::*)(TArgs...) const>
{
template <typename TFunctor>
static inline std::function<QObject*(QObjectList)> pack(const TFunctor &fn, QByteArrayList &injectables) {
static inline std::function<QObject*(QObjectList)> pack(TFunctor fn, QByteArrayList &injectables) {
auto subFn = [fn](const QObjectList &params, 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<decltype(subFn), TArgs...>(subFn, injectables);
return pack_function_imp<decltype(subFn), TArgs...>(std::move(subFn), injectables);
}
};
template <typename TFunc>
inline std::function<QObject*(QObjectList)> pack_function(const TFunc &fn, QByteArrayList &injectables) {
return fn_info<TFunc>::pack(fn, injectables);
inline std::function<QObject*(QObjectList)> pack_function(TFunc fn, QByteArrayList &injectables) {
return fn_info<TFunc>::pack(std::move(fn), injectables);
}

16
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<QObject*(QObjectList)> &creator, const QByteArrayList &injectables, bool weak) :
ServiceRegistryPrivate::FnServiceInfo::FnServiceInfo(std::function<QObject*(QObjectList)> 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);

12
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 <typename TInterface, typename TService, typename TFunc>
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 <typename TInterface, typename TService>
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 <typename TService, typename TFunc>
void registerObject(const TFunc &fn, bool weak = false);
void registerObject(TFunc fn, bool weak = false);
//! Register a service via an already existing instance
template <typename TService>
void registerObject(TService *service, bool weak = false);
@ -159,11 +159,11 @@ void ServiceRegistry::registerInterface(bool weak)
}
template <typename TInterface, typename TService, typename TFunc>
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<TInterface*>(), packed_fn, injectables, weak);
}
@ -189,11 +189,11 @@ void ServiceRegistry::registerObject(bool weak)
}
template<typename TService, typename TFunc>
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<TService*>(), packed_fn, injectables, weak);
}

5
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<QObject*(QObjectList)> &creator, const QByteArrayList &injectables, bool weak);
FnServiceInfo(std::function<QObject*(QObjectList)> creator, QByteArrayList injectables, bool weak);
protected:
QObject *construct(ServiceRegistryPrivate *d) const final;

2
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

23
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 &section, const QFileSelector *selector) const
{
return readInclude(reader, [this, &section, selector](QXmlStreamReader &reader){
section = readSection(reader, selector);
return readInclude(reader, [this, &section, 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())
{}

2
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<QString, SettingsElements::Setup> _cache;
//Functions to read the settings XML

2
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)
{

2
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;

12
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<ViewModel*>(this), requestCode);
}
void ViewModel::showImp(const QMetaObject *metaObject, const QVariantHash &params, QPointer<ViewModel> parent, quint32 requestCode)
void ViewModel::showImp(const QMetaObject *metaObject, QVariantHash params, QPointer<ViewModel> parent, quint32 requestCode)
{
QMetaObject::invokeMethod(CoreAppPrivate::dInstance().data(), "showViewModel", Qt::QueuedConnection,
Q_ARG(const QMetaObject*, metaObject),
Q_ARG(QVariantHash, params),
Q_ARG(QPointer<ViewModel>, parent),
Q_ARG(QVariantHash, std::move(params)),
Q_ARG(QPointer<ViewModel>, std::move(parent)),
Q_ARG(quint32, requestCode));
}
// ------------- Private Implementation -------------
ViewModelPrivate::ViewModelPrivate() {}

16
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 <typename TViewModel>
inline void show(const QVariantHash &params = {}) const;
inline void show(QVariantHash params = {}) const;
//! @copybrief ViewModel::show(const QVariantHash &) const
void show(const char *viewModelName, const QVariantHash &params = {}) const;
//! @copybrief ViewModel::show(const QVariantHash &) const
void show(const QMetaObject *viewMetaObject, const QVariantHash &params = {}) const;
//! Show another viewmodel as a child of this one and expect its result
template <typename TViewModel>
inline void showForResult(quint32 requestCode, const QVariantHash &params = {}) 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 &params = {}) const;
//! @copybrief ViewModel::showForResult(quint32, const QVariantHash &) const
@ -57,23 +57,23 @@ private:
QScopedPointer<ViewModelPrivate> d;
static void showImp(const QMetaObject *metaObject, const QVariantHash &params, QPointer<ViewModel> parent, quint32 requestCode = 0);
static void showImp(const QMetaObject *metaObject, QVariantHash params, QPointer<ViewModel> parent, quint32 requestCode = 0);
};
// ------------- Generic Implementation -------------
template<typename TViewModel>
inline void ViewModel::show(const QVariantHash &params) const
inline void ViewModel::show(QVariantHash params) const
{
static_assert(std::is_base_of<ViewModel, TViewModel>::value, "TViewModel must extend QtMvvm::ViewModel");
showImp(&TViewModel::staticMetaObject, params, const_cast<ViewModel*>(this));
showImp(&TViewModel::staticMetaObject, std::move(params), const_cast<ViewModel*>(this));
}
template<typename TViewModel>
void ViewModel::showForResult(quint32 requestCode, const QVariantHash &params) const
void ViewModel::showForResult(quint32 requestCode, QVariantHash params) const
{
static_assert(std::is_base_of<ViewModel, TViewModel>::value, "TViewModel must extend QtMvvm::ViewModel");
showImp(&TViewModel::staticMetaObject, params, const_cast<ViewModel*>(this), requestCode);
showImp(&TViewModel::staticMetaObject, std::move(params), const_cast<ViewModel*>(this), requestCode);
}
}

6
src/mvvmcore/viewmodel_p.h

@ -6,11 +6,7 @@
namespace QtMvvm {
class ViewModelPrivate
{
public:
ViewModelPrivate();
};
class ViewModelPrivate {};
}

2
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)
{

2
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,

12
src/mvvmdatasynccore/changeremoteviewmodel.cpp

@ -11,10 +11,6 @@ std::tuple<RemoteConfig, bool> 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);
}

8
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;
};

34
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)
"<p>Name: %1<br/>"
"Fingerprint: %2</p>"
"<p>Do you want accept the request?</p>")
.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<DeviceInfo> &devices)
{
for(auto device : devices) {
for(const auto &device : devices) {
if(d->pendingGrants.remove(device.deviceId())) {
information(tr("Account access granted"),
tr("<p>Account access has been granted to device:</p>"
"<p>Name: %1<br/>"
"Fingerprint: %2</p>")
.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<DataSyncViewModel> 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<DataSyncViewModel> qPtr(q);
auto resFn = [this, qPtr](bool ok, QString error) {
auto resFn = [qPtr](bool ok, const QString &error) {
if(!qPtr)
return;
if(ok) {

4
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<QtDataSync::SyncManager::SyncState, QColor> ColorMap;
using ColorMap = QMap<QtDataSync::SyncManager::SyncState, QColor>;
//! 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;

4
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;

7
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<UserInfo> &devices)
{
//find new devices and update existing
QList<ExchangeDevicesModelPrivate::LimitedUserInfo> 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()) {

2
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);

8
src/mvvmdatasynccore/exportsetupviewmodel.cpp

@ -17,11 +17,7 @@ std::tuple<bool, bool, QString> 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);
}

4
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;
};
}

7
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);
}

4
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;
};

22
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<ExportSetupViewModel>(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 &params)
}
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<NetworkExchangeViewModel> 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))
{}

2
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;

6
src/mvvmdatasynccore/networkexchangeviewmodel_p.h

@ -1,6 +1,8 @@
#ifndef QTMVVM_NETWORKEXCHANGEVIEWMODEL_P_H
#define QTMVVM_NETWORKEXCHANGEVIEWMODEL_P_H
#include <QtDataSync/UserExchangeManager>
#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<quint32, QtDataSync::UserInfo> activeExports;
};

2
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()
{

2
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;

2
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
{

2
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;

2
src/mvvmdatasyncwidgets/exportsetupdialog.cpp

@ -33,7 +33,7 @@ ExportSetupDialog::ExportSetupDialog(ViewModel *viewModel, QWidget *parent) :
Binding::OneWayToView);
}
ExportSetupDialog::~ExportSetupDialog() {}
ExportSetupDialog::~ExportSetupDialog() = default;
void ExportSetupDialog::accept()
{

2
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;

2
src/mvvmdatasyncwidgets/identityeditdialog.cpp

@ -30,7 +30,7 @@ IdentityEditDialog::IdentityEditDialog(ViewModel *viewModel, QWidget *parent) :
Binding::OneWayToView);
}
IdentityEditDialog::~IdentityEditDialog() {}
IdentityEditDialog::~IdentityEditDialog() = default;
void IdentityEditDialog::accept()
{

2
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;

4
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)
{

2
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);

2
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)
{

2
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);

13
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<int>::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<QuickPresenter*>(ServiceRegistry::instance()->service<IPresenter>());
} catch(QException &e) {
qFatal(e.what());
qFatal("%s", e.what());
}
}

2
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 <typename TPresenter>

6
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<QObject> qmlPresenter;
InputViewFactory *inputViewFactory;
InputViewFactory *inputViewFactory = nullptr;
QHash<const QMetaObject *, QUrl> explicitMappings;
QStringList searchDirs;
QStringList searchDirs{QStringLiteral(":/qtmvvm/views")};
};
}

2
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)
{

2
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);

2
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

2
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 {

2
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);
};
}

30
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<SettingsViewModel*>(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 &section : category.sections)
createSection(section, tab);
}
@ -148,7 +144,7 @@ void SettingsDialogPrivate::createSection(const SettingsElements::Section &secti
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 &regex, 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<void(int)> &updateFunc, const QSize &iconSize, int layoutSpacing, QObject *parent) :
CategoryItemDelegate::CategoryItemDelegate(std::function<void(int)> 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

2
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

14
src/mvvmwidgets/settingsdialog_p.h

@ -23,9 +23,11 @@ namespace QtMvvm {
class CategoryItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
CategoryItemDelegate(const std::function<void(int)> &updateFunc,
const QSize &iconSize,
CategoryItemDelegate(std::function<void(int)> 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::SettingsDialog> ui;
CategoryItemDelegate *delegate;
int maxWidthBase;
CategoryItemDelegate *delegate = nullptr;
int maxWidthBase = 0;
typedef QPair<SettingsElements::Entry, QMetaProperty> EntryInfo;
using EntryInfo = QPair<SettingsElements::Entry, QMetaProperty>;
QHash<QWidget*, EntryInfo> entryMap;
QSet<QWidget*> changedEntries;

18
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<int>::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<MessageConfig::StandardButton>(resCode),
property.read(input));
@ -408,7 +408,7 @@ void WidgetsPresenter::presentFileDialog(const MessageConfig &config, QPointer<M
if(isMultiFile)
result->setResult(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<WidgetsPresenter*>(ServiceRegistry::instance()->service<IPresenter>());
} 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);
}

2
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 <typename TPresenter>

4
src/mvvmwidgets/widgetspresenter_p.h

@ -17,12 +17,12 @@ public:
static WidgetsPresenter *currentPresenter();
InputWidgetFactory* inputViewFactory;
InputWidgetFactory* inputViewFactory = nullptr;
QSet<const QMetaObject*> implicitMappings;
QHash<const QMetaObject*, const QMetaObject*> explicitMappings;
};
Q_MVVMWIDGETS_EXPORT QValidator *createUrlValidator(const QStringList &schemes, QObject* parent = nullptr);
Q_MVVMWIDGETS_EXPORT QValidator *createUrlValidator(QStringList schemes, QObject* parent = nullptr);
}

Loading…
Cancel
Save