ACF $AcfVersion:0$
CSingleDocumentTemplateComp.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// ACF includes
6#include <imod/IModel.h>
10
11
12namespace idoc
13{
14
15
91{
92public:
95
96 I_BEGIN_COMPONENT(CSingleDocumentTemplateComp);
97 I_REGISTER_INTERFACE(idoc::IDocumentTemplate);
98 I_ASSIGN(m_documentTypeIdAttrPtr, "DocumentTypeId", "ID of supported document", true, "Default");
99 I_ASSIGN(m_documentTypeNameAttrPtr, "DocumentTypeName", "Human readable name of document", false, "");
100 I_ASSIGN(m_defaultDirectoryAttrPtr, "DefaultDirectory", "Default file directory for open file dialog", true, ".");
101 I_ASSIGN(m_documentCompFact, "DocumentFactory", "Document factory", true, "DocumentFactory");
102 I_ASSIGN_TO(m_modelCompFact, m_documentCompFact, true);
103 I_ASSIGN(m_viewCompFact, "ViewFactory", "Create of document GUI", true, "ViewFactory");
104 I_ASSIGN(m_fileLoaderCompPtr, "DocumentLoader", "Provide document loading and saving", true, "DocumentLoader");
105 I_ASSIGN(m_undoManagerCompFact, "UndoManager", "Undo manager providing undo functionality", false, "UndoManager");
106 I_ASSIGN_TO(m_undoManagerObserverCompFact, m_undoManagerCompFact, true);
107 I_ASSIGN(m_isNewSupportedAttrPtr, "IsNewSupported", "Template supports the new operation", true, false);
108 I_ASSIGN(m_isEditSupportedAttrPtr, "IsEditSupported", "Template supports the edit operation", true, false);
109 I_END_COMPONENT;
110
111 // reimplemented (idoc::IDocumentTemplate)
112 virtual ifile::IFilePersistence* GetFileLoader(const QByteArray& documentTypeId) const override;
114 QByteArray& documentTypeId,
115 bool initialize = true,
116 bool beQuiet = false,
117 bool* ignoredFlagPtr = NULL) const override;
119 const QByteArray& documentTypeId,
120 istd::IChangeable* documentPtr,
121 const QByteArray& viewTypeId = QByteArray()) const override;
122 virtual idoc::IUndoManagerUniquePtr CreateUndoManager(const QByteArray& documentTypeId, istd::IChangeable* documentPtr) const override;
123
124protected:
133
134 // reimplemented (icomp::CComponentBase)
135 virtual void OnComponentCreated() override;
136
137private:
138 I_ATTR(bool, m_isNewSupportedAttrPtr);
139 I_ATTR(bool, m_isEditSupportedAttrPtr);
140 I_ATTR(QByteArray, m_documentTypeIdAttrPtr);
141 I_TEXTATTR(m_documentTypeNameAttrPtr);
142 I_ATTR(QString, m_defaultDirectoryAttrPtr);
143 I_FACT(istd::IChangeable, m_documentCompFact);
144 I_FACT(imod::IModel, m_modelCompFact);
145 I_FACT(imod::IObserver, m_viewCompFact);
146 I_REF(ifile::IFilePersistence, m_fileLoaderCompPtr);
147 I_FACT(idoc::IUndoManager, m_undoManagerCompFact);
148 I_FACT(imod::IObserver, m_undoManagerObserverCompFact);
149};
150
151
152} // namespace idoc
153
154
155
Base class for component implementation.
Base class implementing document template for single document type.
Document template component supporting only one type of the provided document.
virtual ifile::IFilePersistence * GetFileLoader(const QByteArray &documentTypeId) const override
Get file loader/saver for specified document ID.
virtual ViewUniquePtr CreateView(const QByteArray &documentTypeId, istd::IChangeable *documentPtr, const QByteArray &viewTypeId=QByteArray()) const override
Creates a view instance for document document of type viewTypeId.
virtual ViewUniquePtr ExtractViewInterface(icomp::IComponentUniquePtr &componentPtr) const
Extract pointer of view interface from factorisied view component.
virtual void OnComponentCreated() override
virtual istd::IChangeableUniquePtr CreateDocument(QByteArray &documentTypeId, bool initialize=true, bool beQuiet=false, bool *ignoredFlagPtr=NULL) const override
Creates a document instance for document type documentTypeId.
virtual idoc::IUndoManagerUniquePtr CreateUndoManager(const QByteArray &documentTypeId, istd::IChangeable *documentPtr) const override
Creates an undo manager for a given document documentPtr.
Common interface for a document template.
Interface providing UNDO/REDO functionality.
Interface providing loading and saving of data objects.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition IObserver.h:156
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
#define I_TEXTATTR(member)
Declare translatable text attribute member.
#define NULL
Definition istd.h:74
std::unique_ptr< IComponent > IComponentUniquePtr
Definition IComponent.h:72
Contains the system independent basic implementations of Document/View design pattern.