Browse Source

added presenter and message config doc

pull/2/head
Skycoder42 7 years ago
parent
commit
65134f99a0
  1. 71
      doc/ipresenter.dox
  2. 381
      doc/message.dox
  3. 12
      src/mvvmcore/ipresenter.h
  4. 179
      src/mvvmcore/message.h

71
doc/ipresenter.dox

@ -0,0 +1,71 @@
/*!
@class QtMvvm::IPresenter
This class is what you need to implement if you want to create your own GUI frontend for mvvm.
Once you created your custom presenter class, register it as service before calling
CoreApp::bootApp() (Or entering the eventloop, in case of automatic startup, like with
#QTMVVM_REGISTER_CORE_APP)
To register it, it is recommended to use a startup hook like this:
@code{.cpp}
void myPresenterInit()
{
QtMvvm::ServiceRegistry::instance()->registerInterface<QtMvvm::IPresenter, MyPresenter>();
}
Q_COREAPP_STARTUP_FUNCTION(myPresenterInit)
@endcode
*/
/*!
@fn QtMvvm::IPresenter::present
@param viewModel The ViewModel to be presenter
@param params Additional parameters for the viemodel initialization
@param parent An optional parent for the viewmodels view
@throws PresenterException When presenting fails for whatever reason
This method should:
1. Find and create a view for the viewmodel
2. Use the view of the parent viewModel to make the new view a child of that parent view
3. Make the viewmodel a child of the view (via QObject::setParent)
4. Call the viewmodels ViewModel::onInit method with the given parameters
5. Find a presentation method for the view (based on the view/viewmodel and/or parent)
6. Show the view to the user
If this method returns it is assumed the presentation was successful. If you throw the
exception, presenting has failed, and the app will automatically destroy the viewmodel and
handle cleanups and results.
@note If you need to present asynchronous, then you need to perform this step yourself in case
the asynchronous presentation failed.
@sa IPresenter::showDialog
*/
/*!
@fn QtMvvm::IPresenter::showDialog
@param config The configuration for the dialog to be shown
@param result A reference to the object to report results to
@throws PresenterException When presenting fails for whatever reason
This method should create a simple dialog based of the configuration passed to it. Read the
MessageConfig for more details on the parameters. The MessageConfig::type and
MessageConfig::subType properties are used to determine the kind of dialog to be shown. The other
properties are used to configure the dialog.
The result is a reference to a result object to report the result value and the pressed button
to. The result is owned by the caller, you must never delete it. Use the special "GUI methods" to
report the result and configure a close target.
If this method returns it is assumed the presentation was successful. If you throw the
exception, presenting has failed, and the app will automatically complete the message result with
the MessageConfig::NoButton constant.
@note If you need to present asynchronous, then you need to perform this step yourself in case
the asynchronous presentation failed.
@sa IPresenter::present, MessageConfig, MessageResult, MessageResult::complete,
MessageResult::setCloseTarget
*/

381
doc/message.dox

