QXmpp Version: 0.9.3
Loading...
Searching...
No Matches
QXmppDataForm.h
1/*
2 * Copyright (C) 2008-2014 The QXmpp developers
3 *
4 * Author:
5 * Jeremy Lainé
6 *
7 * Source:
8 * https://github.com/qxmpp-project/qxmpp
9 *
10 * This file is a part of QXmpp library.
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 */
23
24#ifndef QXMPPDATAFORM_H
25#define QXMPPDATAFORM_H
26
27#include <QPair>
28#include <QVariant>
29
30#include "QXmppStanza.h"
31
32class QXmppDataFormPrivate;
33class QXmppDataFormFieldPrivate;
34class QXmppDataFormMediaPrivate;
35
39
40class QXMPP_EXPORT QXmppDataForm
41{
42public:
46
47 class QXMPP_EXPORT Media
48 {
49 public:
50 Media();
51 Media(const QXmppDataForm::Media &other);
52 ~Media();
53
54 QXmppDataForm::Media& operator=(const QXmppDataForm::Media &other);
55
56 int height() const;
57 void setHeight(int height);
58
59 int width() const;
60 void setWidth(int width);
61
62 QList<QPair<QString, QString> > uris() const;
63 void setUris(const QList<QPair<QString, QString> > &uris);
64
65 bool isNull() const;
66
67 private:
68 QSharedDataPointer<QXmppDataFormMediaPrivate> d;
69 };
70
74
75 class QXMPP_EXPORT Field
76 {
77 public:
79 enum Type
80 {
81 BooleanField,
82 FixedField,
83 HiddenField,
84 JidMultiField,
85 JidSingleField,
86 ListMultiField,
87 ListSingleField,
88 TextMultiField,
89 TextPrivateField,
90 TextSingleField
91 };
92
93 Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField);
94 Field(const QXmppDataForm::Field &other);
95 ~Field();
96
97 QXmppDataForm::Field& operator=(const QXmppDataForm::Field &other);
98
99 QString description() const;
100 void setDescription(const QString &description);
101
102 QString key() const;
103 void setKey(const QString &key);
104
105 QString label() const;
106 void setLabel(const QString &label);
107
108 Media media() const;
109 void setMedia(const Media &media);
110
111 QList<QPair<QString, QString> > options() const;
112 void setOptions(const QList<QPair<QString, QString> > &options);
113
114 bool isRequired() const;
115 void setRequired(bool required);
116
117 QXmppDataForm::Field::Type type() const;
118 void setType(QXmppDataForm::Field::Type type);
119
120 QVariant value() const;
121 void setValue(const QVariant &value);
122
123 private:
124 QSharedDataPointer<QXmppDataFormFieldPrivate> d;
125 };
126
128 enum Type
129 {
131 Form,
133 Submit,
135 Cancel,
137 Result
140 };
141
143 QXmppDataForm(const QXmppDataForm &other);
145
146 QXmppDataForm& operator=(const QXmppDataForm &other);
147
148 QString instructions() const;
149 void setInstructions(const QString &instructions);
150
151 QList<Field> fields() const;
152 QList<Field> &fields();
153 void setFields(const QList<QXmppDataForm::Field> &fields);
154
155 QString title() const;
156 void setTitle(const QString &title);
157
158 QXmppDataForm::Type type() const;
159 void setType(QXmppDataForm::Type type);
160
161 bool isNull() const;
162
164 void parse(const QDomElement &element);
165 void toXml(QXmlStreamWriter *writer) const;
167
168private:
169 QSharedDataPointer<QXmppDataFormPrivate> d;
170};
171
172#endif
The QXmppDataForm::Field class represents a data form field as defined by XEP-0004: Data Forms.
Definition: QXmppDataForm.h:76
Type
This enum is used to describe a field's type.
Definition: QXmppDataForm.h:80
The QXmppDataForm::Media class represents a media field as defined by XEP-0221: Data Forms Media Elem...
Definition: QXmppDataForm.h:48
The QXmppDataForm class represents a data form as defined by XEP-0004: Data Forms.
Definition: QXmppDataForm.h:41
Type
This enum is used to describe a form's type.
Definition: QXmppDataForm.h:129
@ None
Unknown form type.
Definition: QXmppDataForm.h:130