10 changed files with 196 additions and 27 deletions
			
			
		@ -0,0 +1,53 @@ | 
				
			|||||
 | 
					#include <QObject> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					//! A QML signelton to access the QtMvvm namespace methods for showing simple dialogs
 | 
				
			||||
 | 
					class Message : public QObject | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					public: | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::information method
 | 
				
			||||
 | 
						//! @copydetails QtMvvm::information(const QString &, const QString &, const std::function<void()> &, const QString &)
 | 
				
			||||
 | 
						static void information(string title, string text, function onResult, string okText); | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::question method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::question(const QString &, const QString &, const std::function<void(bool)> &, const QString &, const QString &)
 | 
				
			||||
 | 
						static void question(string title, string text, function onResult, string yesText, string noText); | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::warning method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::warning(const QString &, const QString &, const std::function<void()> &, const QString &)
 | 
				
			||||
 | 
						static void warning(string title, string text, function onResult, string okText); | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::critical method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::critical(const QString &, const QString &, const std::function<void()> &, const QString &)
 | 
				
			||||
 | 
						static void critical(string title, string text, function onResult, string okText); | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::about method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::about
 | 
				
			||||
 | 
						static void about(string description, | 
				
			||||
 | 
										  url websiteUrl, | 
				
			||||
 | 
										  string licenseName, | 
				
			||||
 | 
										  url licenseUrl, | 
				
			||||
 | 
										  string companyName, | 
				
			||||
 | 
										  bool addQtVersion, | 
				
			||||
 | 
										  list extraTopInfos, | 
				
			||||
 | 
										  string extraBottomInfos); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::getInput method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::getInput(const QString &, const QString &, const char *, const std::function<void(QVariant)> &, const QVariant &, const QVariantMap &, const QString &, const QString &)
 | 
				
			||||
 | 
						static void getInput(string title, | 
				
			||||
 | 
											 string text, | 
				
			||||
 | 
											 string inputType, | 
				
			||||
 | 
											 function onResult, | 
				
			||||
 | 
											 var defaultValue, | 
				
			||||
 | 
											 object viewProperties, | 
				
			||||
 | 
											 string okText, | 
				
			||||
 | 
											 string cancelText); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::getExistingDirectory method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::getExistingDirectory(const std::function<void(QUrl)> &, const QString &, const QUrl &)
 | 
				
			||||
 | 
						static void getExistingDirectory(function onResult, string title, url dir); | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::getOpenFile method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::getOpenFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
 | 
				
			||||
 | 
						static void getOpenFile(function onResult, string title, list supportedMimeTypes, url dir); | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::getOpenFiles method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::getOpenFiles(const std::function<void(QList<QUrl>)> &, const QString &, const QStringList &, const QUrl &)
 | 
				
			||||
 | 
						static void getOpenFiles(function onResult, string title, list supportedMimeTypes, url dir); | 
				
			||||
 | 
						//! @brief A QML version of the QtMvvm::getSaveFile method
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::getSaveFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
 | 
				
			||||
 | 
						static void getSaveFile(function onResult, string title, list supportedMimeTypes, url dir); | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,119 @@ | 
				
			|||||
 | 
					#include <QObject> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/*! @brief A QML class to create a local mvvm multiway binding
 | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * It is basically a wrapper around the QtMvvm::bind method. The parameters are set via the | 
				
			||||
 | 
					 * properties, and once the binding component is completed, it will create the binding. It is | 
				
			||||
 | 
					 * possible to modify the properties while running. This will recreate the binding, discarding | 
				
			||||
 | 
					 * the previous one | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @sa QtMvvm::bind | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					class MvvmBinding : public QObject | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						/*! @brief The object in the role of a viewmodel
 | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @default{`null`} | 
				
			||||
 | 
						 * @accessors{ | 
				
			||||
 | 
						 *	@memberAc{viewModel} | 
				
			||||
 | 
						 *	@notifyAc{viewModelChanged()} | 
				
			||||
 | 
						 * } | 
				
			||||
 | 
						 * @sa QtMvvm::bind | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Q_PROPERTY(QObject* viewModel MEMBER viewModel NOTIFY viewModelChanged) | 
				
			||||
 | 
						/*! @brief The property of the viewmodel to use in the binding
 | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @default{<i>Empty</i>} | 
				
			||||
 | 
						 * @accessors{ | 
				
			||||
 | 
						 *	@memberAc{viewModelProperty} | 
				
			||||
 | 
						 *	@notifyAc{viewModelPropertyChanged()} | 
				
			||||
 | 
						 * } | 
				
			||||
 | 
						 * @sa QtMvvm::bind | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Q_PROPERTY(QString viewModelProperty MEMBER viewModelProperty NOTIFY viewModelPropertyChanged) | 
				
			||||
 | 
						/*! @brief The object in the role of a view
 | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @default{`parent()`} | 
				
			||||
 | 
						 * @accessors{ | 
				
			||||
 | 
						 *	@memberAc{view} | 
				
			||||
 | 
						 *	@notifyAc{viewChanged()} | 
				
			||||
 | 
						 * } | 
				
			||||
 | 
						 * @sa QtMvvm::bind | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Q_PROPERTY(QObject* view MEMBER view NOTIFY viewChanged) | 
				
			||||
 | 
						/*! @brief The property of the view to use in the binding
 | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @default{<i>Empty</i>} | 
				
			||||
 | 
						 * @accessors{ | 
				
			||||
 | 
						 *	@memberAc{viewProperty} | 
				
			||||
 | 
						 *	@notifyAc{viewPropertyChanged()} | 
				
			||||
 | 
						 * } | 
				
			||||
 | 
						 * @sa QtMvvm::bind | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Q_PROPERTY(QString viewProperty MEMBER viewProperty NOTIFY viewPropertyChanged) | 
				
			||||
 | 
						/*! @brief An alternative signal to be used instead of the viewModelProperty notify signal
 | 
				
			||||
 | 
						 * to detect property changes | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @default{<i>Empty</i>} | 
				
			||||
 | 
						 * @accessors{ | 
				
			||||
 | 
						 *	@memberAc{viewModelChangeSignal} | 
				
			||||
 | 
						 *	@notifyAc{viewModelChangeSignalChanged()} | 
				
			||||
 | 
						 * } | 
				
			||||
 | 
						 * @sa QtMvvm::bind | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Q_PROPERTY(QString viewModelChangeSignal MEMBER viewModelChangeSignal NOTIFY viewModelChangeSignalChanged) | 
				
			||||
 | 
						/*! @brief An alternative signal to be used instead of the viewProperty notify signal to
 | 
				
			||||
 | 
						 * detect property changes | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @default{<i>Empty</i>} | 
				
			||||
 | 
						 * @accessors{ | 
				
			||||
 | 
						 *	@memberAc{viewChangeSignal} | 
				
			||||
 | 
						 *	@notifyAc{viewChangeSignalChanged()} | 
				
			||||
 | 
						 * } | 
				
			||||
 | 
						 * @sa QtMvvm::bind | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Q_PROPERTY(QString viewChangeSignal MEMBER viewChangeSignal NOTIFY viewChangeSignalChanged) | 
				
			||||
 | 
						/*! @brief The type/direction of binding to create
 | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @default{`MvvmBinding::TwoWay`} | 
				
			||||
 | 
						 * @accessors{ | 
				
			||||
 | 
						 *	@readAc{type} | 
				
			||||
 | 
						 *	@writeAc{setType()} | 
				
			||||
 | 
						 *	@notifyAc{typeChanged()} | 
				
			||||
 | 
						 * } | 
				
			||||
 | 
						 * @sa QtMvvm::bind | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Q_PROPERTY(BindingDirection type READ type WRITE setType NOTIFY typeChanged) | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					public: | 
				
			||||
 | 
						//! @copydoc QtMvvm::Binding::BindingDirectionFlag
 | 
				
			||||
 | 
						enum BindingDirection { | 
				
			||||
 | 
							SingleInit = 1, //!< @copydoc QtMvvm::Binding::SingleInit
 | 
				
			||||
 | 
							OneWayToView = 3, //!< @copydoc QtMvvm::Binding::OneWayToView
 | 
				
			||||
 | 
							OneWayToViewModel = 4, //!< @copydoc QtMvvm::Binding::OneWayToViewModel
 | 
				
			||||
 | 
							TwoWay = 7 //!< @copydoc QtMvvm::Binding::TwoWay
 | 
				
			||||
 | 
						}; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						//! @copydoc QtMvvm::Binding::unbind
 | 
				
			||||
 | 
						void unbind(); | 
				
			||||
 | 
						//! @copydoc QtMvvm::Binding::isValid
 | 
				
			||||
 | 
						bool isValid(); | 
				
			||||
 | 
						//! @writeAcFn{MvvmBinding::type}
 | 
				
			||||
 | 
						void setType(BindingDirection type); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					signals: | 
				
			||||
 | 
						//! @notifyAcFn{MvvmBinding::viewModel}
 | 
				
			||||
 | 
						void viewModelChanged(); | 
				
			||||
 | 
						//! @notifyAcFn{MvvmBinding::viewModelProperty}
 | 
				
			||||
 | 
						void viewModelPropertyChanged(); | 
				
			||||
 | 
						//! @notifyAcFn{MvvmBinding::view}
 | 
				
			||||
 | 
						void viewChanged(); | 
				
			||||
 | 
						//! @notifyAcFn{MvvmBinding::viewProperty}
 | 
				
			||||
 | 
						void viewPropertyChanged(); | 
				
			||||
 | 
						//! @notifyAcFn{MvvmBinding::viewModelChangeSignal}
 | 
				
			||||
 | 
						void viewModelChangeSignalChanged(); | 
				
			||||
 | 
						//! @notifyAcFn{MvvmBinding::viewChangeSignal}
 | 
				
			||||
 | 
						void viewChangeSignalChanged(); | 
				
			||||
 | 
						//! @notifyAcFn{MvvmBinding::type}
 | 
				
			||||
 | 
						void typeChanged(); | 
				
			||||
 | 
					}; | 
				
			||||
					Loading…
					
					
				
		Reference in new issue