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
Top level report document definition. A KReportDocment defines the design of a document, and is composed of multiple sections.
QString title() const
QObject * sectionByName(const QString &)
QString name() const
void eventOnComplete()
Executed when the report is complete. If a handler exists for this in the user object it is called...
QObject * objectByName(const QString &)
Report object user scripting API.
void initialize(const QJSValue &val)
Assigns a user object to this report.
Q_OBJECTQ_OBJECT
void eventOnOpen()
Executed when the report is opened. If a handler exists for this in the user object it is called...
QString recordSource() const
void eventOnNewPage()
Executed when a new page is created. If a handler exists for this in the user object it is called...
Q_SLOTSQ_SLOTS
Field item script interface.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 22:58:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.