ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
idoc::IDocumentTemplate Class Referenceabstract

Common interface for a document template. More...

#include <IDocumentTemplate.h>

Inheritance diagram for idoc::IDocumentTemplate:
idoc::IDocumentTypesInfo istd::IPolymorphic idoc::CCompositeDocumentTemplateComp idoc::CSingleDocumentTemplateBase idoc::CSingleDocumentTemplateComp iqtdoc::CExtendedDocumentTemplateComp

Public Types

typedef istd::TUniqueInterfacePtr< istd::IPolymorphicViewUniquePtr
 Type definitions for view smart pointers.
 
typedef istd::TSharedInterfacePtr< istd::IPolymorphicViewSharedPtr
 
- Public Types inherited from idoc::IDocumentTypesInfo
enum  SupportedFeatures { SF_NEW_DOCUMENT = 0x0001 , SF_EDIT_DOCUMENT = 0x0010 , SF_DEFAULT = 0xffff }
 Enumeration for supported types of operations with documents. More...
 
typedef QVector< QByteArray > Ids
 Type definition for document type ID collections.
 

Public Member Functions

virtual Ids GetViewTypeIds (const QByteArray &documentTypeId) const =0
 Return supported view type IDs for specified document type.
 
virtual QString GetViewTypeName (const QByteArray &documentTypeId, const QByteArray &viewTypeId) const =0
 Get human readable name of some view type ID.
 
virtual ifile::IFilePersistenceGetFileLoader (const QByteArray &documentTypeId) const =0
 Get file loader/saver for specified document ID.
 
virtual istd::IChangeableUniquePtr CreateDocument (QByteArray &documentTypeId, bool initialize=true, bool beQuiet=false, bool *ignoredFlagPtr=NULL) const =0
 Creates a document instance for document type documentTypeId.
 
virtual ViewUniquePtr CreateView (const QByteArray &documentTypeId, istd::IChangeable *documentPtr, const QByteArray &viewTypeId=QByteArray()) const =0
 Creates a view instance for document document of type viewTypeId.
 
virtual idoc::IUndoManagerUniquePtr CreateUndoManager (const QByteArray &documentTypeId, istd::IChangeable *documentPtr) const =0
 Creates an undo manager for a given document documentPtr.
 
- Public Member Functions inherited from idoc::IDocumentTypesInfo
virtual bool IsFeatureSupported (int featureFlags, const QByteArray &documentTypeId) const =0
 Return true, if the feature(s) is supported by this document template.
 
virtual Ids GetDocumentTypeIds () const =0
 Get list of supported document type IDs.
 
virtual QString GetDocumentTypeName (const QByteArray &documentTypeId) const =0
 Get human readable name of some document type ID.
 
virtual ifile::IFileTypeInfoGetDocumentFileTypeInfo (const QByteArray &documentTypeId) const =0
 Get file type information object for some selected document type.
 
virtual Ids GetDocumentTypeIdsForFile (const QString &filePath) const =0
 Get list of supported document IDs that can handle the specified file.
 
virtual QString GetDefaultDirectory (const QString &sugestedDir="", const QByteArray *documentTypeIdPtr=NULL) const =0
 Return default directory for specified document type.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Detailed Description

Common interface for a document template.

Document template provides all necessary functionality for creating and controlling the data model of a document, its persistence, and its representation (view). A template acts as a factory for documents and views, and defines the relationship between document types, their file formats, and their visual representations.

The template is responsible for:

Templates can be single-type (supporting one document type) or composite (supporting multiple document types).

