QXmppDataForm.h

    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 class QDomElement;
    00033
    00037
    00038 class QXmppDataForm
    00039 {
    00040 public:
    00044
    00045     class Field
    00046     {
    00047     public:
    00049         enum Type
    00050         {
    00051             BooleanField,
    00052             FixedField,
    00053             HiddenField,
    00054             JidMultiField,
    00055             JidSingleField,
    00056             ListMultiField,
    00057             ListSingleField,
    00058             TextMultiField,
    00059             TextPrivateField,
    00060             TextSingleField,
    00061         };
    00062
    00063         Field(QXmppDataForm::Field::Type type = QXmppDataForm::Field::TextSingleField);
    00064
    00065         QString description() const;
    00066         void setDescription(const QString &description);
    00067
    00068         QString key() const;
    00069         void setKey(const QString &key);
    00070
    00071         QString label() const;
    00072         void setLabel(const QString &label);
    00073
    00074         QList<QPair<QString, QString> > options() const;
    00075         void setOptions(const QList<QPair<QString, QString> > &options);
    00076
    00077         bool isRequired() const;
    00078         void setRequired(bool required);
    00079
    00080         QXmppDataForm::Field::Type type() const;
    00081         void setType(QXmppDataForm::Field::Type type);
    00082
    00083         QVariant value() const;
    00084         void setValue(const QVariant &value);
    00085
    00086     private:
    00087         QString m_description;
    00088         QString m_key;
    00089         QString m_label;
    00090         QList<QPair<QString, QString> > m_options;
    00091         bool m_required;
    00092         QXmppDataForm::Field::Type m_type;
    00093         QVariant m_value;
    00094     };
    00095
    00097     enum Type
    00098     {
    00099         None,
    00100         Form,
    00101
    00102         Submit,
    00103
    00104         Cancel,
    00105
    00106         Result,
    00107
    00108
    00109     };
    00110
    00111     QXmppDataForm(QXmppDataForm::Type type = QXmppDataForm::None);
    00112
    00113     QString instructions() const;
    00114     void setInstructions(const QString &instructions);
    00115
    00116     QList<Field> fields() const;
    00117     QList<Field> &fields();
    00118     void setFields(const QList<QXmppDataForm::Field> &fields);
    00119
    00120     QString title() const;
    00121     void setTitle(const QString &title);
    00122
    00123     QXmppDataForm::Type type() const;
    00124     void setType(QXmppDataForm::Type type);
    00125
    00126     bool isNull() const;
    00127
    00129     void parse(const QDomElement &element);
    00130     void toXml(QXmlStreamWriter *writer) const;
    00132
    00133 private:
    00134     QString m_instructions;
    00135     QList<Field> m_fields;
    00136     QString m_title;
    00137     QXmppDataForm::Type m_type;
    00138 };
    00139
    00140 #endif

All Classes Functions Enumerations Enumerator Properties