@ -0,0 +1,381 @@
/*!
@class QtMvvm::MessageConfig
You can use the configuration to show simple dialogs from the core application. Typically, you
can use the wrapper methods, but for more advanced dialogs you may need to create a message
config explicitly.
@sa CoreApp::showDialog, QtMvvm::information, QtMvvm::question, QtMvvm::warning,
QtMvvm::critical, QtMvvm::about, QtMvvm::getInput, QtMvvm::getExistingDirectory,
QtMvvm::getOpenFile, QtMvvm::getOpenFiles, QtMvvm::getSaveFile
*/
/*!
@enum QtMvvm::MessageConfig::StandardButton
@note The values are kept in sync with QMessageBox::StandardButton etc. This means you can
simply cast the values to the other standard buttons without any risk. This goes for other
classes like QDialogButtonBox and the QML variants as well.
*/
/*!
@property QtMvvm::MessageConfig::type
@default{`MessageConfig::TypeMessageBox`}
The type determines what kind of dialog is show. The type is a general category of dialogs. The
MessageConfig::subType is used to set the final type of dialog shown. It's interpretation
depends on the type used.
It is possible to define your own types, but that means you have to customize the presenters to
add support for those dialogs.
The types supported by default are:
- MessageConfig::TypeMessageBox
- MessageConfig::TypeInputDialog
- MessageConfig::TypeFileDialog
@accessors{
@readAc{type()}
@writeAc{setType()}
}
@sa MessageConfig::subType, MessageConfig::TypeMessageBox, MessageConfig::TypeInputDialog,
MessageConfig::TypeFileDialog
*/
/*!
@property QtMvvm::MessageConfig::subType
@default{<i>Depends on the type used</i>}
The subType is a finer specification of what kind of dialog to show. It depends on the
MessageConfig::type that is used. The possible valid subtypes depend on the MessageConfig::type
used.
It is possible to define your own subtypes, but that means you have to customize the presenters
to add support for those dialogs.
The subtypes supported by default are:
- For MessageConfig::TypeMessageBox:
- MessageConfig::SubTypeInformation
- MessageConfig::SubTypeWarning
- MessageConfig::SubTypeCritical
- MessageConfig::SubTypeQuestion
- MessageConfig::SubTypeAbout
- For MessageConfig::TypeInputDialog:
- The name of the type to get an input value for, e.g. `QString`, `int`, ...
- For MessageConfig::TypeFileDialog:
- MessageConfig::SubTypeDir
- MessageConfig::SubTypeOpenFile
- MessageConfig::SubTypeOpenFiles
- MessageConfig::SubTypeSaveFile
@accessors{
@readAc{subType()}
@writeAc{setSubType()}
@resetAc{resetSubType()}
}
@sa MessageConfig::type, MessageConfig::TypeMessageBox, MessageConfig::TypeInputDialog,
MessageConfig::TypeFileDialog
*/
/*!
@property QtMvvm::MessageConfig::title
@default{<i>Emtpy</i>}
The title is typically bigger then the rest of the text and serves as a short text to hint the
content. Depending on the platform and type it may be shown as window title or other kind of
decorative text.
@accessors{
@readAc{title()}
@writeAc{setTitle()}
}
@sa MessageConfig::text
*/
/*!
@property QtMvvm::MessageConfig::text
@default{<i>Emtpy</i>}
The text is shown as primary content, a more descriptive label, or tooltip or similar. It can
be of arbitrary length. It's role and contents heavily depend on the type and subtype beeing
used.
@accessors{
@readAc{text()}
@writeAc{setText()}
}
@sa MessageConfig::title, MessageConfig::buttonTexts, MessageConfig::viewProperties
*/
/*!
@property QtMvvm::MessageConfig::buttons
@default{<i>Depends on the type used</i>}
The buttons are the buttons in the dialog to "complete" it. Use these flags to select the
buttons the user can click on. Each button will close the dialog and be reported back via
the MessageResult::dialogDone signal.
@note The RESET-Accessor will reset both, the buttons and the buttonTexts
@accessors{
@readAc{buttons()}
@writeAc{setButtons()}
@resetAc{resetButtons()}
}
@sa MessageConfig::StandardButton, MessageConfig::buttonTexts, MessageResult::dialogDone
*/
/*!
@property QtMvvm::MessageConfig::buttonTexts
@default{<i>Empty</i>}
All buttons in this map will be shown in addition to the ones in the MessageConfig::buttons
property. The will keep their role, but show the text specified in the map instead of their
normal text.
@note The RESET-Accessor will reset both, the buttons and the buttonTexts
@accessors{
@readAc{buttonTexts()}
@writeAc{setButtonTexts()}
@writeAc{setButtonText()}
@resetAc{resetButtons()}
}
@sa MessageConfig::StandardButton, MessageConfig::buttons
*/
/*!
@property QtMvvm::MessageConfig::defaultValue
@default{<i>Invalid</i>}
Some dialogs allow the users to enter some kind of result besides of the buttons they can
press. For such dialogs, this property can be used to provide the input with a default value.
For others, this may serve as a hint for the input.
@accessors{
@readAc{defaultValue()}
@writeAc{setDefaultValue()}
}
@sa MessageConfig::type
*/
/*!
@property QtMvvm::MessageConfig::viewProperties
@default{<i>Empty</i>}
The view properties are additional properties to be set on the created views. This allows you
to configure the appearance of the dialog from within the core code.
@note The properties are always set on all views. If a view does not have such a property, it
will do nothing. This allows you to set properties for all the different views you support.
@accessors{
@readAc{viewProperties()}
@writeAc{setViewProperties()}
@writeAc{setViewProperty()}
}
@sa MessageConfig::type
*/
/*!
@var QtMvvm::MessageConfig::TypeMessageBox
<b>Value:</b> `"msgbox"`
Shows a generic message box with a title and primary text to inform the user of some kind of
event or ask him a question. The MessageConfig:subType is used to determine the kind of
message to show:
Message Type | subType value
----------------|---------------
Information | MessageConfig::SubTypeInformation
Question | MessageConfig::SubTypeWarning
Warning | MessageConfig::SubTypeCritical
Critical Error | MessageConfig::SubTypeQuestion
About Dialog | MessageConfig::SubTypeAbout
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeInputDialog,
MessageConfig::TypeFileDialog
*/
/*!
@var QtMvvm::MessageConfig::TypeInputDialog
<b>Value:</b> `"input"`
Shows a generic input dialog with a title and a short label, together with some kind of edit
view in order to input a single value. The datatype to get as well as the kind of input view
to create is determined by MessageConfig:subType. Theoretically, and type that can be passed
via QVariant can be used as input value. However, only for the most common types do default
edit views exist. In case you want to use types not present in the list below, you need to
create edit views yourself
Type | Widgets edit | Quick edit
--------------------|-------------------------------|------------
bool | QCheckBox | CheckBox
switch | -/- | Switch
QString, string | QLineEdit | TextField
int | QSpinBox | SpinBox
double, number | QDoubleSpinBox | DoubleSpinBox
QDate | QDateEdit | -/-
QTime | QTimeEdit | -/-
QDateTime, date | QDateTimeEdit | -/-
QFont | QFontComboBox | FontEdit
QKeySequence | QKeySequenceEdit | -/-
QUrl, url | QLineEdit with QUrlValidator | UrlField
selection, list | QComboBox | ListEdit
radiolist | -/- | RadioListEdit
The following types have special properties as well:
- QString, string:
- `regexp`: A regular expression pattern (QString) to be used as input validator for the
text
- `patternOptions`: QRegularExpression::PatternOptions as options for the regular
expression
- QUrl, url:
- `allowedSchemes`: A QStringList with allowed schemes for the URL
- selection, list, radiolist:
- `listElements`: A list of elemets the user can select from. Can either be:
- QString elements: They will serve as display value and returned value
- QVariantMap elements: A map containing the following values:
- `name`: A QString shown to the user to select
- `value`: A QVariant value that is returned instead of the selected name
@sa MessageConfig::type, MessageConfig::subType, InputViewFactory, InputWidgetFactory,
MessageConfig::TypeMessageBox, MessageConfig::TypeFileDialog
*/
/*!
@var QtMvvm::MessageConfig::TypeFileDialog
<b>Value:</b> `"file"`
Shows a generic file dialog utilizing the operating systems default file dialogs in order to
show a native dialog the user can use to select files or directories
Dialog Type | subType value
----------------|---------------
Open Directory | MessageConfig::SubTypeDir
Open File | MessageConfig::SubTypeOpenFile
Open Files | MessageConfig::SubTypeOpenFiles
Save File | MessageConfig::SubTypeSaveFile
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeInputDialog,
MessageConfig::TypeMessageBox
*/
/*!
@var QtMvvm::MessageConfig::SubTypeInformation
<b>Value:</b> `"information"`
An information message box typically shows a neutral/positiv information.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox
*/
/*!
@var QtMvvm::MessageConfig::SubTypeWarning
<b>Value:</b> `"warning"`
An warning message box typically shows a (non critical) warning.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox
*/
/*!
@var QtMvvm::MessageConfig::SubTypeCritical
<b>Value:</b> `"critical"`
An critical message box typically shows a critical and often unrecoverable error.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox
*/
/*!
@var QtMvvm::MessageConfig::SubTypeQuestion
<b>Value:</b> `"question"`
An question message box typically asks the user a simple Yes-No question he can reply using
the buttons.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox
*/
/*!
@var QtMvvm::MessageConfig::SubTypeAbout
<b>Value:</b> `"about"`
An about dialog is a simple informative dialog showing information about the application in
a neutral manner, but in a sligthly different style than a simple information message.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeMessageBox
*/
/*!
@var QtMvvm::MessageConfig::SubTypeDir
<b>Value:</b> `"dir"`
A file dialog to open a directory lets the user select a single, existing directory. Depending
on the platform he might be able to create a new directory via the dialog, but he can only
select an existing one.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog
*/
/*!
@var QtMvvm::MessageConfig::SubTypeOpenFile
<b>Value:</b> `"open"`
A file dialog to open a file lets the user select a single, existing file.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog
*/
/*!
@var QtMvvm::MessageConfig::SubTypeOpenFiles
<b>Value:</b> `"files"`
A file dialog to open multiple files lets the user select a list of existing files. They can
be in different folders, if the platform allows this.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog
*/
/*!
@var QtMvvm::MessageConfig::SubTypeSaveFile
<b>Value:</b> `"save"`
A file dialog to save a file lets the user select a single file to be created or overwritten
to save content to it.
@sa MessageConfig::type, MessageConfig::subType, MessageConfig::TypeFileDialog
*/

