diff --git a/examples/mvvmcore/SampleCore/SampleCore.pro b/examples/mvvmcore/SampleCore/SampleCore.pro index 1c1f716..6e5c266 100644 --- a/examples/mvvmcore/SampleCore/SampleCore.pro +++ b/examples/mvvmcore/SampleCore/SampleCore.pro @@ -24,3 +24,6 @@ SOURCES += \ target.path = $$[QT_INSTALL_EXAMPLES]/mvvmcore/$$TARGET INSTALLS += target + +RESOURCES += \ + sample_core.qrc diff --git a/examples/mvvmcore/SampleCore/sample_core.qrc b/examples/mvvmcore/SampleCore/sample_core.qrc new file mode 100644 index 0000000..9d84d5c --- /dev/null +++ b/examples/mvvmcore/SampleCore/sample_core.qrc @@ -0,0 +1,5 @@ + + + settings.xml + + diff --git a/examples/mvvmcore/SampleCore/samplecoreapp.cpp b/examples/mvvmcore/SampleCore/samplecoreapp.cpp index d19effd..22bd191 100644 --- a/examples/mvvmcore/SampleCore/samplecoreapp.cpp +++ b/examples/mvvmcore/SampleCore/samplecoreapp.cpp @@ -13,6 +13,8 @@ SampleCoreApp::SampleCoreApp(QObject *parent) : void SampleCoreApp::performRegistrations() { + Q_INIT_RESOURCE(sample_core); + QtMvvm::registerInterfaceConverter(); } diff --git a/examples/mvvmcore/SampleCore/settings.xml b/examples/mvvmcore/SampleCore/settings.xml new file mode 100644 index 0000000..218aed3 --- /dev/null +++ b/examples/mvvmcore/SampleCore/settings.xml @@ -0,0 +1,89 @@ + + + + +
+ + + property + bool + Please do check me + + + + + + baum + 4.2 + + + + Variant A + Variant B + Variant C + + + +
+
+ + 0.0 + 1.0 + + + + + Value A + 1 + + + Value B + 2 + + + Value C + 4 + + + Value A+B + 3 + + + Value A+C + 5 + + + Value B+C + 6 + + + Value A+B+C + 7 + + + +
+
+ + + +
diff --git a/src/mvvmquick/DoubleSpinBox.qml b/src/mvvmquick/DoubleSpinBox.qml index e8b1220..d1ac5a4 100644 --- a/src/mvvmquick/DoubleSpinBox.qml +++ b/src/mvvmquick/DoubleSpinBox.qml @@ -4,6 +4,8 @@ import QtQuick.Controls 2.3 SpinBox { id: _edit property alias inputValue: _edit.dValue + property alias minimum: _edit.dFrom + property alias maximum: _edit.dTo editable: true //double spinbox code diff --git a/src/mvvmquick/ListEdit.qml b/src/mvvmquick/ListEdit.qml index 0f2cb00..8f313d6 100644 --- a/src/mvvmquick/ListEdit.qml +++ b/src/mvvmquick/ListEdit.qml @@ -4,16 +4,32 @@ import QtQuick.Controls 2.3 ComboBox { id: _edit property alias inputValue: _edit.currentValue - property var currentValue: getCurrentValue() property alias listElements: _edit.model + property alias currentValue: _valueHelper.value textRole: "name" + property var _valueHelper: { return {}; } - function getCurrentValue() { - var value = _edit.model[_edit.currentIndex].value; - if(typeof value !== "undefined") - return value; - else - return _edit.displayText; + Component.onCompleted: { + Object.defineProperty( + _valueHelper, + "value", + { + get: function () { + var value = _edit.model[_edit.currentIndex].value; + if(typeof value !== "undefined") + return value; + else + return _edit.displayText; + }, + set: function (value) { + var index = find(value); + if(index !== -1) + currentIndex = index; + else if(editable) + editText = value; + } + } + ); } } diff --git a/src/mvvmquick/SpinBox.qml b/src/mvvmquick/SpinBox.qml index f4ff7e7..eb393b2 100644 --- a/src/mvvmquick/SpinBox.qml +++ b/src/mvvmquick/SpinBox.qml @@ -4,5 +4,7 @@ import QtQuick.Controls 2.3 SpinBox { id: _edit property alias inputValue: _edit.value + property alias minimum: _edit.from + property alias maximum: _edit.to editable: true } diff --git a/src/mvvmsettingscore/settings.xsd b/src/mvvmsettingscore/settings.xsd new file mode 100644 index 0000000..776e7bb --- /dev/null +++ b/src/mvvmsettingscore/settings.xsd @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mvvmsettingscore/settingssetup.h b/src/mvvmsettingscore/settingssetup.h index dc46d03..1b5f328 100644 --- a/src/mvvmsettingscore/settingssetup.h +++ b/src/mvvmsettingscore/settingssetup.h @@ -65,8 +65,8 @@ struct SettingsCategory struct SettingsSetup { - bool allowSearch = false; - bool allowRestore = false; + bool allowSearch = true; + bool allowRestore = true; QList categories; }; diff --git a/src/mvvmsettingscore/settingssetuploader.cpp b/src/mvvmsettingscore/settingssetuploader.cpp index 0766d49..c2b4051 100644 --- a/src/mvvmsettingscore/settingssetuploader.cpp +++ b/src/mvvmsettingscore/settingssetuploader.cpp @@ -39,8 +39,11 @@ SettingsSetup SettingsSetupLoader::loadSetup(const QString &filePath, const QStr if(!reader.readNextStartElement() || reader.name() != QStringLiteral("SettingsConfig")) throwElement(reader, "SettingsConfig"); - setup.allowSearch = reader.boolValue("allowSearch"); - setup.allowRestore = reader.boolValue("allowRestore"); + + if(reader.hasValue("allowSearch")) + setup.allowSearch = reader.boolValue("allowSearch"); + if(reader.hasValue("allowRestore")) + setup.allowRestore = reader.boolValue("allowRestore"); if(reader.readNextStartElement()) { if(reader.name() == QStringLiteral("Category") || diff --git a/src/mvvmsettingscore/settingsviewmodel.cpp b/src/mvvmsettingscore/settingsviewmodel.cpp index 0b67848..d512758 100644 --- a/src/mvvmsettingscore/settingsviewmodel.cpp +++ b/src/mvvmsettingscore/settingsviewmodel.cpp @@ -77,8 +77,9 @@ void SettingsViewModel::resetValue(const QString &key) d->settings->remove(key); } -void SettingsViewModel::callAction(const QString &entryId) +void SettingsViewModel::callAction(const QString &entryId, const QVariantMap ¶meters) { + Q_UNUSED(parameters) logWarning() << "Unknown action requested with entry id:" << entryId; } diff --git a/src/mvvmsettingscore/settingsviewmodel.h b/src/mvvmsettingscore/settingsviewmodel.h index 78a8e65..ceab3b2 100644 --- a/src/mvvmsettingscore/settingsviewmodel.h +++ b/src/mvvmsettingscore/settingsviewmodel.h @@ -45,7 +45,7 @@ public: Q_INVOKABLE virtual void resetValue(const QString &key); public Q_SLOTS: - virtual void callAction(const QString &entryId); + virtual void callAction(const QString &entryId, const QVariantMap ¶meters); void setSettingsSetupLoader(QtMvvm::ISettingsSetupLoader* settingsSetupLoader); diff --git a/src/mvvmwidgets/selectcombobox.cpp b/src/mvvmwidgets/selectcombobox.cpp index 3a7d8b4..a62549d 100644 --- a/src/mvvmwidgets/selectcombobox.cpp +++ b/src/mvvmwidgets/selectcombobox.cpp @@ -41,7 +41,7 @@ void SelectComboBox::setCurrentValue(const QVariant &data) auto index = findData(data); if(index != -1) setCurrentIndex(index); - else + else if(isEditable()) setCurrentText(data.toString()); } diff --git a/tests/auto/settings.xml b/tests/auto/settings.xml new file mode 100644 index 0000000..9ca8d0b --- /dev/null +++ b/tests/auto/settings.xml @@ -0,0 +1,59 @@ + + + /absolute/include/path.xml + ../relative/include/path.xml + + /absolute/include/path.xml + ../relative/include/path.xml +
+ /absolute/include/path.xml + ../relative/include/path.xml + + /absolute/include/path.xml + ../relative/include/path.xml + + prop + attrib + sample + Please do check me + + 42 + 42 + + + 42 + + elem 1 + elem 2 + + + baum + 42 + + + + + + +
+
+ + +