ICF 3.1.1.10
Technical documentation of ICF Libraries
idoc::CSingleDocumentManagerBase Class Referenceabstract

Basic implementation of a template-based single document manager. More...

#include <CSingleDocumentManagerBase.h>

Inheritance diagram for idoc::CSingleDocumentManagerBase:
Collaboration diagram for idoc::CSingleDocumentManagerBase:

Public Member Functions

 CSingleDocumentManagerBase ()
 
virtual idoc::IUndoManager * GetUndoManagerForDocument (const istd::IChangeable *documentPtr) const
 Return undo mananger for document documenPtr.
 
virtual int GetDocumentsCount () const
 Get number of opened documents.
 
virtual istd::IChangeable & GetDocumentFromIndex (int index, DocumentInfo *documentInfoPtr=nullptr) const
 Get document at specified index.
 
virtual int GetViewsCount (int documentIndex) const
 Get number of view for specified document.
 
virtual istd::IPolymorphic * GetViewFromIndex (int documentIndex, int viewIndex) const
 Get single view using its and document indices.
 
virtual istd::IPolymorphic * GetActiveView () const
 Return the active document.
 
virtual istd::IChangeable * GetDocumentFromView (const istd::IPolymorphic &view, DocumentInfo *documentInfoPtr=nullptr) const
 Return the document assigned to view.
 
virtual istd::IPolymorphic * AddViewToDocument (const istd::IChangeable &document, const QByteArray &viewTypeId=QByteArray())
 Add a new view to the document.
 
virtual QByteArray GetDocumentTypeId (const istd::IChangeable &document) const
 Get ID of document type managed by this object.
 
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 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 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 SaveDirtyDocuments (bool beQuiet=false, bool *ignoredPtr=nullptr)
 Ask user (optional) and save all dirty (changed) documents.
 
virtual bool CloseDocument (int documentIndex=-1, bool beQuiet=false, bool *ignoredPtr=nullptr)
 Close document and all its views.
 
virtual bool CloseView (istd::IPolymorphic *viewPtr=nullptr, bool beQuiet=false, bool *ignoredPtr=nullptr)
 Close view.
 
- Public Member Functions inherited from idoc::CTmplBasedDocumentManagerBase
 CTmplBasedDocumentManagerBase ()
 
virtual int GetAllowedOperationFlags (const istd::IPolymorphic *viewPtr=nullptr) const
 Get flags of allowed operations.
 
virtual bool IsFeatureSupported (int featureFlags, const QByteArray &documentTypeId) const
 Return true, if the feature(s) is supported by this document template.
 
virtual Ids GetDocumentTypeIds () const
 Get list of supported document ID's can be created for specified file.
 
virtual QString GetDocumentTypeName (const QByteArray &documentTypeId) const
 Get human readable name of some document type ID.
 
virtual ifile::IFileTypeInfo * GetDocumentFileTypeInfo (const QByteArray &documentTypeId) const
 Get file type information object for some selected document type.
 
virtual Ids GetDocumentTypeIdsForFile (const QString &filePath) const
 Get list of supported document ID's can be created for specified file.
 
virtual QString GetDefaultDirectory (const QString &sugestedDir="", const QByteArray *documentTypeIdPtr=nullptr) const
 Return default directory for specified document type.
 
- Public Member Functions inherited from idoc::IDocumentManager
virtual void SetActiveView (istd::IPolymorphic *viewPtr)=0
 Indicate that some view is active now.
 
- Public Member Functions inherited from istd::IChangeable
virtual int GetSupportedOperations () const
 Get set of flags for supported operations.
 
