File indexing completed on 2024-04-28 16:21:23

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003,2004 Ariya Hidayat <ariya@kde.org>
0003    Copyright (C) 2005 Tomas Mecir <mecirt@gmail.com>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; only
0008    version 2 of the License.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018    Boston, MA 02110-1301, USA.
0019 */
0020 
0021 
0022 #ifndef CALLIGRA_SHEETS_FUNCTION_DESCRIPTION
0023 #define CALLIGRA_SHEETS_FUNCTION_DESCRIPTION
0024 
0025 #include <QList>
0026 #include <QStringList>
0027 
0028 #include "sheets_odf_export.h"
0029 
0030 class QDomElement;
0031 
0032 namespace Calligra
0033 {
0034 namespace Sheets
0035 {
0036 
0037 enum ParameterType { KSpread_Int, KSpread_Float, KSpread_String, KSpread_Boolean, KSpread_Any, KSpread_Date };
0038 
0039 /**
0040  * \ingroup Value
0041  * A function parameter.
0042  */
0043 class CALLIGRA_SHEETS_ODF_EXPORT FunctionParameter
0044 {
0045 public:
0046     FunctionParameter();
0047     FunctionParameter(const FunctionParameter& param);
0048     explicit FunctionParameter(const QDomElement& element);
0049 
0050     QString helpText() const {
0051         return m_help;
0052     }
0053     ParameterType type() const {
0054         return m_type;
0055     }
0056     bool hasRange() const {
0057         return m_range;
0058     }
0059 
0060 private:
0061     QString m_help;
0062     ParameterType m_type;
0063     bool m_range;
0064 };
0065 
0066 /**
0067  * \ingroup Value
0068  * A function description.
0069  */
0070 class CALLIGRA_SHEETS_ODF_EXPORT FunctionDescription
0071 {
0072 public:
0073     FunctionDescription();
0074     explicit FunctionDescription(const QDomElement& element);
0075     FunctionDescription(const FunctionDescription& desc);
0076 
0077     const QStringList& examples() {
0078         return m_examples;
0079     }
0080     const QStringList& syntax() {
0081         return m_syntax;
0082     }
0083     const QStringList& related() {
0084         return m_related;
0085     }
0086     const QStringList& helpText() const {
0087         return m_help;
0088     }
0089     QString name() const {
0090         return m_name;
0091     }
0092     ParameterType type() const {
0093         return m_type;
0094     }
0095 
0096     int params() const {
0097         return m_params.count();
0098     }
0099     FunctionParameter& param(int i) {
0100         return m_params[ i ];
0101     }
0102 
0103     void setGroup(const QString& g) {
0104         m_group = g;
0105     }
0106     QString group() const {
0107         return m_group;
0108     }
0109 
0110     QString toQML() const;
0111 
0112 private:
0113     QString m_group;
0114     QStringList m_examples;
0115     QStringList m_syntax;
0116     QStringList m_related;
0117     QStringList m_help;
0118     QString m_name;
0119     ParameterType m_type;
0120     QList<FunctionParameter> m_params;
0121 };
0122 
0123 } // namespace Sheets
0124 } // namespace Calligra
0125 
0126 #endif // CALLIGRA_SHEETS_FUNCTION_DESCRIPTION