Usage Example
// Get a document template
idoc::IDocumentTemplate* tmpl = GetDocumentTemplate();
// Get available document types
for (const QByteArray& typeId : docTypes) {
QString typeName = tmpl->GetDocumentTypeName(typeId);
qDebug() << "Available type:" << typeName << "(" << typeId << ")";
}
// Create a new document
QByteArray docTypeId = "TextDocument";
istd::IChangeableUniquePtr docPtr = tmpl->CreateDocument(docTypeId, true);
// Create a view for the document
istd::IPolymorphic* view = tmpl->CreateView(docTypeId, docPtr.Get()).Release();
// Get file loader for persistence
ifile::IFilePersistence* loader = tmpl->GetFileLoader(docTypeId);
if (loader) {
// Use loader to save/load the document
loader->SaveToFile(docPtr.Get(), "/path/to/file.txt");
}
Common interface for a document template.
virtual ViewUniquePtr CreateView(const QByteArray &documentTypeId, istd::IChangeable *documentPtr, const QByteArray &viewTypeId=QByteArray()) const =0
Creates a view instance for document document of type viewTypeId.
virtual istd::IChangeableUniquePtr CreateDocument(QByteArray &documentTypeId, bool initialize=true, bool beQuiet=false, bool *ignoredFlagPtr=NULL) const =0
Creates a document instance for document type documentTypeId.
virtual ifile::IFilePersistence * GetFileLoader(const QByteArray &documentTypeId) const =0
Get file loader/saver for specified document ID.
virtual Ids GetDocumentTypeIds() const =0
Get list of supported document type IDs.
virtual QString GetDocumentTypeName(const QByteArray &documentTypeId) const =0
Get human readable name of some document type ID.
QVector< QByteArray > Ids
Type definition for document type ID collections.
Interface providing loading and saving of data objects.
virtual OperationState SaveToFile(const istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const =0
This function saves data data to file filePath.
Base interface for all used interfaces and implementations.
See also
IDocumentManager, CSingleDocumentTemplateComp, CCompositeDocumentTemplateComp

Definition at line 69 of file IDocumentTemplate.h.

Member Typedef Documentation

◆ ViewSharedPtr

Definition at line 76 of file IDocumentTemplate.h.

◆ ViewUniquePtr

Type definitions for view smart pointers.

Definition at line 75 of file IDocumentTemplate.h.

Member Function Documentation

◆ CreateDocument()

virtual istd::IChangeableUniquePtr idoc::IDocumentTemplate::CreateDocument ( QByteArray &  documentTypeId,
bool  initialize = true,
bool  beQuiet = false,
bool *  ignoredFlagPtr = NULL 
) const
pure virtual

Creates a document instance for document type documentTypeId.

Parameters
documentTypeIdID of document type, can be empty for default document. If document type is undefined (empty), this field will be used to return ID of used type.
initializeIf true, document should be filled with initial data (operation new), otherwise initialization is not needed (e.g., for document loading - filling of data will be done by loader).
beQuietIf true, no user interaction dialogs will be shown.
ignoredFlagPtrOptional output flag indicating that the user canceled this operation.
Returns
Unique pointer to the created document, or nullptr if creation failed.
Example
QByteArray docType = "TextDocument";
istd::IChangeableUniquePtr doc = tmpl->CreateDocument(docType, true);
if (doc) {
// Document created successfully
}

Implemented in idoc::CCompositeDocumentTemplateComp, and idoc::CSingleDocumentTemplateComp.

◆ CreateUndoManager()

virtual idoc::IUndoManagerUniquePtr idoc::IDocumentTemplate::CreateUndoManager ( const QByteArray &  documentTypeId,
istd::IChangeable documentPtr 
) const
pure virtual

Creates an undo manager for a given document documentPtr.

Parameters
documentTypeIdID of document type.
documentPtrPointer to document object that will use this undo manager.
Returns
Unique pointer to created instance of undo manager, or nullptr if creating of undo manager was impossible.

The undo manager tracks changes to the document and allows them to be undone/redone. Not all document types support undo functionality.

Implemented in idoc::CCompositeDocumentTemplateComp, and idoc::CSingleDocumentTemplateComp.

◆ CreateView()

virtual ViewUniquePtr idoc::IDocumentTemplate::CreateView ( const QByteArray &  documentTypeId,
istd::IChangeable documentPtr,
const QByteArray &  viewTypeId = QByteArray() 
) const
pure virtual

Creates a view instance for document document of type viewTypeId.

Parameters
documentTypeIdID of document type.
documentPtrPointer to document object that this view will display.
viewTypeIdOptional ID specifying view type if more view types are supported. If empty or not provided, the first/default view type for this document type is used. Use GetViewTypeIds() to discover available view types for a document type.
Returns
Unique pointer to the created view, or nullptr if creation failed.

The view is responsible for displaying the document's content to the user. Some document types support multiple view types (e.g., text view, hex view, preview).

Example
// Create default view
istd::IPolymorphic* view = tmpl->CreateView(docTypeId, doc.Get()).Release();
// Create specific view type
QByteArray viewType = "HexView";
istd::IPolymorphic* hexView = tmpl->CreateView(docTypeId, doc.Get(), viewType).Release();

Implemented in idoc::CCompositeDocumentTemplateComp, and idoc::CSingleDocumentTemplateComp.

◆ GetFileLoader()

virtual ifile::IFilePersistence * idoc::IDocumentTemplate::GetFileLoader ( const QByteArray &  documentTypeId) const
pure virtual

Get file loader/saver for specified document ID.

Parameters
documentTypeIdType ID of document that will be loaded/saved.
Returns
Pointer to file persistence object that handles I/O operations, or NULL if not supported.

The file persistence object handles reading and writing documents to/from files.

Implemented in idoc::CCompositeDocumentTemplateComp, and idoc::CSingleDocumentTemplateComp.

◆ GetViewTypeIds()

virtual Ids idoc::IDocumentTemplate::GetViewTypeIds ( const QByteArray &  documentTypeId) const
pure virtual

Return supported view type IDs for specified document type.

Parameters
documentTypeIdID of document type.
Returns
Vector of view type IDs that can display this document type.

A single document type may support multiple view types (e.g., text view, hex view, preview).

Implemented in idoc::CCompositeDocumentTemplateComp, and idoc::CSingleDocumentTemplateBase.

◆ GetViewTypeName()

virtual QString idoc::IDocumentTemplate::GetViewTypeName ( const QByteArray &  documentTypeId,
const QByteArray &  viewTypeId 
) const
pure virtual

Get human readable name of some view type ID.

Parameters
documentTypeIdID of document type.
viewTypeIdID of view type.
Returns
Localized human-readable name for the view type (e.g., "Text View", "Hex View").

Implemented in idoc::CCompositeDocumentTemplateComp, and idoc::CSingleDocumentTemplateBase.


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