12
src/mvvmcore/ipresenter.h

@ -9,35 +9,47 @@
namespace QtMvvm {
//! An exception to be thrown from the presenter if presenting fails
class Q_MVVMCORE_EXPORT PresenterException : public QException
{
public:
//! Constructor with an error message
PresenterException(const QByteArray &what);
//! @inherit{QException::what}
const char *what() const noexcept override;
//! @inherit{QException::raise}
void raise() const override;
//! @inherit{QException::clone}
QException *clone() const override;
protected:
//! @private
PresenterException(const PresenterException * const other);
//! @private
const QByteArray _what;
};
//! The interface for a GUI view presenter
class Q_MVVMCORE_EXPORT IPresenter
{
public:
inline virtual ~IPresenter() = default;
//! Called to present a viewmodel
virtual void present(ViewModel *viewModel, const QVariantHash &params, QPointer<ViewModel> parent = nullptr) = 0;
//! Called to present a dialog via a message config
virtual void showDialog(const MessageConfig &config, MessageResult *result) = 0;
};
}
//! The IID of the IPresenter class
#define QtMvvm_IPresenterIid "de.skycoder42.qtmvvm.core.IPresenter"
Q_DECLARE_INTERFACE(QtMvvm::IPresenter, QtMvvm_IPresenterIid)
Q_DECLARE_METATYPE(QtMvvm::IPresenter*)
//! @file ipresenter.h The IPresenter class header
#endif // QTMVVM_IPRESENTER_H

