aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2020-03-29 00:39:44 +0100
committerLNJ <lnj@kaidan.im>2020-03-29 18:50:01 +0200
commit1476fa153260487a6ddbc742ca6fdc4054ffd88a (patch)
tree6a6e881cfb2d6a9bc12543910768241e7fea30a8 /src/base
parent380eb5cfe23daecc0d1dcd871dbecbc2bbe62aec (diff)
downloadqxmpp-1476fa153260487a6ddbc742ca6fdc4054ffd88a.tar.gz
QXmppDataForm: Add ctor with all attributes
This makes creating forms manually a lot easier.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppDataForm.cpp40
-rw-r--r--src/base/QXmppDataForm.h25
2 files changed, 61 insertions, 4 deletions
diff --git a/src/base/QXmppDataForm.cpp b/src/base/QXmppDataForm.cpp
index 8239b86a..99848deb 100644
--- a/src/base/QXmppDataForm.cpp
+++ b/src/base/QXmppDataForm.cpp
@@ -245,6 +245,29 @@ QXmppDataForm::Field::Field(QXmppDataForm::Field::Type type)
d->type = type;
}
+///
+/// Constructs a QXmppDataForm::Field with the specified attributes.
+///
+/// \since QXmpp 1.3
+///
+QXmppDataForm::Field::Field(QXmppDataForm::Field::Type type,
+ const QString &key,
+ const QVariant &value,
+ bool isRequired,
+ const QString &label,
+ const QString &description,
+ const QList<QPair<QString, QString>> &options)
+ : d(new QXmppDataFormFieldPrivate)
+{
+ d->type = type;
+ d->key = key;
+ d->value = value;
+ d->required = isRequired;
+ d->label = label;
+ d->description = description;
+ d->options = options;
+}
+
/// Constructs a copy of \a other.
QXmppDataForm::Field::Field(const QXmppDataForm::Field &other)
@@ -526,6 +549,23 @@ QXmppDataForm::QXmppDataForm(QXmppDataForm::Type type)
d->type = type;
}
+///
+/// Constructs a QXmppDataForm with the specified attributes.
+///
+/// \since QXmpp 1.3
+///
+QXmppDataForm::QXmppDataForm(QXmppDataForm::Type type,
+ const QList<QXmppDataForm::Field> &fields,
+ const QString &title,
+ const QString &instructions)
+ : d(new QXmppDataFormPrivate)
+{
+ d->type = type;
+ d->fields = fields;
+ d->title = title;
+ d->instructions = instructions;
+}
+
/// Constructs a copy of \a other.
QXmppDataForm::QXmppDataForm(const QXmppDataForm &other)
diff --git a/src/base/QXmppDataForm.h b/src/base/QXmppDataForm.h
index b58cb680..dd5a6030 100644
--- a/src/base/QXmppDataForm.h
+++ b/src/base/QXmppDataForm.h
@@ -41,18 +41,20 @@ class QXmppDataFormFieldPrivate;
class QXmppDataFormMediaPrivate;
class QXmppDataFormMediaSourcePrivate;
+///
/// \brief The QXmppDataForm class represents a data form as defined by
/// \xep{0004}: Data Forms.
-
+///
class QXMPP_EXPORT QXmppDataForm
{
public:
+ ///
/// \brief The \c QXmppDataForm::MediaSource class represents a link to one
/// of possibly multiple sources for a media element from \xep{0221}: Data
/// Forms Media Element consisting of a MIME type and a QUrl.
///
/// \since QXmpp 1.1
-
+ ///
class QXMPP_EXPORT MediaSource
{
public:
@@ -76,11 +78,12 @@ public:
};
#if QXMPP_DEPRECATED_SINCE(1, 1)
+ ///
/// \brief The QXmppDataForm::Media class represents a media field as
/// defined by \xep{0221}: Data Forms Media Element.
///
/// \deprecated This class is deprecated since QXmpp 1.1.
-
+ ///
class QXMPP_EXPORT Media
{
public:
@@ -115,9 +118,10 @@ public:
};
#endif
+ ///
/// \brief The QXmppDataForm::Field class represents a data form field
/// as defined by \xep{0004}: Data Forms.
-
+ ///
class QXMPP_EXPORT Field
{
public:
@@ -135,7 +139,15 @@ public:
TextSingleField
};
+ // ### QXmpp2: merge ctors
Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField);
+ Field(QXmppDataForm::Field::Type type,
+ const QString &key,
+ const QVariant &value = {},
+ bool isRequired = false,
+ const QString &label = {},
+ const QString &description = {},
+ const QList<QPair<QString, QString>> &options = {});
Field(const QXmppDataForm::Field &other);
~Field();
@@ -198,7 +210,12 @@ public:
///< or the data is a generic data set.
};
+ // ### QXmpp2: merge ctors
QXmppDataForm(QXmppDataForm::Type type = QXmppDataForm::None);
+ QXmppDataForm(QXmppDataForm::Type type,
+ const QList<Field> &fields,
+ const QString &title = {},
+ const QString &instructions = {});
QXmppDataForm(const QXmppDataForm &other);
~QXmppDataForm();