ACF $AcfVersion:0$
IDocumentManager.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
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
18namespace ibase
19{
20 class IProgressManager;
21}
22
23
24namespace idoc
25{
26
27
85 virtual public istd::IChangeable,
86 virtual public IDocumentTypesInfo
87{
88public:
116
121 {
122 QString filePath;
123 QByteArray documentTypeId;
124 bool isDirty;
125 };
126
132 {
133 OF_FILE_NEW = 0x0001,
134 OF_FILE_OPEN = 0x0002,
135 OF_FILE_SAVE = 0x0004,
137 OF_KNOWN_PATH = 0x0010
138 };
139
144 typedef QMap<QString, QByteArray> FileToTypeMap;
145
163 virtual int GetAllowedOperationFlags(const istd::IPolymorphic* viewPtr = NULL) const = 0;
164
181 virtual idoc::IUndoManager* GetUndoManagerForDocument(const istd::IChangeable* documentPtr) const = 0;
182
187 virtual int GetDocumentsCount() const = 0;
188
204 virtual istd::IChangeable& GetDocumentFromIndex(int index, DocumentInfo* documentInfoPtr = NULL) const = 0;
205
209 virtual int GetViewsCount(int documentIndex) const = 0;
210
214 virtual istd::IPolymorphic* GetViewFromIndex(int documentIndex, int viewIndex) const = 0;
215
220 virtual istd::IPolymorphic* GetActiveView() const = 0;
221
225 virtual void SetActiveView(istd::IPolymorphic* viewPtr) = 0;
226
233 virtual istd::IChangeable* GetDocumentFromView(const istd::IPolymorphic& view, DocumentInfo* documentInfoPtr = NULL) const = 0;
234
241 virtual istd::IPolymorphic* AddViewToDocument(const istd::IChangeable& document, const QByteArray& viewTypeId = QByteArray()) = 0;
242
247 virtual QByteArray GetDocumentTypeId(const istd::IChangeable& document) const = 0;
248
259 virtual bool InsertNewDocument(
260 const QByteArray& documentTypeId,
261 bool createView = true,
262 const QByteArray& viewTypeId = "",
263 istd::IChangeableSharedPtr* newDocumentPtr = nullptr,
264 bool beQuiet = false,
265 bool* ignoredPtr = NULL) = 0;
266
277 virtual bool OpenDocument(
278 const QByteArray* documentTypeIdPtr = NULL,
279 const QString* fileNamePtr = NULL,
280 bool createView = true,
281 const QByteArray& viewTypeId = "",
282 istd::IChangeableSharedPtr* documentPtr = nullptr,
283 FileToTypeMap* loadedMapPtr = NULL,
284 bool beQuiet = false,
285 bool* ignoredPtr = NULL,
286 ibase::IProgressManager* progressManagerPtr = NULL) = 0;
287
296 virtual bool SaveDocument(
297 int documentIndex = -1,
298 bool requestFileName = false,
299 FileToTypeMap* savedMapPtr = NULL,
300 bool beQuiet = false,
301 bool* ignoredPtr = NULL,
302 ibase::IProgressManager* progressManagerPtr = NULL) = 0;
303
311 virtual bool SaveDirtyDocuments(bool beQuiet = false, bool* ignoredPtr = NULL) = 0;
312
320 virtual bool CloseDocument(int documentIndex = -1, bool beQuiet = false, bool* ignoredPtr = NULL) = 0;
321
329 virtual bool CloseView(istd::IPolymorphic* viewPtr = NULL, bool beQuiet = false, bool* ignoredPtr = NULL) = 0;
330};
331
332
333} // namespace idoc
334
335
Consume information about progress of some process.
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept.
virtual idoc::IUndoManager * GetUndoManagerForDocument(const istd::IChangeable *documentPtr) const =0
Return undo manager for document documentPtr.
ChangeFlags
Possible changes in the manager data model.
@ CF_DOCUMENT_RENAMED
A document has been renamed or its file path has changed.
@ CF_VIEW_ACTIVATION_CHANGED
The active view has changed to a different view.
@ CF_DOCUMENT_COUNT_CHANGED
The total number of managed documents has changed.
@ CF_DOCUMENT_CREATED
A new document has been created.
@ CF_DOCUMENT_REMOVED
A document has been removed from the manager.
virtual bool CloseView(istd::IPolymorphic *viewPtr=NULL, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Close view.
virtual bool SaveDocument(int documentIndex=-1, bool requestFileName=false, FileToTypeMap *savedMapPtr=NULL, bool beQuiet=false, bool *ignoredPtr=NULL, ibase::IProgressManager *progressManagerPtr=NULL)=0
Save document.
virtual void SetActiveView(istd::IPolymorphic *viewPtr)=0
Indicate that some view is active now.
virtual bool OpenDocument(const QByteArray *documentTypeIdPtr=NULL, const QString *fileNamePtr=NULL, bool createView=true, const QByteArray &viewTypeId="", istd::IChangeableSharedPtr *documentPtr=nullptr, FileToTypeMap *loadedMapPtr=NULL, bool beQuiet=false, bool *ignoredPtr=NULL, ibase::IProgressManager *progressManagerPtr=NULL)=0
Opens document(s) from the file list.
virtual istd::IChangeable & GetDocumentFromIndex(int index, DocumentInfo *documentInfoPtr=NULL) const =0
Get document at specified index.
virtual istd::IPolymorphic * GetViewFromIndex(int documentIndex, int viewIndex) const =0
Get single view using its and document indices.
virtual int GetViewsCount(int documentIndex) const =0
Get number of view for specified document.
virtual int GetAllowedOperationFlags(const istd::IPolymorphic *viewPtr=NULL) const =0
Get flags of allowed operations.
virtual bool CloseDocument(int documentIndex=-1, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Close document and all its views.
OperationFlags
Flags describing possible operations that can be performed by the document manager.
@ OF_FILE_NEW
New document creation is supported.
@ OF_KNOWN_PATH
Document has a known file path.
@ OF_FILE_SAVE
Saving documents is supported.
@ OF_FILE_OPEN
Opening existing documents is supported.
@ OF_FILE_SAVE_AS
Save As operation is supported.
virtual bool InsertNewDocument(const QByteArray &documentTypeId, bool createView=true, const QByteArray &viewTypeId="", istd::IChangeableSharedPtr *newDocumentPtr=nullptr, bool beQuiet=false, bool *ignoredPtr=NULL)=0
Creates a new document with the document ID documentTypeId.
virtual QByteArray GetDocumentTypeId(const istd::IChangeable &document) const =0
Get ID of document type managed by this object.
virtual istd::IChangeable * GetDocumentFromView(const istd::IPolymorphic &view, DocumentInfo *documentInfoPtr=NULL) const =0
Return the document assigned to view.
QMap< QString, QByteArray > FileToTypeMap
Map from file path to document type ID's.
virtual bool SaveDirtyDocuments(bool beQuiet=false, bool *ignoredPtr=NULL)=0
Ask user (optional) and save all dirty (changed) documents.
virtual istd::IPolymorphic * AddViewToDocument(const istd::IChangeable &document, const QByteArray &viewTypeId=QByteArray())=0
Add a new view to the document.
virtual int GetDocumentsCount() const =0
Get number of opened documents.
virtual istd::IPolymorphic * GetActiveView() const =0
Return the active document.
Provide information about different document types.
Interface providing UNDO/REDO functionality.
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
Base interface for all used interfaces and implementations.
#define NULL
Definition istd.h:74
This namespace contains basic implementations of standard primitives on the component level.
Contains the system independent basic implementations of Document/View design pattern.
Information about a document managed by the document manager.
QByteArray documentTypeId
Type identifier of the document.
bool isDirty
True if document has unsaved changes.
QString filePath
Full file path of the document, empty if not saved yet.