File indexing completed on 2024-05-12 04:43:22

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef KRSCRIPTHANDLER_H
0019 #define KRSCRIPTHANDLER_H
0020 
0021 #include "kreport_export.h"
0022 #include "config-kreport.h"
0023 
0024 #ifdef KREPORT_SCRIPTING
0025 #include "KReportScriptConstants.h"
0026 #include "KReportDataSource.h"
0027 #include <QtQml/QJSValue>
0028 
0029 class KReportScriptDebug;
0030 class KReportScriptDraw;
0031 class KReportSectionData;
0032 class QJSEngine;
0033 class KReportDocument;
0034 class OROPage;
0035 class KReportScriptSource;
0036 
0037 namespace Scripting
0038 {
0039 class Report;
0040 class Section;
0041 }
0042 
0043 /*!
0044  * @brief Handles scripting during report rendering.
0045  *
0046  * The script handler loads scriptable objects, and executes
0047  * appropriate script code during report rendering
0048  */
0049 class KREPORT_EXPORT KReportScriptHandler : public QObject
0050 {
0051     Q_OBJECT
0052 public:
0053     KReportScriptHandler(const KReportDataSource *reportDataSource, KReportScriptSource *scriptSource, KReportDocument* reportDocument);
0054     ~KReportScriptHandler() override;
0055 
0056     QVariant evaluate(const QString&);
0057     void displayErrors();
0058     QJSValue registerScriptObject(QObject*, const QString&);
0059     bool trigger();
0060 
0061 public Q_SLOTS:
0062 
0063     void slotEnteredSection(KReportSectionData*, OROPage*, QPointF);
0064     void slotEnteredGroup(const QString&, const QVariant&);
0065     void slotExitedGroup(const QString&, const QVariant&);
0066     void setPageNumber(int p);
0067     void setPageTotal(int t);
0068     void newPage();
0069 
0070 Q_SIGNALS:
0071     void groupChanged(const QMap<QString, QVariant> &groupData);
0072 
0073 private:
0074     //! @todo KEXI3 QString where();
0075     Q_DISABLE_COPY(KReportScriptHandler)
0076     class Private;
0077     Private * const d;
0078 };
0079 
0080 #else // !KREPORT_SCRIPTING
0081 #define KReportScriptHandler void
0082 #endif
0083 
0084 #endif