| 1 |
/* This file is part of the KDE project |
| 2 |
SPDX-FileCopyrightText: 2017 Dag Andersen <[email protected]> |
| 3 |
|
| 4 |
SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef REPORTGENERATOR_H |
| 8 |
#define REPORTGENERATOR_H |
| 9 |
|
| 10 |
#include "planmodels_export.h" |
| 11 |
|
| 12 |
#include <QModelIndexList> |
| 13 |
|
| 14 |
#include <KoXmlReaderForward.h> |
| 15 |
|
| 16 |
#include <QDomDocument> |
| 17 |
#include <QSortFilterProxyModel> |
| 18 |
|
| 19 |
class QIODevice; |
| 20 |
class QString; |
| 21 |
|
| 22 |
class KoXmlWriter; |
| 23 |
class KoStore; |
| 24 |
class KoOdfWriteStore; |
| 25 |
class KoOdfReadStore; |
| 26 |
|
| 27 |
#define HeaderRole Qt::UserRole + 543 |
| 28 |
|
| 29 |
namespace KPlato |
| 30 |
{ |
| 31 |
|
| 32 |
class Project; |
| 33 |
class ScheduleManager; |
| 34 |
class ItemModelBase; |
| 35 |
class ChartItemModel; |
| 36 |
|
| 37 |
class PLANMODELS_EXPORT ReportGenerator |
| 38 |
{ |
| 39 |
public: |
| 40 |
explicit ReportGenerator(); |
| 41 |
virtual ~ReportGenerator(); |
| 42 |
|
| 43 |
void setReportType(const QString &type); |
| 44 |
|
| 45 |
void setTemplateFile(const QString &file); |
| 46 |
void setReportFile(const QString &file); |
| 47 |
void setProject(Project *project); |
| 48 |
void setScheduleManager(ScheduleManager *manager); |
| 49 |
|
| 50 |
bool initiate(); |
| 51 |
virtual bool createReport() = 0; |
| 52 |
|
| 53 |
QString lastError() const; |
| 54 |
|
| 55 |
protected: |
| 56 |
/// Re-implement this to initiate your report generator |
| 57 |
virtual bool initiateInternal(); |
| 58 |
|
| 59 |
QAbstractItemModel *projectsModel(ItemModelBase *base) const; |
| 60 |
void addDataModel(const QString &name, QAbstractItemModel *model, int role); |
| 61 |
|
| 62 |
static ChartItemModel *findChartItemModel(QSortFilterProxyModel &model); |
| 63 |
static bool startsWith(const QStringList &keys, const QString &key); |
| 64 |
static QStringList trimmed(const QStringList &lst); |
| 65 |
|
| 66 |
protected: |
| 67 |
QString m_lastError; |
| 68 |
QString m_reportType; |
| 69 |
QString m_templateFile; |
| 70 |
QString m_reportFile; |
| 71 |
Project *m_project; |
| 72 |
ScheduleManager *m_manager; |
| 73 |
|
| 74 |
ReportGenerator *m_reportGenerator; |
| 75 |
|
| 76 |
QStringList m_keys; |
| 77 |
QStringList m_variables; |
| 78 |
|
| 79 |
QMap<QString, QAbstractItemModel*> m_datamodels; |
| 80 |
QMap<QString, int> m_headerrole; |
| 81 |
QList<ItemModelBase*> m_basemodels; |
| 82 |
|
| 83 |
}; |
| 84 |
|
| 85 |
} //namespace KPlato |
| 86 |
|
| 87 |
#endif // REPORTGENERATOR_H |