virtual bool CopyFrom (const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 Copy this object from another one.
 
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual std::unique_ptr< IChangeable > CloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this object.
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state.
 
virtual QMutex * GetChangesLock () const
 Get mutex beeing locked during changes, if available.
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction.
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction.
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes.
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes.
 
- Public Member Functions inherited from idoc::IDocumentTypesInfo

Protected Member Functions

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.
 
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.
 
void EnsureViewRemoved ()
 
QString GetCurrentDocumentFilePath () const
 
bool HasDocumentPendingChanges () const
 
virtual void OnUpdate (const istd::IChangeable::ChangeSet &changeSet)
 Called on update of observed model.
 
virtual void OnViewRegistered (istd::IPolymorphic *viewPtr)=0
 Called after view is registered.
 
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 QString GetSaveFilePath (const QByteArray &documentTypeId, const istd::IChangeable *dataObjectPtr, const QString &currentFilePath) const =0
 Gets save file name.
 
virtual bool QueryDocumentSave (bool *ignoredPtr)=0
 Query user if this document can be closed.
 
bool SerializeOpenDocument (iser::IArchive &archive)
 Serializes open documents information.
 
- Protected Member Functions inherited from idoc::CTmplBasedDocumentManagerBase
virtual const idoc::IDocumentTemplate * GetDocumentTemplate () const
 
void SetDocumentTemplate (const idoc::IDocumentTemplate *documentTemplatePtr)
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event.
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event.
 
- Protected Member Functions inherited from imod::CSingleModelObserverBase
void SetModelPtr (imod::IModel *modelPtr)
 Set internal model pointer to specified value.
 
 CSingleModelObserverBase ()
 
virtual ~CSingleModelObserverBase ()
 
imod::IModel * GetObservedModel () const
 Get access to observed model.
 
imod::IModel * GetModelPtr () const
 Get access to observed model.
 
void EnsureModelDetached ()
 Make sure this observer is detached.
 
void SetObservedIds (const istd::IChangeable::ChangeSet &changeMask)
 Set list of ID's beeing observed.
 
bool IsModelAttached (const imod::IModel *modelPtr=nullptr) const override
 Check if specified model is attached.
 
bool OnModelAttached (imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
 This call back function will be called, if an observable object is about to be attached.
 
bool OnModelDetached (imod::IModel *modelPtr) override
 This call back function will be called, if an observable object is about to be detached.
 
void BeforeModelChange (imod::IModel *modelPtr) override
 This function will be called before update of the observer contents occures.
 
void AfterModelChange (imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
 This function will be called after update of the observer contents occures.
 
- Protected Member Functions inherited from imod::IObserver

Additional Inherited Members

- Public Types inherited from idoc::IDocumentManager
enum  ChangeFlags {
  CF_DOCUMENT_RENAMED = 0x834d670 , CF_DOCUMENT_CREATED , CF_DOCUMENT_REMOVED , CF_DOCUMENT_COUNT_CHANGED ,
  CF_VIEW_ACTIVATION_CHANGED
}
 Possible changes in the mananger data model. More...
 
enum  OperationFlags {
  OF_FILE_NEW = 0x0001 , OF_FILE_OPEN = 0x0002 , OF_FILE_SAVE = 0x0004 , OF_FILE_SAVE_AS = 0x0008 ,
  OF_KNOWN_PATH = 0x0010
}
 Flags describing possible operations. More...
 
typedef QMap< QString, QByteArray > FileToTypeMap
 Map from file path to ducument type ID's.
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ICF_INTERNAL = 0 , CF_ALL_DATA , CF_ANY , CF_DESTROYING ,
  CF_DELEGATED , CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0 , SO_OBSERVE = 1 << 0 , SO_COPY = 1 << 1 , SO_CLONE = 1 << 2 ,
  SO_COMPARE = 1 << 3 , SO_RESET = 1 << 4 , SO_CHANGE_LOCK = 1 << 5
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT , CM_WITHOUT_REFS , CM_WITH_REFS , CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 
- Public Types inherited from idoc::IDocumentTypesInfo
enum  SupportedFeatures { SF_NEW_DOCUMENT = 0x0001 , SF_EDIT_DOCUMENT = 0x0010 , SF_DEFAULT = 0xffff }
 Enumeration for supported types of operation with the document. More...
 
typedef QVector< QByteArray > Ids
 
- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSet & GetNoChanges ()
 Get empty set of changes.
 
static const ChangeSet & GetAnyChange ()
 Get anonymous change set.
 
static const ChangeSet & GetAllChanges ()
 Get anonymous change set.
 
static const ChangeSet & GetDelegatedChanges ()
 Get delegated change set.
 
- Protected Types inherited from imod::CSingleModelObserverBase
typedef imod::IModel ModelType
 

Detailed Description

Basic implementation of a template-based single document manager.

Definition at line 26 of file CSingleDocumentManagerBase.h.

Constructor & Destructor Documentation

◆ CSingleDocumentManagerBase()

idoc::CSingleDocumentManagerBase::CSingleDocumentManagerBase ( )

Member Function Documentation

◆ AddViewToDocument()

virtual istd::IPolymorphic * idoc::CSingleDocumentManagerBase::AddViewToDocument ( const istd::IChangeable & document,
const QByteArray & viewTypeId = QByteArray() )
virtual

Add a new view to the document.

Parameters
documentdocument instance
viewTypeIdID of view type, if it will be created.
Returns
Created view object

Implements idoc::IDocumentManager.

◆ CloseDocument()

virtual bool idoc::CSingleDocumentManagerBase::CloseDocument ( int documentIndex = -1,
bool beQuiet = false,
bool * ignoredPtr = nullptr )
virtual

Close document and all its views.

Parameters
documentIndexoptional index of document to close, if negative then current active document will be closed.
beQuietif true, no user interaction will be done. Typically user will be asked for saving document.
ignoredPtroptional return flag indicating that closing was aborted by user.

Implements idoc::IDocumentManager.

◆ CloseView()

virtual bool idoc::CSingleDocumentManagerBase::CloseView ( istd::IPolymorphic * viewPtr = nullptr,
bool beQuiet = false,
bool * ignoredPtr = nullptr )
virtual

Close view.

Parameters
viewPtrpointer to view should be closed or nullptr if current active view should be closed.
beQuietif true, no user interaction will be done. Typically user will be asked for saving document.
ignoredPtroptional return flag indicating that closing was aborted by user.

Implements idoc::IDocumentManager.

◆ EnsureViewRemoved()

void idoc::CSingleDocumentManagerBase::EnsureViewRemoved ( )
protected

◆ GetActiveView()

virtual istd::IPolymorphic * idoc::CSingleDocumentManagerBase::GetActiveView ( ) const
virtual

Return the active document.

If no document is active, the function return a nullptr

Implements idoc::IDocumentManager.

◆ GetCurrentDocumentFilePath()

QString idoc::CSingleDocumentManagerBase::GetCurrentDocumentFilePath ( ) const
protected

◆ GetDocumentFromIndex()

virtual istd::IChangeable & idoc::CSingleDocumentManagerBase::GetDocumentFromIndex ( int index,
DocumentInfo * documentInfoPtr = nullptr ) const
virtual

Get document at specified index.

Parameters
indexindex of document.
documentInfoPtroptional return value describing some additional informations about document.

Implements idoc::IDocumentManager.

◆ GetDocumentFromView()

virtual istd::IChangeable * idoc::CSingleDocumentManagerBase::GetDocumentFromView ( const istd::IPolymorphic & view,
DocumentInfo * documentInfoPtr = nullptr ) const
virtual

Return the document assigned to view.

Parameters
viewview object.
documentInfoPtroptional return value describing some additional informations about document.
Returns
pointer to assigned document, or nullptr if no document for this view exists.

Implements idoc::IDocumentManager.

◆ GetDocumentsCount()

virtual int idoc::CSingleDocumentManagerBase::GetDocumentsCount ( ) const
virtual

Get number of opened documents.

Implements idoc::IDocumentManager.

◆ GetDocumentTypeId()

virtual QByteArray idoc::CSingleDocumentManagerBase::GetDocumentTypeId ( const istd::IChangeable & document) const
virtual

Get ID of document type managed by this object.

Returns
ID of document type or empty string if no document is found.

Implements idoc::IDocumentManager.

◆ GetOpenFilePath()

virtual QString idoc::CSingleDocumentManagerBase::GetOpenFilePath ( const QByteArray * documentTypeIdPtr = nullptr) const
protectedpure virtual

Gets open file names.

Implemented in idocgui::CSingleDocumentWorkspaceGuiComp.

◆ GetSaveFilePath()

virtual QString idoc::CSingleDocumentManagerBase::GetSaveFilePath ( const QByteArray & documentTypeId,
const istd::IChangeable * dataObjectPtr,
const QString & currentFilePath ) const
protectedpure virtual

◆ GetUndoManagerForDocument()

virtual idoc::IUndoManager * idoc::CSingleDocumentManagerBase::GetUndoManagerForDocument ( const istd::IChangeable * documentPtr) const
virtual

Return undo mananger for document documenPtr.

Implements idoc::IDocumentManager.

◆ GetViewFromIndex()

virtual istd::IPolymorphic * idoc::CSingleDocumentManagerBase::GetViewFromIndex ( int documentIndex,
int viewIndex ) const
virtual

Get single view using its and document indices.

Implements idoc::IDocumentManager.

◆ GetViewsCount()

virtual int idoc::CSingleDocumentManagerBase::GetViewsCount ( int documentIndex) const
virtual

Get number of view for specified document.

Implements idoc::IDocumentManager.

◆ HasDocumentPendingChanges()

bool idoc::CSingleDocumentManagerBase::HasDocumentPendingChanges ( ) const
protected

◆ InsertNewDocument()

virtual bool idoc::CSingleDocumentManagerBase::InsertNewDocument ( const QByteArray & documentTypeId,
bool createView = true,
const QByteArray & viewTypeId = "",
istd::IChangeable ** newDocumentPtr = nullptr,
bool beQuiet = false,
bool * ignoredPtr = nullptr )
virtual

Creates a new document with the document ID documentTypeId.

Parameters
documentTypeIdID of document type.
createViewif true, view will be automatically created.
viewTypeIdID of view type, if it will be created.
newDocumentPtroptional pointer where new created document will be returned.
beQuietif true, no user interaction will be done.
ignoredPtroptional return flag indicating that creating was aborted by user.
Returns
true, if success.

Implements idoc::IDocumentManager.

◆ NewDocument()

bool idoc::CSingleDocumentManagerBase::NewDocument ( const QByteArray & documentTypeId,
bool createView,
const QByteArray & viewTypeId,
bool initialize,
bool beQuiet,
bool * ignoredPtr )
protected

Create instance of specified document without attaching to this manager.

◆ OnUpdate()

virtual void idoc::CSingleDocumentManagerBase::OnUpdate ( const istd::IChangeable::ChangeSet & changeSet)
protectedvirtual

Called on update of observed model.

This method is designed to be overload by derrived classes.

Reimplemented from imod::CSingleModelObserverBase.

◆ OnViewRegistered()

virtual void idoc::CSingleDocumentManagerBase::OnViewRegistered ( istd::IPolymorphic * viewPtr)
protectedpure virtual

Called after view is registered.

Implemented in idocgui::CSingleDocumentWorkspaceGuiComp.

◆ OnViewRemoved()

virtual void idoc::CSingleDocumentManagerBase::OnViewRemoved ( istd::IPolymorphic * viewPtr)
protectedpure virtual

Called before view is removed.

Implemented in idocgui::CSingleDocumentWorkspaceGuiComp.

◆ OpenDocument()

virtual bool idoc::CSingleDocumentManagerBase::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 )
virtual

Opens document(s) from the file list.

Parameters
documentTypeIdPtroptional ID of document type. If it is nullptr, document type will be found automatically.
fileNamePtrfile name.
createViewif true, view will be automatically created.
viewTypeIdID of view type, if it will be created.
documentPtroptional access to the document instance.
loadedMapPtroptional list of loaded files and its document type ID's.
beQuietif true, no user interaction will be done.
ignoredPtroptional return flag indicating that opening was aborted by user.
progressManagerPtrprovide optional progress manager.

Implements idoc::IDocumentManager.

◆ OpenSingleDocument()

virtual bool idoc::CSingleDocumentManagerBase::OpenSingleDocument ( const QString & filePath,
bool createView,
const QByteArray & viewTypeId,
QByteArray & documentTypeId,
bool beQuiet,
bool * ignoredPtr,
iproc::IProgressManager * progressManagerPtr )
protectedvirtual

Open single document using its file path.

Parameters
filePathfile path.
createViewif true, instance of view will be created.
viewTypeIdoptional view type ID should be created.
documentTypeIdoutput parameter returning loaded ducument type ID.
Returns
instance of created document or nullptr if error is occured.

◆ QueryDocumentSave()

virtual bool idoc::CSingleDocumentManagerBase::QueryDocumentSave ( bool * ignoredPtr)
protectedpure virtual

Query user if this document can be closed.

Parameters
ignoredPtroptional return flag indicating that user ignored this close operation.

Implemented in idocgui::CSingleDocumentWorkspaceGuiComp.

◆ RegisterDocument()

bool idoc::CSingleDocumentManagerBase::RegisterDocument ( )
protected

Register (attach) created document as new working document.

◆ SaveDirtyDocuments()

virtual bool idoc::CSingleDocumentManagerBase::SaveDirtyDocuments ( bool beQuiet = false,
bool * ignoredPtr = nullptr )
virtual

Ask user (optional) and save all dirty (changed) documents.

Parameters
beQuietif true, no user interaction will be done. Typically user will be asked for saving document.
ignoredPtroptional return flag indicating that process was aborted by user.
Returns
true if all documents were saved and are not dirty now.

Implements idoc::IDocumentManager.

◆ SaveDocument()

virtual bool idoc::CSingleDocumentManagerBase::SaveDocument ( int documentIndex = -1,
bool requestFileName = false,
FileToTypeMap * savedMapPtr = nullptr,
bool beQuiet = false,
bool * ignoredPtr = nullptr,
iproc::IProgressManager * progressManagerPtr = nullptr )
virtual

Save document.

Parameters
documentIndexoptional index of document to save, if negative then current active document will be saved.
requestFileNameif true, file name will be always requested by user.
savedMapPtroptional list of files will be extended with currently saved file.
beQuietif true, no user interaction will be done.
ignoredPtroptional return flag indicating that saving was aborted by user.

Implements idoc::IDocumentManager.

◆ SerializeOpenDocument()

bool idoc::CSingleDocumentManagerBase::SerializeOpenDocument ( iser::IArchive & archive)
protected

Serializes open documents information.


The documentation for this class was generated from the following file:

© Witold Gantzke and Kirill Lepskiy