KReport

KReportScriptReport.h
1 /* This file is part of the KDE project
2  * Copyright (C) 2007-2008 by Adam Pigg ([email protected])
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef SCRIPTINGKRSCRIPTREPORT_H
18 #define SCRIPTINGKRSCRIPTREPORT_H
19 
20 #include <QObject>
21 #include <QtQml/QJSValue>
22 #include <QMap>
23 
24 class KReportDocument;
25 
26 namespace Scripting
27 {
28 
29 
30 /**
31  @brief Report object user scripting API.
32 
33  Contains methods for a report object which can be called by user scripts. \n
34 
35  Example: \n
36  \code
37  function report()
38  {
39  this.OnOpen = function()
40  {
41  debug.print("Report opened!");
42  }
43  }
44  reportname.initialize(new report())
45  \endcode
46 */
47 class Report : public QObject
48 {
49  Q_OBJECT
50 public:
51  explicit Report(KReportDocument*);
52 
53  ~Report() override;
54 
55 public Q_SLOTS:
56  //! @return the title of the report as a string
57  QString title() const;
58 
59  //! @return the name of the report as a string
60  QString name() const;
61 
62  //! @return the record source (data source, table, query etc) as a string
63  QString recordSource() const;
64 
65  //! @return an object in the report given its name, or NULL
66  QObject* objectByName(const QString &);
67 
68  //! @return a section in the report given its name, or NULL
69  QObject* sectionByName(const QString &);
70 
71 
72  //! Assigns a user object to this report
73  void initialize(const QJSValue &val);
74 
75  //! Executed when the report is opened. If a handler exists for this in the user object it is called.
76  void eventOnOpen();
77 
78  //! Executed when the report is complete. If a handler exists for this in the user object it is called.
79  void eventOnComplete();
80 
81  //! Executed when a new page is created. If a handler exists for this in the user object it is called.
82  void eventOnNewPage();
83 
84 private:
85  KReportDocument *m_reportData;
86  QJSValue m_scriptObject;
87  QMap<QString, QObject*> m_scriptObjMap;
88 };
89 
90 }
91 
92 #endif
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * sectionByName(const QString &)
void eventOnComplete()
Executed when the report is complete. If a handler exists for this in the user object it is called.
void eventOnOpen()
Executed when the report is opened. If a handler exists for this in the user object it is called.
QObject * objectByName(const QString &)
void initialize(const QJSValue &val)
Assigns a user object to this report.
QString recordSource() const
Field item script interface.
void eventOnNewPage()
Executed when a new page is created. If a handler exists for this in the user object it is called.
Report object user scripting API.
Top level report document definition. A KReportDocment defines the design of a document,...
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 22 2023 04:10:43 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.