MyBooks
storageinterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  * This file is part of the CuteReport project *
3  * Copyright (C) 2012-2017 by Alexander Mikhalov *
4  * alexander.mikhalov@gmail.com *
5  * *
6  ** GNU General Public License Usage **
7  * *
8  * This library is free software: you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation, either version 3 of the License, or *
11  * (at your option) any later version. *
12  * You should have received a copy of the GNU General Public License *
13  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
14  * *
15  ** GNU Lesser General Public License **
16  * *
17  * This library is free software: you can redistribute it and/or modify *
18  * it under the terms of the GNU Lesser General Public License as *
19  * published by the Free Software Foundation, either version 3 of the *
20  * License, or (at your option) any later version. *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library. *
23  * If not, see <http://www.gnu.org/licenses/>. *
24  * *
25  * This library is distributed in the hope that it will be useful, *
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
28  * GNU General Public License for more details. *
29  ****************************************************************************/
30 #ifndef STORAGEINTERFACE_H
31 #define STORAGEINTERFACE_H
32 
33 #include "reportcore.h"
34 #include "reportplugininterface.h"
35 #include "cutereport_globals.h"
36 #include "cutereport_types.h"
37 #include <QString>
38 #include <QWidget>
39 
48 namespace CuteDesigner {
49 class Core;
50 }
51 
52 namespace CuteReport
53 {
54 class StorageHelperInterface;
55 
57 {
58  Q_OBJECT
60 
61 public:
62  explicit StorageInterface(QObject * parent):ReportPluginInterface(parent) {}
63  virtual ~StorageInterface(){}
64 
65  virtual StorageInterface * clone() = 0;
66  virtual CuteReport::StorageHelperInterface * createHelper(CuteDesigner::Core * designer) {Q_UNUSED(designer); return 0;}
67 
68  virtual QString urlScheme() const = 0;
69 
70  virtual QString urlHint(const QString & key) {Q_UNUSED(key); return QString();}
71  virtual QStringList urlHints() {return QStringList();}
72 
73 
78  virtual CuteReport::StorageSyncStatus sync() {return CuteReport::StorageSyncSuccessful;} // if false, then storage cannot be synced correct;
79 
83  virtual CuteReport::StorageSyncStatus interruptSync() {return CuteReport::StorageSyncSuccessful;} // interrupts current syncing
84 
85  virtual QString localCachedFileName(const QString & url) = 0;
86  virtual QString normalizedURL(const QString & url) = 0;
87 
88  virtual bool saveObject(const QString & url, const QByteArray & objectData) = 0;
89  virtual QByteArray loadObject(const QString & url) = 0;
90 
92  virtual QList<StorageObjectInfo> objectsList(const QString & url, bool * ok = 0) = 0;
93  virtual QList<StorageObjectInfo> objectsList(const QString & url, const QStringList & nameFilters, QDir::Filters filters,
94  QDir::SortFlags sort, bool * ok = 0) = 0;
95 
96  virtual bool objectExists(const QString & url) = 0;
97 
98  virtual QString rootUrl() { return urlScheme() + ":";}
99 
100  // TODO
101  // async methods: return request id
102 // virtual qint32 reportsInfoListRequest() const = 0;
103 // virtual qint32 objectsInfoListRequest(CuteReport::ReportInterface * report, const QString & prefix) const= 0;
104 // virtual qint32 saveObject(const QString & url, const QVariant & objectData, CuteReport::ReportInterface * report) = 0;
105 // virtual qint32 loadObject(const QString & url, CuteReport::ReportInterface * report) = 0;
106 
107  virtual QString lastError() const = 0;
108 
109 signals:
110  void syncFinished(int syncStatus);
111  // TODO
112 // void reportsInfoListResult(StorageListResult result);
113 // void objectsInfoListResult(StorageListResult result);
114 // void progress(StorageProgress);
115 
116 protected:
117  virtual StorageInterface * createInstance(QObject * parent = 0) const = 0;
118  explicit StorageInterface(const StorageInterface & source, QObject * parent = 0)
119  :ReportPluginInterface(source, parent){}
120 
121  friend class ReportCore;
122 };
123 
124 
126 {
127  Q_OBJECT
128 public:
129  enum VisibleOptions{ReportsOptions, ObjectsOptions, AllOptions};
130  StorageHelperInterface(StorageInterface *, CuteDesigner::Core * designer, VisibleOptions = AllOptions)
131  :m_designer(designer){}
132  virtual void load() = 0;
133  virtual void save() = 0;
134 
135 protected:
136  CuteDesigner::Core * m_designer;
137 };
138 
139 }
140 
141 Q_DECLARE_INTERFACE(CuteReport::StorageInterface, "CuteReport.StorageInterface/1.0")
142 Q_DECLARE_INTERFACE(CuteReport::StorageHelperInterface, "CuteReport.StorageHelperInterface/1.0")
143 
144 
145 #endif // STORAGEINTERFACE_H
Definition: abstractpainterdelegate.h:42
virtual QStringList urlHints()
Definition: storageinterface.h:71
Definition: datasetinterface.h:43
VisibleOptions
Definition: storageinterface.h:129
StorageSyncStatus
Definition: cutereport_types.h:124
virtual CuteReport::StorageSyncStatus interruptSync()
Definition: storageinterface.h:83
virtual QString urlHint(const QString &key)
Definition: storageinterface.h:70
StorageInterface(const StorageInterface &source, QObject *parent=0)
Definition: storageinterface.h:118
Definition: reportplugininterface.h:53
StorageInterface(QObject *parent)
Definition: storageinterface.h:62
virtual ~StorageInterface()
Definition: storageinterface.h:63
virtual CuteReport::StorageSyncStatus sync()
Definition: storageinterface.h:78
virtual QString rootUrl()
Definition: storageinterface.h:98
#define CUTEREPORT_EXPORTS
Definition: cutereport_globals.h:47
Definition: cutereport_types.h:124
virtual CuteReport::StorageHelperInterface * createHelper(CuteDesigner::Core *designer)
Definition: storageinterface.h:66
StorageHelperInterface(StorageInterface *, CuteDesigner::Core *designer, VisibleOptions=AllOptions)
Definition: storageinterface.h:130
Definition: storageinterface.h:125
Definition: reportcore.h:83
CuteDesigner::Core * m_designer
Definition: storageinterface.h:136
Definition: storageinterface.h:56