diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,7 +13,7 @@ set(kreportexample_SRCS main.cpp window.cpp DesignerWidget.cpp - KReportExampleData.cpp + KReportExampleDataSource.cpp ) add_executable(kreportexample ${kreportexample_SRCS}) target_link_libraries(kreportexample KF5::ConfigGui KReport KReportUtilsPrivate) diff --git a/examples/DesignerWidget.cpp b/examples/DesignerWidget.cpp --- a/examples/DesignerWidget.cpp +++ b/examples/DesignerWidget.cpp @@ -18,7 +18,7 @@ */ #include "DesignerWidget.h" -#include "KReportExampleData.h" +#include "KReportExampleDataSource.h" #include #include @@ -44,7 +44,7 @@ this, SLOT(slotDesignerPropertySetChanged())); connect(m_reportDesigner, SIGNAL(dirty()), this, SLOT(designDirty())); - m_reportDesigner->setReportData(new KReportExampleData); + m_reportDesigner->setDataSource(new KReportExampleDataSource); } ReportDesignerWidget::~ReportDesignerWidget() diff --git a/examples/KReportExampleData.h b/examples/KReportExampleDataSource.h rename from examples/KReportExampleData.h rename to examples/KReportExampleDataSource.h --- a/examples/KReportExampleData.h +++ b/examples/KReportExampleDataSource.h @@ -20,18 +20,18 @@ #ifndef KREPORTEXAMPLEDATA_H #define KREPORTEXAMPLEDATA_H -#include +#include #include #include #include -class KReportExampleData : public KReportData +class KReportExampleDataSource : public KReportDataSource { public: - KReportExampleData(); - ~KReportExampleData(); + KReportExampleDataSource(); + ~KReportExampleDataSource(); virtual QVariant value(const QString& field) const; - virtual QVariant value(unsigned int) const; + virtual QVariant value(int) const; virtual QStringList fieldNames() const; virtual QStringList fieldKeys() const; virtual int fieldNumber(const QString& field) const; @@ -46,6 +46,8 @@ virtual QStringList scriptList() const; virtual QString scriptCode(const QString &script) const; + + virtual QStringList dataSourceNames() const; private: struct Data diff --git a/examples/KReportExampleData.cpp b/examples/KReportExampleDataSource.cpp rename from examples/KReportExampleData.cpp rename to examples/KReportExampleDataSource.cpp --- a/examples/KReportExampleData.cpp +++ b/examples/KReportExampleDataSource.cpp @@ -17,10 +17,10 @@ Boston, MA 02110-1301, USA. */ -#include "KReportExampleData.h" +#include "KReportExampleDataSource.h" #include -KReportExampleData::KReportExampleData() +KReportExampleDataSource::KReportExampleDataSource() { QList temp {{ 0, "Adam Pigg", "Kexi", QObject::tr("United Kingdom"), "0123456789", 58.816, -3.1484, "1746287369", false }, {1, "Jaroslaw Staniek", "Kexi", QObject::tr("Poland"), "8472947462", 51.895182, 19.623270, "1234567890", true }, @@ -31,17 +31,17 @@ m_currentRecord = 0; } -KReportExampleData::~KReportExampleData() +KReportExampleDataSource::~KReportExampleDataSource() { } -QVariant KReportExampleData::value(const QString& field) const +QVariant KReportExampleDataSource::value(const QString& field) const { return value(fieldNumber(field)); } -QVariant KReportExampleData::value(unsigned int f) const +QVariant KReportExampleDataSource::value(int f) const { switch(f) { case 0: @@ -84,81 +84,81 @@ } } -QStringList KReportExampleData::fieldNames() const +QStringList KReportExampleDataSource::fieldNames() const { return m_fieldNames; } -QStringList KReportExampleData::fieldKeys() const +QStringList KReportExampleDataSource::fieldKeys() const { return fieldNames(); } -int KReportExampleData::fieldNumber(const QString& field) const +int KReportExampleDataSource::fieldNumber(const QString& field) const { return m_fieldNames.indexOf(field); } -qint64 KReportExampleData::recordCount() const +qint64 KReportExampleDataSource::recordCount() const { return m_testData.count(); } -qint64 KReportExampleData::at() const +qint64 KReportExampleDataSource::at() const { return m_currentRecord; } -bool KReportExampleData::moveLast() +bool KReportExampleDataSource::moveLast() { m_currentRecord = recordCount() - 1; return true; } -bool KReportExampleData::moveFirst() +bool KReportExampleDataSource::moveFirst() { m_currentRecord = 0; return true; } -bool KReportExampleData::movePrevious() +bool KReportExampleDataSource::movePrevious() { if (m_currentRecord > 0) { m_currentRecord--; return true; } return false; } -bool KReportExampleData::moveNext() +bool KReportExampleDataSource::moveNext() { if (m_currentRecord < recordCount() - 1) { m_currentRecord++; return true; } return false; } -bool KReportExampleData::close() +bool KReportExampleDataSource::close() { return true; } -bool KReportExampleData::open() +bool KReportExampleDataSource::open() { return true; } -QStringList KReportExampleData::scriptList() const +QStringList KReportExampleDataSource::scriptList() const { QStringList scripts; scripts << "example"; return scripts; } -QString KReportExampleData::scriptCode(const QString &script) const +QString KReportExampleDataSource::scriptCode(const QString &script) const { if (script != "example") return QString(); @@ -190,3 +190,8 @@ return scriptcode; } + +QStringList KReportExampleDataSource::dataSourceNames() const +{ + return QStringList(); +} diff --git a/examples/window.cpp b/examples/window.cpp --- a/examples/window.cpp +++ b/examples/window.cpp @@ -19,6 +19,7 @@ #include "window.h" #include "DesignerWidget.h" +#include "KReportExampleDataSource.h" #include #include @@ -121,7 +122,7 @@ return; } - preRenderer.setSourceData(new KReportExampleData()); + preRenderer.setSourceData(new KReportExampleDataSource()); preRenderer.setName("example_report"); if (preRenderer.generateDocument()) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ common/KReportPluginManager.cpp common/KReportJsonTrader_p.cpp common/KReportPluginMetaData.cpp - common/KReportData.cpp + common/KReportDataSource.cpp common/KReportUtils.cpp common/KReportPageSize.cpp common/KReportUnit.cpp @@ -44,7 +44,7 @@ renderer/KReportRendererBase.cpp renderer/KReportPage.cpp renderer/KReportView.cpp - renderer/KReportOneRecordData_p.cpp + renderer/KReportOneRecordDataSource_p.cpp wrtembed/KReportDetailGroupSectionDialog.cpp wrtembed/KReportDesignerItemBase.cpp @@ -254,7 +254,7 @@ RELATIVE common HEADER_NAMES KReportPageSize - KReportData + KReportDataSource KReportItemBase KReportItemLine KReportPluginMetaData diff --git a/src/common/KReportData.h b/src/common/KReportDataSource.h rename from src/common/KReportData.h rename to src/common/KReportDataSource.h --- a/src/common/KReportData.h +++ b/src/common/KReportDataSource.h @@ -25,12 +25,12 @@ /** @brief Abstraction of report data source */ -class KREPORT_EXPORT KReportData +class KREPORT_EXPORT KReportDataSource { public: - KReportData(); - virtual ~KReportData(); + KReportDataSource(); + virtual ~KReportDataSource(); //! Describes sorting for single field /*! By default the order is ascending. */ @@ -87,7 +87,7 @@ virtual QStringList fieldKeys() const; //! Return the value of the field at the given position for the current record - virtual QVariant value(unsigned int) const = 0; + virtual QVariant value(int pos) const = 0; //! Return the value of the field fir the given name for the current record virtual QVariant value(const QString &field) const = 0; @@ -103,8 +103,8 @@ //! Default impl does nothing virtual void setSorting(const QList &sorting); - //! Adds an expression to the data source - virtual void addExpression(const QString &field, const QVariant &value, char relation = '='); + //! Adds a condition to the data source + virtual void addCondition(const QString &field, const QVariant &value, const QString& relation = QLatin1String("=")); //! Utility Functions //! @todo These are probably eligable to be moved into a new class @@ -118,20 +118,22 @@ virtual QString scriptCode(const QString& script) const; #endif - //! Return a list of data sources possible for advanced controls - virtual QStringList dataSources() const; + //! Return a list of data source names available for this data source + //! Works after the source is opened + virtual QStringList dataSourceNames() const = 0; - //! Return a list of data source names possible for advanced controls. - //! Returns dataSources() by default - virtual QStringList dataSourceNames() const; + //! Return data source caption for specified @a dataSourceName + //! It is possibly translated. As such it is suitable for use in GUIs. + //! Default implementation just returns @a dataSourceName. + virtual QString dataSourceCaption(const QString &dataSourceName) const; //! Creates a new instance with data source. Default implementation returns @c nullptr. //! @a source is implementation-specific identifier. //! Owner of the returned pointer is the caller. - virtual KReportData* create(const QString &source) const Q_REQUIRED_RESULT; + virtual KReportDataSource* create(const QString &source) const Q_REQUIRED_RESULT; private: - Q_DISABLE_COPY(KReportData) + Q_DISABLE_COPY(KReportDataSource) class Private; Private * const d; }; diff --git a/src/common/KReportData.cpp b/src/common/KReportDataSource.cpp rename from src/common/KReportData.cpp rename to src/common/KReportDataSource.cpp --- a/src/common/KReportData.cpp +++ b/src/common/KReportDataSource.cpp @@ -15,12 +15,12 @@ * License along with this library. If not, see . */ -#include "KReportData.h" +#include "KReportDataSource.h" #include #define KReportDataSortedFieldPrivateArgs(o) std::tie(o.field, o.order) -class KReportData::SortedField::Private +class KReportDataSource::SortedField::Private { public: @@ -32,131 +32,131 @@ Qt::SortOrder order = Qt::AscendingOrder; }; -class KReportData::Private +class KReportDataSource::Private { public: bool dummy = true; }; //==========KReportData::SortedField========== -KReportData::SortedField::SortedField() +KReportDataSource::SortedField::SortedField() : d(new Private) { } -KReportData::SortedField::SortedField(const KReportData::SortedField& other) : d(new Private(*other.d)) +KReportDataSource::SortedField::SortedField(const KReportDataSource::SortedField& other) : d(new Private(*other.d)) { } -KReportData::SortedField::~SortedField() +KReportDataSource::SortedField::~SortedField() { delete d; } -KReportData::SortedField & KReportData::SortedField::operator=(const KReportData::SortedField& other) +KReportDataSource::SortedField & KReportDataSource::SortedField::operator=(const KReportDataSource::SortedField& other) { if (this != &other) { setField(other.field()); setOrder(other.order()); } return *this; } -bool KReportData::SortedField::operator==(const KReportData::SortedField& other) const +bool KReportDataSource::SortedField::operator==(const KReportDataSource::SortedField& other) const { return KReportDataSortedFieldPrivateArgs((*d)) == KReportDataSortedFieldPrivateArgs((*other.d)); } -bool KReportData::SortedField::operator!=(const KReportData::SortedField& other) const +bool KReportDataSource::SortedField::operator!=(const KReportDataSource::SortedField& other) const { return KReportDataSortedFieldPrivateArgs((*d)) != KReportDataSortedFieldPrivateArgs((*other.d)); } -QString KReportData::SortedField::field() const +QString KReportDataSource::SortedField::field() const { return d->field; } -Qt::SortOrder KReportData::SortedField::order() const +Qt::SortOrder KReportDataSource::SortedField::order() const { return d->order; } -void KReportData::SortedField::setField(const QString& field) +void KReportDataSource::SortedField::setField(const QString& field) { d->field = field; } -void KReportData::SortedField::setOrder(Qt::SortOrder order) +void KReportDataSource::SortedField::setOrder(Qt::SortOrder order) { d->order = order; } //==========KReportData========== -KReportData::KReportData() : d(new Private()) +KReportDataSource::KReportDataSource() : d(new Private()) { } -KReportData::~KReportData() +KReportDataSource::~KReportDataSource() { delete d; } -QStringList KReportData::fieldKeys() const +QStringList KReportDataSource::fieldKeys() const { return fieldNames(); } -QString KReportData::sourceName() const +QString KReportDataSource::sourceName() const { return QString(); } -QString KReportData::sourceClass() const +QString KReportDataSource::sourceClass() const { return QString(); } -void KReportData::setSorting(const QList &sorting) +void KReportDataSource::setSorting(const QList &sorting) { Q_UNUSED(sorting); } -void KReportData::addExpression(const QString &field, const QVariant &value, char relation) +void KReportDataSource::addCondition(const QString &field, const QVariant &value, const QString& relation) { Q_UNUSED(field); Q_UNUSED(value); Q_UNUSED(relation); } #ifdef KREPORT_SCRIPTING -QStringList KReportData::scriptList() const +QStringList KReportDataSource::scriptList() const { return QStringList(); } -QString KReportData::scriptCode(const QString &script) const +QString KReportDataSource::scriptCode(const QString &script) const { Q_UNUSED(script); return QString(); } #endif -QStringList KReportData::dataSources() const +QStringList KReportDataSource::dataSourceNames() const { return QStringList(); } -QStringList KReportData::dataSourceNames() const +QString KReportDataSource::dataSourceCaption(const QString &dataSourceName) const { - return dataSources(); + return dataSourceName; } -KReportData* KReportData::create(const QString &source) const +KReportDataSource* KReportDataSource::create(const QString &source) const { Q_UNUSED(source); return 0; diff --git a/src/common/KReportDetailSectionData.h b/src/common/KReportDetailSectionData.h --- a/src/common/KReportDetailSectionData.h +++ b/src/common/KReportDetailSectionData.h @@ -21,7 +21,7 @@ #include -#include "KReportData.h" +#include "KReportDataSource.h" class KReportSectionData; class KReportDetailGroupSectionData; @@ -46,7 +46,7 @@ QString m_name; int m_pageBreak; - QList m_sortedFields; + QList m_sortedFields; KReportSectionData * m_detailSection; diff --git a/src/common/KReportDetailSectionData.cpp b/src/common/KReportDetailSectionData.cpp --- a/src/common/KReportDetailSectionData.cpp +++ b/src/common/KReportDetailSectionData.cpp @@ -90,7 +90,7 @@ } } m_groupList.append(dgsd); - KReportData::SortedField s; + KReportDataSource::SortedField s; s.setField(dgsd->m_column); s.setOrder(dgsd->m_sort); m_sortedFields.append(s); diff --git a/src/common/KReportItemBase.h b/src/common/KReportItemBase.h --- a/src/common/KReportItemBase.h +++ b/src/common/KReportItemBase.h @@ -29,7 +29,7 @@ class OROPage; class OROSection; class KReportSize; -class KReportData; +class KReportDataSource; class KReportLineStyle; #ifdef KREPORT_SCRIPTING @@ -90,7 +90,7 @@ @brief Render a complex item that uses a sub query as a data source @return the height required by the object */ - virtual int renderReportData(OROPage *page, OROSection *section, const QPointF &offset, KReportData *data, KReportScriptHandler *script); + virtual int renderReportData(OROPage *page, OROSection *section, const QPointF &offset, KReportDataSource *dataSource, KReportScriptHandler *script); /** @brief Override if the item supports a simple data source, such as a field diff --git a/src/common/KReportItemBase.cpp b/src/common/KReportItemBase.cpp --- a/src/common/KReportItemBase.cpp +++ b/src/common/KReportItemBase.cpp @@ -116,12 +116,12 @@ } int KReportItemBase::renderReportData(OROPage *page, OROSection *section, const QPointF &offset, - KReportData *data, KReportScriptHandler* script) + KReportDataSource *dataSource, KReportScriptHandler* script) { Q_UNUSED(page) Q_UNUSED(section) Q_UNUSED(offset) - Q_UNUSED(data) + Q_UNUSED(dataSource) Q_UNUSED(script) return 0; } diff --git a/src/common/KReportRenderObjects.h b/src/common/KReportRenderObjects.h --- a/src/common/KReportRenderObjects.h +++ b/src/common/KReportRenderObjects.h @@ -29,7 +29,7 @@ #include #include -#include "KReportData.h" +#include "KReportDataSource.h" #include "KReportItemBase.h" #include "KReportSectionData.h" #include "KReportLineStyle.h" diff --git a/src/plugins/web/KReportItemWeb.h b/src/plugins/web/KReportItemWeb.h --- a/src/plugins/web/KReportItemWeb.h +++ b/src/plugins/web/KReportItemWeb.h @@ -21,8 +21,8 @@ #ifndef KREPORTITEMWEB_H #define KREPORTITEMWEB_H -#include "KReportAsyncItemBase.h" -#include "KReportData.h" +#include +#include #include #include diff --git a/src/renderer/KReportOneRecordData_p.h b/src/renderer/KReportOneRecordDataSource_p.h rename from src/renderer/KReportOneRecordData_p.h rename to src/renderer/KReportOneRecordDataSource_p.h --- a/src/renderer/KReportOneRecordData_p.h +++ b/src/renderer/KReportOneRecordDataSource_p.h @@ -22,25 +22,25 @@ #ifndef KREPORTONERECORDDATA_H #define KREPORTONERECORDDATA_H -#include +#include namespace KReportPrivate { /** - * @brief A Report Data provide which returns one record + * @brief A report data source which returns one record * * When no other data source is specified the pre-renderer * will create this as its data source. This will return * one record of data, and no fields. Useful for creating * a report with a static page of data, or a report page * generated from a script only. */ -class OneRecordData : public KReportData +class OneRecordDataSource : public KReportDataSource { public: - OneRecordData(); - ~OneRecordData(); + OneRecordDataSource(); + ~OneRecordDataSource(); virtual QVariant value(const QString& field) const; - virtual QVariant value(unsigned int fieldNum) const; + virtual QVariant value(int fieldNum) const; virtual QStringList fieldNames() const; virtual int fieldNumber(const QString& field) const; virtual qint64 recordCount() const; @@ -51,6 +51,7 @@ virtual bool moveNext(); virtual bool close(); virtual bool open(); + virtual QStringList dataSourceNames() const; }; } diff --git a/src/renderer/KReportOneRecordData_p.cpp b/src/renderer/KReportOneRecordDataSource_p.cpp rename from src/renderer/KReportOneRecordData_p.cpp rename to src/renderer/KReportOneRecordDataSource_p.cpp --- a/src/renderer/KReportOneRecordData_p.cpp +++ b/src/renderer/KReportOneRecordDataSource_p.cpp @@ -19,80 +19,85 @@ * */ -#include "KReportOneRecordData_p.h" +#include "KReportOneRecordDataSource_p.h" namespace KReportPrivate { -OneRecordData::OneRecordData() +OneRecordDataSource::OneRecordDataSource() { } -OneRecordData::~OneRecordData() +OneRecordDataSource::~OneRecordDataSource() { } -QVariant OneRecordData::value(const QString& field) const +QVariant OneRecordDataSource::value(const QString& field) const { Q_UNUSED(field); return QVariant(); } -QVariant OneRecordData::value(unsigned int fieldNum) const +QVariant OneRecordDataSource::value(int fieldNum) const { Q_UNUSED(fieldNum); return QVariant(); } -QStringList OneRecordData::fieldNames() const +QStringList OneRecordDataSource::fieldNames() const { return QStringList(); } -int OneRecordData::fieldNumber(const QString& field) const +int OneRecordDataSource::fieldNumber(const QString& field) const { Q_UNUSED(field); return 0; } -qint64 OneRecordData::recordCount() const +qint64 OneRecordDataSource::recordCount() const { return 1; } -qint64 OneRecordData::at() const +qint64 OneRecordDataSource::at() const { return 0; } -bool OneRecordData::moveLast() +bool OneRecordDataSource::moveLast() { return true; } -bool OneRecordData::moveFirst() +bool OneRecordDataSource::moveFirst() { return true; } -bool OneRecordData::movePrevious() +bool OneRecordDataSource::movePrevious() { return false; } -bool OneRecordData::moveNext() +bool OneRecordDataSource::moveNext() { return false; } -bool OneRecordData::close() +bool OneRecordDataSource::close() { return true; } -bool OneRecordData::open() +bool OneRecordDataSource::open() { return true; } -} \ No newline at end of file +QStringList OneRecordDataSource::dataSourceNames() const +{ + return QStringList(); +} + +} diff --git a/src/renderer/KReportPreRenderer.h b/src/renderer/KReportPreRenderer.h --- a/src/renderer/KReportPreRenderer.h +++ b/src/renderer/KReportPreRenderer.h @@ -31,7 +31,7 @@ #endif class KReportPreRendererPrivate; class ORODocument; -class KReportData; +class KReportDataSource; class KReportDocument; class QDomElement; @@ -49,7 +49,7 @@ virtual ~KReportPreRenderer(); //! Sets source data to @a data, takes ownership - void setSourceData(KReportData* data); + void setSourceData(KReportDataSource* dataSource); #ifdef KREPORT_SCRIPTING KReportScriptHandler *scriptHandler(); diff --git a/src/renderer/KReportPreRenderer.cpp b/src/renderer/KReportPreRenderer.cpp --- a/src/renderer/KReportPreRenderer.cpp +++ b/src/renderer/KReportPreRenderer.cpp @@ -19,10 +19,10 @@ #include "KReportPreRenderer.h" #include "KReportPreRenderer_p.h" #include "KReportAsyncItemManager_p.h" -#include "KReportOneRecordData_p.h" +#include "KReportOneRecordDataSource_p.h" #include "KReportRenderObjects.h" -#include "KReportData.h" +#include "KReportDataSource.h" #include "KReportItemBase.h" #include "KReportDocument.h" #include "KReportDetailSectionData.h" @@ -51,8 +51,8 @@ m_leftMargin = m_rightMargin = 0.0; m_pageCounter = 0; m_maxHeight = m_maxWidth = 0.0; - m_oneRecord = new KReportPrivate::OneRecordData(); - m_kodata = 0; + m_oneRecord = new KReportPrivate::OneRecordDataSource(); + m_dataSource = 0; #ifdef KREPORT_SCRIPTING m_scriptHandler = 0; #endif @@ -157,14 +157,14 @@ void KReportPreRendererPrivate::renderDetailSection(KReportDetailSectionData *detailData) { if (detailData->m_detailSection) { - if (m_kodata/* && !curs->eof()*/) { + if (m_dataSource/* && !curs->eof()*/) { QStringList keys; QStringList keyValues; QList shownGroups; KReportDetailGroupSectionData * grp = 0; - bool status = m_kodata->moveFirst(); - int recordCount = m_kodata->recordCount(); + bool status = m_dataSource->moveFirst(); + int recordCount = m_dataSource->recordCount(); //kreportDebug() << "Record Count:" << recordCount; @@ -176,7 +176,7 @@ shownGroups << i; keys.append(grp->m_column); if (!keys.last().isEmpty()) - keyValues.append(m_kodata->value(m_kodata->fieldNumber(keys.last())).toString()); + keyValues.append(m_dataSource->value(m_dataSource->fieldNumber(keys.last())).toString()); else keyValues.append(QString()); @@ -188,37 +188,37 @@ } while (status) { - const qint64 pos = m_kodata->at(); + const qint64 pos = m_dataSource->at(); //kreportDebug() << "At:" << l << "Y:" << m_yOffset << "Max Height:" << m_maxHeight; if ((renderSectionSize(*detailData->m_detailSection) + finishCurPageSize((pos + 1 == recordCount)) + m_bottomMargin + m_yOffset) >= m_maxHeight) { //kreportDebug() << "Next section is too big for this page"; if (pos > 0) { - m_kodata->movePrevious(); + m_dataSource->movePrevious(); createNewPage(); - m_kodata->moveNext(); + m_dataSource->moveNext(); } } renderSection(*(detailData->m_detailSection)); - if (m_kodata) - status = m_kodata->moveNext(); + if (m_dataSource) + status = m_dataSource->moveNext(); if (status == true && keys.count() > 0) { // check to see where it is we need to start int pos = -1; // if it's still -1 by the time we are done then no keyValues changed for (int i = 0; i < keys.count(); ++i) { - if (keyValues[i] != m_kodata->value(m_kodata->fieldNumber(keys[i])).toString()) { + if (keyValues[i] != m_dataSource->value(m_dataSource->fieldNumber(keys[i])).toString()) { pos = i; break; } } // don't bother if nothing has changed if (pos != -1) { // roll back the query and go ahead if all is good - status = m_kodata->movePrevious(); + status = m_dataSource->movePrevious(); if (status == true) { // print the footers as needed // any changes made in this for loop need to be duplicated @@ -241,22 +241,22 @@ } // step ahead to where we should be and print the needed headers // if all is good - status = m_kodata->moveNext(); + status = m_dataSource->moveNext(); if (do_break) createNewPage(); if (status == true) { for (int i = 0; i < shownGroups.count(); ++i) { grp = detailData->m_groupList[shownGroups.at(i)]; if (grp->m_groupHeader) { if (renderSectionSize(*(grp->m_groupHeader)) + finishCurPageSize() + m_bottomMargin + m_yOffset >= m_maxHeight) { - m_kodata->movePrevious(); + m_dataSource->movePrevious(); createNewPage(); - m_kodata->moveNext(); + m_dataSource->moveNext(); } if (!keys[i].isEmpty()) - keyValues[i] = m_kodata->value(m_kodata->fieldNumber(keys[i])).toString(); + keyValues[i] = m_dataSource->value(m_dataSource->fieldNumber(keys[i])).toString(); //Tell interested parties thak key values changed renderSection(*(grp->m_groupHeader)); @@ -270,7 +270,7 @@ } } - if (keys.size() > 0 && m_kodata->movePrevious()) { + if (keys.size() > 0 && m_dataSource->movePrevious()) { // finish footers // duplicated changes from above here for (int i = shownGroups.count() - 1; i >= 0; i--) { @@ -302,7 +302,7 @@ QList objects = sectionData.objects(); foreach(KReportItemBase *ob, objects) { QPointF offset(m_leftMargin, m_yOffset); - QVariant itemData = m_kodata->value(ob->itemDataSource()); + QVariant itemData = m_dataSource->value(ob->itemDataSource()); //ASync objects cannot alter the section height KReportAsyncItemBase *async_ob = qobject_cast(ob); @@ -347,10 +347,10 @@ QList objects = sectionData.objects(); foreach(KReportItemBase *ob, objects) { QPointF offset(m_leftMargin, m_yOffset); - QVariant itemData = m_kodata->value(ob->itemDataSource()); + QVariant itemData = m_dataSource->value(ob->itemDataSource()); if (ob->supportsSubQuery()) { - itemHeight = ob->renderReportData(m_page, sec, offset, m_kodata, m_scriptHandler); + itemHeight = ob->renderReportData(m_page, sec, offset, m_dataSource, m_scriptHandler); } else { KReportAsyncItemBase *async_ob = qobject_cast(ob); if (async_ob){ @@ -383,7 +383,7 @@ void KReportPreRendererPrivate::initEngine() { delete m_scriptHandler; - m_scriptHandler = new KReportScriptHandler(m_kodata, m_reportDocument); + m_scriptHandler = new KReportScriptHandler(m_dataSource, m_reportDocument); connect(this, SIGNAL(enteredGroup(QString,QVariant)), m_scriptHandler, SLOT(slotEnteredGroup(QString,QVariant))); @@ -402,8 +402,8 @@ bool KReportPreRendererPrivate::generateDocument() { - if (!m_kodata) { - m_kodata = m_oneRecord; + if (!m_dataSource) { + m_dataSource = m_oneRecord; } if (!m_valid || !m_reportDocument) { @@ -475,8 +475,8 @@ //kreportDebug() << "Page Size:" << m_maxWidth << m_maxHeight; m_document->setPageLayout(m_reportDocument->pageLayout()); - m_kodata->setSorting(m_reportDocument->m_detailSection->m_sortedFields); - if (!m_kodata->open()) { + m_dataSource->setSorting(m_reportDocument->m_detailSection->m_sortedFields); + if (!m_dataSource->open()) { return false; } @@ -529,7 +529,7 @@ KReportDetailSectionData * detailData = m_reportDocument->m_detailSection; if (detailData->m_detailSection) { - KReportData *mydata = m_kodata; + KReportDataSource *mydata = m_dataSource; if (mydata && mydata->recordCount() > 0) { /* && !((query = orqThis->getQuery())->eof()))*/ if (!mydata->moveFirst()) { @@ -598,17 +598,17 @@ m_scriptHandler->displayErrors(); #endif - if (!m_kodata->close()) { + if (!m_dataSource->close()) { return false; } #ifdef KREPORT_SCRIPTING delete m_scriptHandler; m_scriptHandler = 0; #endif - if (m_kodata != m_oneRecord) { - delete m_kodata; - m_kodata = 0; + if (m_dataSource != m_oneRecord) { + delete m_dataSource; + m_dataSource = 0; } m_postProcText.clear(); @@ -655,11 +655,11 @@ return d->m_document; } -void KReportPreRenderer::setSourceData(KReportData *data) +void KReportPreRenderer::setSourceData(KReportDataSource *dataSource) { - if (d && data != d->m_kodata) { - delete d->m_kodata; - d->m_kodata = data; + if (d && dataSource != d->m_dataSource) { + delete d->m_dataSource; + d->m_dataSource = dataSource; } } diff --git a/src/renderer/KReportPreRenderer_p.h b/src/renderer/KReportPreRenderer_p.h --- a/src/renderer/KReportPreRenderer_p.h +++ b/src/renderer/KReportPreRenderer_p.h @@ -28,7 +28,7 @@ #include namespace KReportPrivate{ - class OneRecordData; + class OneRecordDataSource; } class KReportPreRenderer; @@ -59,8 +59,8 @@ qreal m_maxWidth; // -- same as above -- int m_pageCounter; // what page are we currently on? - KReportData* m_kodata; - KReportPrivate::OneRecordData *m_oneRecord; + KReportDataSource* m_dataSource; + KReportPrivate::OneRecordDataSource *m_oneRecord; QList m_postProcText; diff --git a/src/renderer/scripting/KReportScriptHandler.h b/src/renderer/scripting/KReportScriptHandler.h --- a/src/renderer/scripting/KReportScriptHandler.h +++ b/src/renderer/scripting/KReportScriptHandler.h @@ -23,7 +23,7 @@ #ifdef KREPORT_SCRIPTING #include "KReportScriptConstants.h" -#include "KReportData.h" +#include "KReportDataSource.h" #include class KReportScriptDebug; @@ -43,7 +43,7 @@ { Q_OBJECT public: - KReportScriptHandler(const KReportData *, KReportDocument*); + KReportScriptHandler(const KReportDataSource *reportDataSource, KReportDocument* reportDocument); ~KReportScriptHandler(); QVariant evaluate(const QString&); diff --git a/src/renderer/scripting/KReportScriptHandler.cpp b/src/renderer/scripting/KReportScriptHandler.cpp --- a/src/renderer/scripting/KReportScriptHandler.cpp +++ b/src/renderer/scripting/KReportScriptHandler.cpp @@ -43,7 +43,7 @@ KReportScriptDebug *debug; KReportScriptDraw *draw; Scripting::Report *report; - const KReportData *reportData; + const KReportDataSource *reportDataSource; QString source; KReportDocument *reportDocument; QJSEngine engine; @@ -60,10 +60,10 @@ { } -KReportScriptHandler::KReportScriptHandler(const KReportData* kodata, KReportDocument* doc) : d(new Private()) +KReportScriptHandler::KReportScriptHandler(const KReportDataSource* reportDataSource, KReportDocument* reportDocument) : d(new Private()) { - d->reportDocument = doc; - d->reportData = kodata; + d->reportDocument = reportDocument; + d->reportDataSource = reportDataSource; //Add a general report object d->report = new Scripting::Report(d->reportDocument); @@ -91,7 +91,7 @@ bool KReportScriptHandler::trigger() { - QString code = d->reportData->scriptCode(d->reportDocument->script()); + QString code = d->reportDataSource->scriptCode(d->reportDocument->script()); //kreportDebug() << code; if (code.isEmpty()) { diff --git a/src/wrtembed/KReportDesigner.h b/src/wrtembed/KReportDesigner.h --- a/src/wrtembed/KReportDesigner.h +++ b/src/wrtembed/KReportDesigner.h @@ -22,7 +22,7 @@ #include #include "KReportDocument.h" -#include "KReportData.h" +#include "KReportDataSource.h" class KProperty; class KPropertySet; @@ -72,15 +72,15 @@ @brief Sets the report data The report data interface contains functions to retrieve data and information about the fields. - @param kodata Pointer to KReportData instance, ownership is transferred + @param kodata Pointer to KReportDataSource instance, ownership is transferred */ - void setReportData(KReportData* kodata); + void setDataSource(KReportDataSource* source); /** @brief Return a pointer to the reports data @return Pointer to report data */ - KReportData *reportData() const; + KReportDataSource *reportDataSource() const; /** @brief Return a pointer to the section specified diff --git a/src/wrtembed/KReportDesigner.cpp b/src/wrtembed/KReportDesigner.cpp --- a/src/wrtembed/KReportDesigner.cpp +++ b/src/wrtembed/KReportDesigner.cpp @@ -113,7 +113,7 @@ delete zoom; delete sectionData; delete set; - delete kordata; + delete dataSource; } QGridLayout *grid; @@ -182,7 +182,7 @@ QString originalInterpreter; //Value of the script interpreter at load time QString originalScript; //Value of the script at load time - KReportData *kordata = nullptr; + KReportDataSource *dataSource = nullptr; }; KReportDesigner::KReportDesigner(QWidget * parent) @@ -441,14 +441,14 @@ (void)se.exec(); } -void KReportDesigner::setReportData(KReportData* kodata) +void KReportDesigner::setDataSource(KReportDataSource* source) { - if (d->kordata == kodata) { + if (d->dataSource == source) { return; } - delete d->kordata; + delete d->dataSource; - d->kordata = kodata; + d->dataSource = source; slotPageButton_Pressed(); setModified(true); emit reportDataChanged(); @@ -648,9 +648,9 @@ return d->itmset; } -KReportData *KReportDesigner::reportData() const +KReportDataSource *KReportDesigner::reportDataSource() const { - return d->kordata; + return d->dataSource; } KReportDesignerSectionDetail * KReportDesigner::detailSection() const @@ -681,18 +681,18 @@ { QStringList qs; qs << QString(); - if (d->kordata) - qs << d->kordata->fieldNames(); + if (d->dataSource) + qs << d->dataSource->fieldNames(); return qs; } QStringList KReportDesigner::fieldKeys() const { QStringList qs; qs << QString(); - if (d->kordata) - qs << d->kordata->fieldKeys(); + if (d->dataSource) + qs << d->dataSource->fieldKeys(); return qs; } @@ -792,8 +792,8 @@ void KReportDesigner::slotPageButton_Pressed() { #ifdef KREPORT_SCRIPTING - if (d->kordata) { - QStringList sl = d->kordata->scriptList(); + if (d->dataSource) { + QStringList sl = d->dataSource->scriptList(); sl.prepend(QLatin1String("")); d->script->setListData(sl, sl); }