QXmpp  Version:0.4.92
 All Classes Functions Enumerations Enumerator Properties Groups
QXmppDataForm.h
1 /*
2  * Copyright (C) 2008-2011 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * http://code.google.com/p/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 <QSharedDataPointer>
29 #include <QString>
30 #include <QVariant>
31 #include <QXmlStreamWriter>
32 
33 #include "QXmppGlobal.h"
34 
35 class QDomElement;
36 class QXmppDataFormPrivate;
37 class QXmppDataFormFieldPrivate;
38 
42 
43 class QXMPP_EXPORT QXmppDataForm
44 {
45 public:
49 
50  class QXMPP_EXPORT Field
51  {
52  public:
54  enum Type
55  {
56  BooleanField,
57  FixedField,
58  HiddenField,
59  JidMultiField,
60  JidSingleField,
61  ListMultiField,
62  ListSingleField,
63  TextMultiField,
64  TextPrivateField,
65  TextSingleField,
66  };
67 
68  Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField);
69  Field(const QXmppDataForm::Field &other);
70  ~Field();
71 
72  QXmppDataForm::Field& operator=(const QXmppDataForm::Field &other);
73 
74  QString description() const;
75  void setDescription(const QString &description);
76 
77  QString key() const;
78  void setKey(const QString &key);
79 
80  QString label() const;
81  void setLabel(const QString &label);
82 
83  QList<QPair<QString, QString> > options() const;
84  void setOptions(const QList<QPair<QString, QString> > &options);
85 
86  bool isRequired() const;
87  void setRequired(bool required);
88 
89  QXmppDataForm::Field::Type type() const;
90  void setType(QXmppDataForm::Field::Type type);
91 
92  QVariant value() const;
93  void setValue(const QVariant &value);
94 
95  private:
96  QSharedDataPointer<QXmppDataFormFieldPrivate> d;
97  };
98 
100  enum Type
101  {
103  Form,
104 
105  Submit,
106 
107  Cancel,
108 
109  Result,
110 
111 
112  };
113 
115  QXmppDataForm(const QXmppDataForm &other);
116  ~QXmppDataForm();
117 
118  QXmppDataForm& operator=(const QXmppDataForm &other);
119 
120  QString instructions() const;
121  void setInstructions(const QString &instructions);
122 
123  QList<Field> fields() const;
124  QList<Field> &fields();
125  void setFields(const QList<QXmppDataForm::Field> &fields);
126 
127  QString title() const;
128  void setTitle(const QString &title);
129 
130  QXmppDataForm::Type type() const;
131  void setType(QXmppDataForm::Type type);
132 
133  bool isNull() const;
134 
136  void parse(const QDomElement &element);
137  void toXml(QXmlStreamWriter *writer) const;
139 
140 private:
141  QSharedDataPointer<QXmppDataFormPrivate> d;
142 };
143 
144 #endif