QXmpp Version:0.3.0
|
00001 /* 00002 * Copyright (C) 2008-2011 The QXmpp developers 00003 * 00004 * Author: 00005 * Jeremy Lainé 00006 * 00007 * Source: 00008 * http://code.google.com/p/qxmpp 00009 * 00010 * This file is a part of QXmpp library. 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2.1 of the License, or (at your option) any later version. 00016 * 00017 * This library is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 */ 00023 00024 #ifndef QXMPPDATAFORM_H 00025 #define QXMPPDATAFORM_H 00026 00027 #include <QPair> 00028 #include <QString> 00029 #include <QVariant> 00030 #include <QXmlStreamWriter> 00031 00032 00033 class QDomElement; 00034 00039 00040 class QXmppDataForm 00041 { 00042 public: 00046 00047 class Media 00048 { 00049 public: 00050 Media(unsigned int height = 0, unsigned int width = 0); 00051 00052 QList<QPair<QString, QString> > uris() const; 00053 void setUris(const QList<QPair<QString, QString> > &uris); 00054 00055 unsigned int height() const; 00056 void setHeight(unsigned int height); 00057 00058 unsigned int width() const; 00059 void setWidth(unsigned int width); 00060 00061 bool isNull() const; 00062 00063 private: 00064 QList<QPair<QString, QString> > m_uris; 00065 unsigned int m_height; 00066 unsigned int m_width; 00067 }; 00068 00069 00073 00074 class Field 00075 { 00076 public: 00078 enum Type 00079 { 00080 BooleanField, 00081 FixedField, 00082 HiddenField, 00083 JidMultiField, 00084 JidSingleField, 00085 ListMultiField, 00086 ListSingleField, 00087 TextMultiField, 00088 TextPrivateField, 00089 TextSingleField, 00090 }; 00091 00092 Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField); 00093 00094 QString description() const; 00095 void setDescription(const QString &description); 00096 00097 QString key() const; 00098 void setKey(const QString &key); 00099 00100 QString label() const; 00101 void setLabel(const QString &label); 00102 00103 QList<QPair<QString, QString> > options() const; 00104 void setOptions(const QList<QPair<QString, QString> > &options); 00105 00106 bool isRequired() const; 00107 void setRequired(bool required); 00108 00109 QXmppDataForm::Field::Type type() const; 00110 void setType(QXmppDataForm::Field::Type type); 00111 00112 QVariant value() const; 00113 void setValue(const QVariant &value); 00114 00115 Media media() const; 00116 void setMedia(const Media &media); 00117 00118 private: 00119 QString m_description; 00120 QString m_key; 00121 QString m_label; 00122 QList<QPair<QString, QString> > m_options; 00123 bool m_required; 00124 QXmppDataForm::Field::Type m_type; 00125 QVariant m_value; 00126 Media m_media; 00127 }; 00128 00130 enum Type 00131 { 00132 None, 00133 Form, 00134 00135 Submit, 00136 00137 Cancel, 00138 00139 Result, 00140 00141 00142 }; 00143 00144 QXmppDataForm(QXmppDataForm::Type type = QXmppDataForm::None); 00145 00146 QString instructions() const; 00147 void setInstructions(const QString &instructions); 00148 00149 QList<Field> fields() const; 00150 QList<Field> &fields(); 00151 void setFields(const QList<QXmppDataForm::Field> &fields); 00152 00153 QString title() const; 00154 void setTitle(const QString &title); 00155 00156 QXmppDataForm::Type type() const; 00157 void setType(QXmppDataForm::Type type); 00158 00159 bool isNull() const; 00160 00162 void parse(const QDomElement &element); 00163 void toXml(QXmlStreamWriter *writer) const; 00165 00166 private: 00167 QString m_instructions; 00168 QList<Field> m_fields; 00169 QString m_title; 00170 QXmppDataForm::Type m_type; 00171 }; 00172 00173 #endif