IDocumentManager.h
Go to the documentation of this file.
1 #ifndef idoc_IDocumentManager_included
2 #define idoc_IDocumentManager_included
3 
4 
5 // Qt includes
6 #include <QtCore/QByteArray>
7 #include <QtCore/QMap>
8 
9 // Qt includes
10 #include <QtCore/QString>
11 
12 // ACF includes
13 #include <istd/IChangeable.h>
14 #include <idoc/IUndoManager.h>
16 
17 
18 namespace idoc
19 {
20 
21 
26  virtual public istd::IChangeable,
27  virtual public IDocumentTypesInfo
28 {
29 public:
34  {
35  CF_DOCUMENT_RENAMED = 0x834d670,
40  };
41 
42  struct DocumentInfo
43  {
44  QString filePath;
45  QByteArray documentTypeId;
46  bool isDirty;
47  };
48 
53  {
54  OF_FILE_NEW = 0x0001,
55  OF_FILE_OPEN = 0x0002,
56  OF_FILE_SAVE = 0x0004,
57  OF_FILE_SAVE_AS = 0x0008,
58  OF_KNOWN_PATH = 0x0010
59  };
60 
64  typedef QMap<QString, QByteArray> FileToTypeMap;
65 
69  virtual int GetAllowedOperationFlags(const istd::IPolymorphic* viewPtr = NULL) const = 0;
70 
74  virtual idoc::IUndoManager* GetUndoManagerForDocument(const istd::IChangeable* documentPtr) const = 0;
75 
79  virtual int GetDocumentsCount() const = 0;
80 
86  virtual istd::IChangeable& GetDocumentFromIndex(int index, DocumentInfo* documentInfoPtr = NULL) const = 0;
87 
91  virtual int GetViewsCount(int documentIndex) const = 0;
92 
96  virtual istd::IPolymorphic* GetViewFromIndex(int documentIndex, int viewIndex) const = 0;
97 
102  virtual istd::IPolymorphic* GetActiveView() const = 0;
103 
110  virtual istd::IChangeable* GetDocumentFromView(const istd::IPolymorphic& view, DocumentInfo* documentInfoPtr = NULL) const = 0;
111 
118  virtual istd::IPolymorphic* AddViewToDocument(const istd::IChangeable& document, const QByteArray& viewTypeId = QByteArray()) = 0;
119 
124  virtual QByteArray GetDocumentTypeId(const istd::IChangeable& document) const = 0;
125 
136  virtual bool InsertNewDocument(
137  const QByteArray& documentTypeId,
138  bool createView = true,
139  const QByteArray& viewTypeId = "",
140  istd::IChangeable** newDocumentPtr = NULL,
141  bool beQuiet = false,
142  bool* ignoredPtr = NULL) = 0;
143 
154  virtual bool OpenDocument(
155  const QByteArray* documentTypeIdPtr = NULL,
156  const QString* fileNamePtr = NULL,
157  bool createView = true,
158  const QByteArray& viewTypeId = "",
159  istd::IChangeable** documentPtr = NULL,
160  FileToTypeMap* loadedMapPtr = NULL,
161  bool beQuiet = false,
162  bool* ignoredPtr = NULL) = 0;
163 
172  virtual bool SaveDocument(
173  int documentIndex = -1,
174  bool requestFileName = false,
175  FileToTypeMap* savedMapPtr = NULL,
176  bool beQuiet = false,
177  bool* ignoredPtr = NULL) = 0;
178 
186  virtual bool SaveDirtyDocuments(bool beQuiet = false, bool* ignoredPtr = NULL) = 0;
187 
195  virtual bool CloseDocument(int documentIndex = -1, bool beQuiet = false, bool* ignoredPtr = NULL) = 0;
196 
204  virtual bool CloseView(istd::IPolymorphic* viewPtr = NULL, bool beQuiet = false, bool* ignoredPtr = NULL) = 0;
205 };
206 
207 
208 } // namespace idoc
209 
210 
211 #endif // !idoc_IDocumentManager_included
212 
213 
virtual bool SaveDocument(int documentIndex=-1, bool requestFileName=false, FileToTypeMap *savedMapPtr=NULL, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Save document.
virtual bool SaveDirtyDocuments(bool beQuiet=false, bool *ignoredPtr=NULL)=0
Ask user (optional) and save all dirty (changed) documents.
Provide information about different document types.
virtual QByteArray GetDocumentTypeId(const istd::IChangeable &document) const =0
Get ID of document type managed by this object.
virtual idoc::IUndoManager * GetUndoManagerForDocument(const istd::IChangeable *documentPtr) const =0
Return undo mananger for document documenPtr.
virtual bool CloseView(istd::IPolymorphic *viewPtr=NULL, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Close view.
virtual int GetDocumentsCount() const =0
Get number of opened documents.
virtual istd::IChangeable * GetDocumentFromView(const istd::IPolymorphic &view, DocumentInfo *documentInfoPtr=NULL) const =0
Return the document assigned to view.
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Base interface for all used interfaces and implementations.
Definition: IPolymorphic.h:17
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept...
virtual int GetAllowedOperationFlags(const istd::IPolymorphic *viewPtr=NULL) const =0
Get flags of allowed operations.
virtual int GetViewsCount(int documentIndex) const =0
Get number of view for specified document.
virtual istd::IPolymorphic * GetViewFromIndex(int documentIndex, int viewIndex) const =0
Get single view using its and document indices.
virtual bool OpenDocument(const QByteArray *documentTypeIdPtr=NULL, const QString *fileNamePtr=NULL, bool createView=true, const QByteArray &viewTypeId="", istd::IChangeable **documentPtr=NULL, FileToTypeMap *loadedMapPtr=NULL, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Opens document(s) from the file list.
virtual istd::IPolymorphic * AddViewToDocument(const istd::IChangeable &document, const QByteArray &viewTypeId=QByteArray())=0
Add a new view to the document.
ChangeFlags
Possible changes in the mananger data model.
#define NULL
Definition: istd.h:64
virtual istd::IPolymorphic * GetActiveView() const =0
Return the active document.
virtual bool InsertNewDocument(const QByteArray &documentTypeId, bool createView=true, const QByteArray &viewTypeId="", istd::IChangeable **newDocumentPtr=NULL, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Creates a new document with the document ID documentTypeId.
virtual bool CloseDocument(int documentIndex=-1, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Close document and all its views.
QMap< QString, QByteArray > FileToTypeMap
Map from file path to ducument type ID's.
Interface providing UNDO/REDO functionality.
Definition: IUndoManager.h:16
virtual istd::IChangeable & GetDocumentFromIndex(int index, DocumentInfo *documentInfoPtr=NULL) const =0
Get document at specified index.
OperationFlags
Flags describing possible operations.

© 2007-2017 Witold Gantzke and Kirill Lepskiy