179
src/mvvmcore/message.h

@ -14,91 +14,150 @@
namespace QtMvvm {
class MessageConfigPrivate;
//! A configuration for a simple dialog to be shown from the core code
class Q_MVVMCORE_EXPORT MessageConfig
{
Q_GADGET
Q_DECLARE_TR_FUNCTIONS(MessageConfig)
//! The general type of dialog to be shown
Q_PROPERTY(QByteArray type READ type WRITE setType)
//! A subtype for the dialog to specify what exactly it should show
Q_PROPERTY(QByteArray subType READ subType WRITE setSubType RESET resetSubType)
//! The dialog title or window title
Q_PROPERTY(QString title READ title WRITE setTitle)
//! The primary text/message to be displayed
Q_PROPERTY(QString text READ text WRITE setText)
//! The available buttons a user may press
Q_PROPERTY(StandardButtons buttons READ buttons WRITE setButtons RESET resetButtons)
//! A map of name overwrites for the texts shown on buttons
Q_PROPERTY(QVariantMap buttonTexts READ buttonTextsMap WRITE setButtonTextsMap RESET resetButtons)
//! A default value for dialogs that take some kind of input
Q_PROPERTY(QVariant defaultValue READ defaultValue WRITE setDefaultValue)
//! Additional properties to be set on the created views
Q_PROPERTY(QVariantMap viewProperties READ viewProperties WRITE setViewProperties)
public:
//! The Possible Buttons a dialog can have
enum StandardButton {
// keep this in sync with QPlatformDialogHelper::StandardButton
NoButton = 0x00000000,
Ok = 0x00000400,
Save = 0x00000800,
SaveAll = 0x00001000,
Open = 0x00002000,
Yes = 0x00004000,
YesToAll = 0x00008000,
No = 0x00010000,
NoToAll = 0x00020000,
Abort = 0x00040000,
Retry = 0x00080000,
Ignore = 0x00100000,
Close = 0x00200000,
Cancel = 0x00400000,
Discard = 0x00800000,
Help = 0x01000000,
Apply = 0x02000000,
Reset = 0x04000000,
RestoreDefaults = 0x08000000
NoButton = 0x00000000, //!< Equivalent to QMessageBox::NoButton
Ok = 0x00000400, //!< Equivalent to QMessageBox::Ok
Save = 0x00000800, //!< Equivalent to QMessageBox::Save
SaveAll = 0x00001000, //!< Equivalent to QMessageBox::SaveAll
Open = 0x00002000, //!< Equivalent to QMessageBox::Open
Yes = 0x00004000, //!< Equivalent to QMessageBox::Yes
YesToAll = 0x00008000, //!< Equivalent to QMessageBox::YesToAll
No = 0x00010000, //!< Equivalent to QMessageBox::No
NoToAll = 0x00020000, //!< Equivalent to QMessageBox::NoToAll
Abort = 0x00040000, //!< Equivalent to QMessageBox::Abort
Retry = 0x00080000, //!< Equivalent to QMessageBox::Retry
Ignore = 0x00100000, //!< Equivalent to QMessageBox::Ignore
Close = 0x00200000, //!< Equivalent to QMessageBox::Close
Cancel = 0x00400000, //!< Equivalent to QMessageBox::Cancel
Discard = 0x00800000, //!< Equivalent to QMessageBox::Discard
Help = 0x01000000, //!< Equivalent to QMessageBox::Help
Apply = 0x02000000, //!< Equivalent to QMessageBox::Apply
Reset = 0x04000000, //!< Equivalent to QMessageBox::Reset
RestoreDefaults = 0x08000000 //!< Equivalent to QMessageBox::RestoreDefaults
};
Q_DECLARE_FLAGS(StandardButtons, StandardButton)
Q_FLAG(StandardButtons)
/**
* @name Possible standard values for MessageConfig::type
* @{
*/
//! @brief A type to show a standard message box
static const QByteArray TypeMessageBox;
//! A type to show a generic input dialog
static const QByteArray TypeInputDialog;
//! A type to show a generic file dialog
static const QByteArray TypeFileDialog;
//! @}
/**
* @name Possible values for MessageConfig::subType when using the type MessageConfig::TypeMessageBox
* @{
*/
//! @brief A subType to show an information message
static const QByteArray SubTypeInformation;
//! A subType to show a warning message
static const QByteArray SubTypeWarning;
//! A subType to show a critical error message
static const QByteArray SubTypeCritical;
//! A subType to show a question message
static const QByteArray SubTypeQuestion;
//! A subType to show an about dialog
static const QByteArray SubTypeAbout;
//! @}
/**
* @name Possible values for MessageConfig::subType when using the type MessageConfig::TypeFileDialog
* @{
*/
//! @brief A subType to show an open directory dialog
static const QByteArray SubTypeDir;
//! A subType for to show an open file dialog
static const QByteArray SubTypeOpenFile;
//! A subType for to show an open files dialog
static const QByteArray SubTypeOpenFiles;
//! A subType for to show a save file dialog
static const QByteArray SubTypeSaveFile;
//! @}
//! Default constructor, can take a type and a subtype
MessageConfig(const QByteArray &type = TypeMessageBox, const QByteArray &subType = {});
//! Copy constructor
MessageConfig(const MessageConfig &other);
~MessageConfig();
//! Assignment operator
MessageConfig &operator=(const MessageConfig &other);
//! @readAcFn{MessageConfig::type}
QByteArray type() const;
//! @readAcFn{MessageConfig::subType}
QByteArray subType() const;
//! @readAcFn{MessageConfig::title}
QString title() const;
//! @readAcFn{MessageConfig::text}
QString text() const;
//! @readAcFn{MessageConfig::buttons}
StandardButtons buttons() const;
//! @readAcFn{MessageConfig::buttonTexts}
QHash<StandardButton, QString> buttonTexts() const;
QByteArray inputType() const;
//! @readAcFn{MessageConfig::defaultValue}
QVariant defaultValue() const;
//! @readAcFn{MessageConfig::viewProperties}
QVariantMap viewProperties() const;
//! @writeAcFn{MessageConfig::type}
MessageConfig &setType(const QByteArray &type);
//! @writeAcFn{MessageConfig::subType}
MessageConfig &setSubType(const QByteArray &subType);
//! @writeAcFn{MessageConfig::title}
MessageConfig &setTitle(const QString &title);
//! @writeAcFn{MessageConfig::text}
MessageConfig &setText(const QString &text);
//! @writeAcFn{MessageConfig::buttons}
MessageConfig &setButtons(StandardButtons buttons);
//! @writeAcFn{MessageConfig::buttonTexts}
MessageConfig &setButtonTexts(const QHash<StandardButton, QString> &buttonTexts);
//! @writeAcFn{MessageConfig::buttonTexts}
MessageConfig &setButtonText(StandardButton button, const QString &text);
//! @writeAcFn{MessageConfig::defaultValue}
MessageConfig &setDefaultValue(const QVariant &defaultValue);
//! @writeAcFn{MessageConfig::viewProperties}
MessageConfig &setViewProperties(const QVariantMap &viewProperties);
//! @writeAcFn{MessageConfig::viewProperties}
MessageConfig &setViewProperty(const QString &key, const QVariant &value);
//! @resetAcFn{MessageConfig::subType}
MessageConfig &resetSubType();
//! @resetAcFn{MessageConfig::buttons}
MessageConfig &resetButtons();
private:
@ -109,101 +168,138 @@ private:
};
class MessageResultPrivate;
//! A result watcher to get the result once a dialog has finished
class Q_MVVMCORE_EXPORT MessageResult : public QObject
{
Q_OBJECT
//! The result for an input, if the dialog had any
Q_PROPERTY(QVariant result READ result WRITE setResult)
//! Specifies whether the object should delete itself after completition
Q_PROPERTY(bool autoDelete READ autoDelete WRITE setAutoDelete NOTIFY autoDeleteChanged)
public:
explicit MessageResult();
~MessageResult();
//! Checks if the dialog has a result
bool hasResult() const;
//! @readAcFn{MessageResult::result}
QVariant result() const;
//! @readAcFn{MessageResult::autoDelete}
bool autoDelete() const;
//USE IN GUI ONLY
//TODO document USE IN GUI ONLY in doc
/**
* @name Presenter-Only methods
* @details The following methods should be used by the presenter only, not from the core
* @{
*/
//! @brief Sets an object and a method to be called to close the dialog
Q_INVOKABLE void setCloseTarget(QObject *closeObject, const QString &closeMethod);
//! @copydoc MessageResult::setCloseTarget(QObject *, const QString &)
Q_INVOKABLE void setCloseTarget(QObject *closeObject, const QMetaMethod &closeMethod);
//! Completes the dialog and tells the result that it is finished
Q_INVOKABLE void complete(QtMvvm::MessageConfig::StandardButton result);
//! @copybrief MessageResult::complete(QtMvvm::MessageConfig::StandardButton)
Q_INVOKABLE inline void complete(QtMvvm::MessageConfig::StandardButton result, const QVariant &resultValue) {
setResult(resultValue);
complete(result);
}
//! @}
public Q_SLOTS:
//! Tries to discard the dialog by closing it
void discardMessage();
//! @writeAcFn{MessageResult::result}
void setResult(QVariant result);
//! @writeAcFn{MessageResult::autoDelete}
void setAutoDelete(bool autoDelete);
Q_SIGNALS:
//! Is emitted as soon as the dialog was completed
void dialogDone(QtMvvm::MessageConfig::StandardButton result);
//! @notifyAcFn{MessageResult::autoDelete}
void autoDeleteChanged(bool autoDelete);
private:
QScopedPointer<MessageResultPrivate> d;
};
/**
* @name Methods to show simple messageboxes (MessageConfig::TypeMessageBox)
* @{
*/
//! @brief A shortcut to show a simple information messagebox
Q_MVVMCORE_EXPORT MessageResult *information(const QString &title,
const QString &text,
const QString &okText = {});
//! @copydoc QtMvvm::information(const QString &, const QString &, const std::function<void()> &, const QString &)
Q_MVVMCORE_EXPORT void information(const QString &title,
const QString &text,
QObject *scope,
const std::function<void()> &onResult,
const QString &okText = {});
//! @copydoc QtMvvm::information(const QString &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void information(const QString &title,
const QString &text,
const std::function<void()> &onResult,
const QString &okText = {});
//! A shortcut to show a simple question messagebox
Q_MVVMCORE_EXPORT MessageResult *question(const QString &title,
const QString &text,
const QString &yesText = {},
const QString &noText = {});
//! @copydoc QtMvvm::question(const QString &, const QString &, const std::function<void(bool)> &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void question(const QString &title,
const QString &text,
QObject *scope,
const std::function<void(bool)> &onResult,
const QString &yesText = {},
const QString &noText = {});
//! @copydoc QtMvvm::question(const QString &, const QString &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void question(const QString &title,
const QString &text,
const std::function<void(bool)> &onResult,
const QString &yesText = {},
const QString &noText = {});
//! A shortcut to show a simple warning messagebox
Q_MVVMCORE_EXPORT MessageResult *warning(const QString &title,
const QString &text,
const QString &okText = {});
//! @copydoc QtMvvm::warning(const QString &, const QString &, const std::function<void()> &, const QString &)
Q_MVVMCORE_EXPORT void warning(const QString &title,
const QString &text,
QObject *scope,
const std::function<void()> &onResult,
const QString &okText = {});
//! @copydoc QtMvvm::warning(const QString &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void warning(const QString &title,
const QString &text,
const std::function<void()> &onResult,
const QString &okText = {});
//! A shortcut to show a simple critical error messagebox
Q_MVVMCORE_EXPORT MessageResult *critical(const QString &title,
const QString &text,
const QString &okText = {});
//! @copydoc QtMvvm::critical(const QString &, const QString &, const std::function<void()> &, const QString &)
Q_MVVMCORE_EXPORT void critical(const QString &title,
const QString &text,
QObject *scope,
const std::function<void()> &onResult,
const QString &okText = {});
//! @copydoc QtMvvm::critical(const QString &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void critical(const QString &title,
const QString &text,
const std::function<void()> &onResult,
const QString &okText = {});
//! A shortcut to show a rich but simple about dialog
Q_MVVMCORE_EXPORT MessageResult *about(const QString &description,
const QUrl &websiteUrl = QUrl(),
const QString &licenseName = QString(),
@ -212,7 +308,13 @@ Q_MVVMCORE_EXPORT MessageResult *about(const QString &description,
bool addQtVersion = true,
const QStringList &extraTopInfos = QStringList(),
const QString &extraBottomInfos = QString());
//! @}
/**
* @name Methods to show simple input dialogs (MessageConfig::TypeInputDialog)
* @{
*/
//! @brief A shortcut to show an input dialog based of a type name
Q_MVVMCORE_EXPORT MessageResult *getInput(const QString &title,
const QString &text,
const char *inputType,
@ -220,6 +322,7 @@ Q_MVVMCORE_EXPORT MessageResult *getInput(const QString &title,
const QVariantMap &viewProperties = {},
const QString &okText = {},
const QString &cancelText = {});
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const char *, const std::function<void(QVariant)> &, const QVariant &, const QVariantMap &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void getInput(const QString &title,
const QString &text,
const char *inputType,
@ -229,6 +332,7 @@ Q_MVVMCORE_EXPORT void getInput(const QString &title,
const QVariantMap &viewProperties = {},
const QString &okText = {},
const QString &cancelText = {});
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const char *, const QVariant &, const QVariantMap &, const QString &, const QString &)
Q_MVVMCORE_EXPORT void getInput(const QString &title,
const QString &text,
const char *inputType,
@ -238,89 +342,110 @@ Q_MVVMCORE_EXPORT void getInput(const QString &title,
const QString &okText = {},
const QString &cancelText = {});
//! A shortcut to show an input dialog based of a type as generic parameter
template <typename TEdit>
inline MessageResult *getInput(const QString &title,
const QString &text,
const QVariant &defaultValue = {},
const TEdit &defaultValue = {},
const QVariantMap &viewProperties = {},
const QString &okText = {},
const QString &cancelText = {}) {
return getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), defaultValue, viewProperties, okText, cancelText);
return getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), QVariant::fromValue(defaultValue), viewProperties, okText, cancelText);
}
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const std::function<void(TEdit, bool)> &, const TEdit &, const QVariantMap &, const QString &, const QString &)
template <typename TEdit>
inline void getInput(const QString &title,
const QString &text,
QObject *scope,
const std::function<void(TEdit, bool)> &onResult,
const QVariant &defaultValue = {},
const TEdit &defaultValue = {},
const QVariantMap &viewProperties = {},
const QString &okText = {},
const QString &cancelText = {}) {
getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), scope, [onResult](QVariant v) {
onResult(v.template value<TEdit>(), v.isValid());
}, defaultValue, viewProperties, okText, cancelText);
}, QVariant::fromValue(defaultValue), viewProperties, okText, cancelText);
}
//! @copydoc QtMvvm::getInput(const QString &, const QString &, const TEdit &, const QVariantMap &, const QString &, const QString &)
template <typename TEdit>
inline void getInput(const QString &title,
const QString &text,
const std::function<void(TEdit, bool)> &onResult,
const QVariant &defaultValue = {},
const TEdit &defaultValue = {},
const QVariantMap &viewProperties = {},
const QString &okText = {},
const QString &cancelText = {}) {
getInput(title, text, QMetaType::typeName(qMetaTypeId<TEdit>()), [onResult](QVariant v) {
onResult(v.template value<TEdit>(), v.isValid());
}, defaultValue, viewProperties, okText, cancelText);
}, QVariant::fromValue(defaultValue), viewProperties, okText, cancelText);
}
//! @}
/**
* @name Methods to show simple file dialogs (MessageConfig::TypeFileDialog)
* @{
*/
//! @brief A shortcut to show a file dialog to select an existing directory
Q_MVVMCORE_EXPORT MessageResult *getExistingDirectory(const QString &title = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getExistingDirectory(const std::function<void(QUrl)> &, const QString &, const QUrl &)
Q_MVVMCORE_EXPORT void getExistingDirectory(QObject *scope,
const std::function<void(QUrl)> &onResult,
const QString &title = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getExistingDirectory(const QString &, const QUrl &)
Q_MVVMCORE_EXPORT void getExistingDirectory(const std::function<void(QUrl)> &onResult,
const QString &title = {},
const QUrl &dir = {});
//! @brief A shortcut to show a file dialog to select an existing file
Q_MVVMCORE_EXPORT MessageResult *getOpenFile(const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFile(QObject *scope,
const std::function<void(QUrl)> &onResult,
const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFile(const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFile(const std::function<void(QUrl)> &onResult,
const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @brief A shortcut to show a file dialog to select multiple existing files
Q_MVVMCORE_EXPORT MessageResult *getOpenFiles(const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFiles(const std::function<void(QList<QUrl>)> &, const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFiles(QObject *scope,
const std::function<void(QList<QUrl>)> &onResult,
const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getOpenFiles(const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getOpenFiles(const std::function<void(QList<QUrl>)> &onResult,
const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @brief A shortcut to show a file dialog to select a new file for saving
Q_MVVMCORE_EXPORT MessageResult *getSaveFile(const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getSaveFile(const std::function<void(QUrl)> &, const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getSaveFile(QObject *scope,
const std::function<void(QUrl)> &onResult,
const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @copydoc QtMvvm::getSaveFile(const QString &, const QStringList &, const QUrl &)
Q_MVVMCORE_EXPORT void getSaveFile(const std::function<void(QUrl)> &onResult,
const QString &title = {},
const QStringList &supportedMimeTypes = {},
const QUrl &dir = {});
//! @}
}

Loading…
Cancel
Save