ICF 3.1.1.10
Technical documentation of ICF Libraries
CSingleDocumentManagerBase.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtCore/QByteArray>
11#include <QtCore/QString>
12
13// ICF includes
14#include <iser/IArchive.h>
17
18
19namespace idoc
20{
21
22
29{
30public:
32
33 // reimplemented (idoc::IDocumentManager)
35 virtual int GetDocumentsCount() const;
36 virtual istd::IChangeable& GetDocumentFromIndex(int index, DocumentInfo* documentInfoPtr = nullptr) const;
37 virtual int GetViewsCount(int documentIndex) const;
38 virtual istd::IPolymorphic* GetViewFromIndex(int documentIndex, int viewIndex) const;
39 virtual istd::IPolymorphic* GetActiveView() const;
40 virtual istd::IChangeable* GetDocumentFromView(const istd::IPolymorphic& view, DocumentInfo* documentInfoPtr = nullptr) const;
41 virtual istd::IPolymorphic* AddViewToDocument(const istd::IChangeable& document, const QByteArray& viewTypeId = QByteArray());
42 virtual QByteArray GetDocumentTypeId(const istd::IChangeable& document) const;
43 virtual bool InsertNewDocument(
44 const QByteArray& documentTypeId,
45 bool createView = true,
46 const QByteArray& viewTypeId = "",
47 istd::IChangeable** newDocumentPtr = nullptr,
48 bool beQuiet = false,
49 bool* ignoredPtr = nullptr);
50 virtual bool OpenDocument(
51 const QByteArray* documentTypeIdPtr,
52 const QString* fileNamePtr = nullptr,
53 bool createView = true,
54 const QByteArray& viewTypeId = "",
55 istd::IChangeable** documentPtr = nullptr,
56 FileToTypeMap* loadedMapPtr = nullptr,
57 bool beQuiet = false,
58 bool* ignoredPtr = nullptr,
59 iproc::IProgressManager* progressManagerPtr = nullptr);
60 virtual bool SaveDocument(
61 int documentIndex = -1,
62 bool requestFileName = false,
63 FileToTypeMap* savedMapPtr = nullptr,
64 bool beQuiet = false,
65 bool* ignoredPtr = nullptr,
66 iproc::IProgressManager* progressManagerPtr = nullptr);
67 virtual bool SaveDirtyDocuments(bool beQuiet = false, bool* ignoredPtr = nullptr);
68 virtual bool CloseDocument(int documentIndex = -1, bool beQuiet = false, bool* ignoredPtr = nullptr);
69 virtual bool CloseView(istd::IPolymorphic* viewPtr = nullptr, bool beQuiet = false, bool* ignoredPtr = nullptr);
70
71protected:
80 virtual bool OpenSingleDocument(
81 const QString& filePath,
82 bool createView,
83 const QByteArray& viewTypeId,
84 QByteArray& documentTypeId,
85 bool beQuiet,
86 bool* ignoredPtr,
87 iproc::IProgressManager* progressManagerPtr);
88
93 const QByteArray& documentTypeId,
94 bool createView,
95 const QByteArray& viewTypeId,
96 bool initialize,
97 bool beQuiet,
98 bool* ignoredPtr);
103
105
108
109 // reimplemented (imod::CSingleModelObserverBase)
110 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
111
112 // abstract methods
113
117 virtual void OnViewRegistered(istd::IPolymorphic* viewPtr) = 0;
118
122 virtual void OnViewRemoved(istd::IPolymorphic* viewPtr) = 0;
123
127 virtual QString GetOpenFilePath(const QByteArray* documentTypeIdPtr = nullptr) const = 0;
128
132 virtual QString GetSaveFilePath(const QByteArray& documentTypeId, const istd::IChangeable* dataObjectPtr, const QString& currentFilePath) const = 0;
133
138 virtual bool QueryDocumentSave(bool* ignoredPtr) = 0;
139
144
145private:
146 QString m_filePath;
147 QByteArray m_documentTypeId;
148 QByteArray m_viewTypeId;
149 std::unique_ptr<istd::IChangeable> m_documentPtr;
150 std::unique_ptr<idoc::IUndoManager> m_undoManagerPtr;
151 std::unique_ptr<istd::IPolymorphic> m_viewPtr;
152
153 bool m_isDirty;
154};
155
156
157} // namespace idoc
158
159
Basic implementation of a template-based single document manager.
virtual int GetViewsCount(int documentIndex) const
Get number of view for specified document.
virtual istd::IPolymorphic * AddViewToDocument(const istd::IChangeable &document, const QByteArray &viewTypeId=QByteArray())
Add a new view to the document.
virtual istd::IPolymorphic * GetViewFromIndex(int documentIndex, int viewIndex) const
Get single view using its and document indices.
QString GetCurrentDocumentFilePath() const
virtual bool SaveDirtyDocuments(bool beQuiet=false, bool *ignoredPtr=nullptr)
Ask user (optional) and save all dirty (changed) documents.
virtual void OnViewRemoved(istd::IPolymorphic *viewPtr)=0
Called before view is removed.
virtual QString GetOpenFilePath(const QByteArray *documentTypeIdPtr=nullptr) const =0
Gets open file names.
virtual bool SaveDocument(int documentIndex=-1, bool requestFileName=false, FileToTypeMap *savedMapPtr=nullptr, bool beQuiet=false, bool *ignoredPtr=nullptr, iproc::IProgressManager *progressManagerPtr=nullptr)
Save document.
virtual bool OpenSingleDocument(const QString &filePath, bool createView, const QByteArray &viewTypeId, QByteArray &documentTypeId, bool beQuiet, bool *ignoredPtr, iproc::IProgressManager *progressManagerPtr)
Open single document using its file path.
virtual bool QueryDocumentSave(bool *ignoredPtr)=0
Query user if this document can be closed.
virtual int GetDocumentsCount() const
Get number of opened documents.
bool NewDocument(const QByteArray &documentTypeId, bool createView, const QByteArray &viewTypeId, bool initialize, bool beQuiet, bool *ignoredPtr)
Create instance of specified document without attaching to this manager.
bool RegisterDocument()
Register (attach) created document as new working document.
bool SerializeOpenDocument(iser::IArchive &archive)
Serializes open documents information.
virtual istd::IPolymorphic * GetActiveView() const
Return the active document.
virtual void OnViewRegistered(istd::IPolymorphic *viewPtr)=0
Called after view is registered.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
Called on update of observed model.
virtual bool CloseDocument(int documentIndex=-1, bool beQuiet=false, bool *ignoredPtr=nullptr)
Close document and all its views.
virtual idoc::IUndoManager * GetUndoManagerForDocument(const istd::IChangeable *documentPtr) const
Return undo mananger for document documenPtr.
virtual QByteArray GetDocumentTypeId(const istd::IChangeable &document) const
Get ID of document type managed by this object.
virtual bool CloseView(istd::IPolymorphic *viewPtr=nullptr, bool beQuiet=false, bool *ignoredPtr=nullptr)
Close view.
virtual bool InsertNewDocument(const QByteArray &documentTypeId, bool createView=true, const QByteArray &viewTypeId="", istd::IChangeable **newDocumentPtr=nullptr, bool beQuiet=false, bool *ignoredPtr=nullptr)
Creates a new document with the document ID documentTypeId.
virtual istd::IChangeable * GetDocumentFromView(const istd::IPolymorphic &view, DocumentInfo *documentInfoPtr=nullptr) const
Return the document assigned to view.
virtual bool OpenDocument(const QByteArray *documentTypeIdPtr, const QString *fileNamePtr=nullptr, bool createView=true, const QByteArray &viewTypeId="", istd::IChangeable **documentPtr=nullptr, FileToTypeMap *loadedMapPtr=nullptr, bool beQuiet=false, bool *ignoredPtr=nullptr, iproc::IProgressManager *progressManagerPtr=nullptr)
Opens document(s) from the file list.
virtual QString GetSaveFilePath(const QByteArray &documentTypeId, const istd::IChangeable *dataObjectPtr, const QString &currentFilePath) const =0
Gets save file name.
virtual istd::IChangeable & GetDocumentFromIndex(int index, DocumentInfo *documentInfoPtr=nullptr) const
Get document at specified index.
Base implementation of document manager.
QMap< QString, QByteArray > FileToTypeMap
Map from file path to ducument type ID's.
Interface providing UNDO/REDO functionality.
Basic implementation for a single model observer.
Consume information about progress of some process.
Represent input/output persistence archive.
Definition IArchive.h:34
Set of change flags (its IDs).
Definition IChangeable.h:38
Common interface for data model objects, which can be changed.
Definition IChangeable.h:32
Contains the system indenendent basic implementations of Document/View design pattern.

© Witold Gantzke and Kirill Lepskiy