ICF 3.1.1.10
Technical documentation of ICF Libraries
CMultiDocumentWorkspaceGuiComp.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/QtGlobal>
11#include <QtWidgets/QMdiArea>
12#include <QtWidgets/QMdiSubWindow>
13
14// ICF includes
17#include <iprm/IOptionsList.h>
24
25
26namespace idocgui
27{
28
29
35 idoc::CMultiDocumentManagerBase,
36 istdgui::TRestorableGuiWrap<
37 istdgui::TGuiComponentBase<QMdiArea> > >,
38 virtual public ibase::ICommandsProvider
39{
40 Q_OBJECT
41
42public:
47
48 I_BEGIN_COMPONENT(CMultiDocumentWorkspaceGuiComp);
49 I_REGISTER_INTERFACE(idoc::IDocumentManager);
50 I_REGISTER_INTERFACE(idoc::IDocumentTypesInfo);
51 I_REGISTER_INTERFACE(ibase::ICommandsProvider);
52 I_REGISTER_SUBELEMENT(DocumentSelection);
53 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, iprm::ISelectionParam, ExtractSelectionInfo);
54 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, imod::IModel, ExtractSelectionInfo);
55 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, istd::IChangeable, ExtractSelectionInfo);
56 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, iprm::IOptionsList, ExtractSelectionInfo);
57 I_ASSIGN(m_documentTemplateCompPtr, "DocumentTemplate", "Document template", true, "DocumentTemplate");
58 I_ASSIGN(m_showMaximizedAttrPtr, "ShowViewMaximized", "At start shows the document view maximized", false, true);
59 I_ASSIGN(m_showPathAsTipAttrPtr, "ShowFilePathAsToolTip", "if enabled, the current document file path will be shown as tool tip of document tab", true, false);
60 I_ASSIGN(m_allowViewRepeatingAttrPtr, "AllowViewRepeating", "If enabled, multiple views for the same document are allowed", false, true);
61 I_ASSIGN(m_rememberOpenDocumentsParamPtr, "RememberOpenDocumentsOnExit", "If enabled, restores open documents from previous session", false, "RememberOpenDocumentsOnExit");
62 I_ASSIGN(m_workspaceBackgroundColorAttrPtr, "WorkspaceBackgroundColor", "Background color of the MDI workspace", false, "");
63 I_ASSIGN(m_defaultCreatedDocumentTypeIdAttrPtr, "DefaultCreatedDocumentTypeId", "Type-ID of the document that should be created if the workspace is empty", false, "");
64 I_END_COMPONENT;
65
67 {
68 GI_WINDOW = 0x300,
71 };
72
74
75 // reimplemented (idoc::IDocumentManager)
76 void SetActiveView(istd::IPolymorphic* viewPtr) override;
77
78 // reimplemented (ibase::ICommandsProvider)
80
81 // reimplemented (istdgui::IGuiObject)
82 void OnTryClose(bool* ignoredPtr = nullptr) override;
83
84protected:
85
91
97 istdgui::IGuiObject* GetViewFromWidget(const QWidget& widget) const;
98
104 int GetDocumentIndexFromWidget(const QWidget& widget) const;
105
109 virtual void CreateConnections();
110
115
116 // reimplemented (idoc::CMultiDocumentManagerBase)
118 const QString& filePath,
119 bool createView,
120 const QByteArray& viewTypeId,
121 QByteArray& documentTypeId,
122 bool beQuiet,
123 bool* ignoredPtr,
124 iproc::IProgressManager* progressManagerPtr) override;
125
126 // reimplemented (QObject)
127 bool eventFilter(QObject* sourcePtr, QEvent* eventPtr) override;
128
129 // reimplemented (TRestorableGuiWrap)
130 void OnRestoreSettings(const QSettings& settings) override;
131 void OnSaveSettings(QSettings& settings) const override;
132
133 // reimplemented (idoc::CMultiDocumentManagerBase)
134 void CloseAllDocuments() override;
135 QStringList GetOpenFilePaths(const QByteArray* documentTypeIdPtr = nullptr) const override;
136 void OnViewRegistered(istd::IPolymorphic* viewPtr, const SingleDocumentData& documentData) override;
137 void OnViewRemoved(istd::IPolymorphic* viewPtr) override;
138 bool QueryDocumentSave(const SingleDocumentData& info, bool* ignoredPtr) override;
139
140 // reimplemented (ibase:CGuiComponentBase)
141 void OnGuiCreated() override;
142 void OnGuiDestroyed() override;
143 void OnRetranslate() override;
144 void OnGuiRetranslate() override;
145
146 // reimplemented (icomp::CComponentBase)
147 void OnComponentCreated() override;
148
149 // reimplemented (istd:IChangeable)
150 void OnEndChanges(const ChangeSet& changeSet) override;
151
152protected Q_SLOTS:
153 void OnWindowActivated(QMdiSubWindow* window);
155
156private:
157 class DocumentSelectionInfo: virtual public iprm::ISelectionParam, virtual public iprm::IOptionsList
158 {
159 public:
160 DocumentSelectionInfo();
161
162 void SetParent(CMultiDocumentWorkspaceGuiComp& parent);
163
164 // reimplemented (iprm::ISelectionParam)
165 const iprm::IOptionsList* GetSelectionConstraints() const override;
166 QByteArray GetSelectedOptionId() const override;
167 int GetSelectedOptionIndex() const override;
168 bool SetSelectedOptionIndex(int index) override;
169 iprm::ISelectionParam* GetSubselection(int index) const override;
170
171 // reimplemented (iprm::IOptionsList)
172 int GetOptionsFlags() const override;
173 int GetOptionsCount() const override;
174 QString GetOptionName(int index) const override;
175 QString GetOptionDescription(int index) const override;
176 QByteArray GetOptionId(int index) const override;
177 bool IsOptionEnabled(int index) const override;
178
179 // reimplemented (iser::ISerializable)
180 bool Serialize(iser::IArchive& archive) override;
181
182 private:
183 int m_docIndex;
185 };
186
187 friend class imod::TModelWrap<DocumentSelectionInfo>;
188
189 // static template methods for subelement access
190 template <class InterfaceType>
191 static InterfaceType* ExtractSelectionInfo(CMultiDocumentWorkspaceGuiComp& component)
192 {
193 return &component.m_documentSelectionInfo;
194 }
195
197
198 // global commands
199 istdgui::CHierarchicalCommand m_windowCommand;
200
201 // window menu group
202 istdgui::CHierarchicalCommand m_closeAllDocumentsCommand;
203
204 mutable QString m_lastDirectory;
205
206 int m_viewsCount;
207
208 imod::TModelWrap<DocumentSelectionInfo> m_documentSelectionInfo;
209
210 QString m_organizationName;
211 QString m_applicationName;
212
213 bool m_forceQuietClose;
214
215 I_REF(idoc::IDocumentTemplate, m_documentTemplateCompPtr);
216 I_REF(iprm::IEnableableParam, m_rememberOpenDocumentsParamPtr);
217 I_ATTR(bool, m_showMaximizedAttrPtr);
218 I_ATTR(bool, m_showPathAsTipAttrPtr);
219 I_ATTR(bool, m_allowViewRepeatingAttrPtr);
220 I_ATTR(QString, m_workspaceBackgroundColorAttrPtr);
221 I_ATTR(QByteArray, m_defaultCreatedDocumentTypeIdAttrPtr);
222};
223
224
225} // namespace idocgui
226
227
Interface for a provider of the heriarchical commands.
Basic implementation of a template-based multiple document manager.
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept.
Common interface for a document template.
Provide information about different document types.
This class is a Qt-based workspace implementation of a document manager.
void UpdateAllTitles()
Update titles of views or all views of specified document.
void OnGuiDestroyed() override
Called just before GUI is released.
void OnSaveSettings(QSettings &settings) const override
void OnRetranslate() override
Called when non-GUI elements (like commands) should be retranslated.
int GetDocumentIndexFromWidget(const QWidget &widget) const
Find index of document associated with specified Qt widget.
idocgui::TQtDocumentManagerWrap< idoc::CMultiDocumentManagerBase, istdgui::TRestorableGuiWrap< istdgui::TGuiComponentBase< QMdiArea > > > BaseClass
const ibase::IHierarchicalCommand * GetCommands() const override
Get list of menu commands.
bool QueryDocumentSave(const SingleDocumentData &info, bool *ignoredPtr) override
Query user if this document should be saved.
void OnRestoreSettings(const QSettings &settings) override
void OnTryClose(bool *ignoredPtr=nullptr) override
Called on trying to close application.
void OnGuiCreated() override
Called just after GUI is initialized.
void OnGuiRetranslate() override
Called from widget event filter when GUI should be retranslated.
virtual void CreateConnections()
Creates signal/slot connnections for the implementation.
istd::IChangeable * OpenSingleDocument(const QString &filePath, bool createView, const QByteArray &viewTypeId, QByteArray &documentTypeId, bool beQuiet, bool *ignoredPtr, iproc::IProgressManager *progressManagerPtr) override
Open single document using its file path.
bool eventFilter(QObject *sourcePtr, QEvent *eventPtr) override
void SetActiveView(istd::IPolymorphic *viewPtr) override
Indicate that some view is active now.
void OnEndChanges(const ChangeSet &changeSet) override
Callback function for end change event.
void OnViewsCountChanged()
Called when number of windows changed.
void OnWindowActivated(QMdiSubWindow *window)
void OnViewRegistered(istd::IPolymorphic *viewPtr, const SingleDocumentData &documentData) override
Called after view is registered.
istdgui::IGuiObject * GetViewFromWidget(const QWidget &widget) const
Find view object associated with specified Qt widget.
void OnViewRemoved(istd::IPolymorphic *viewPtr) override
Called before view is removed.
QStringList GetOpenFilePaths(const QByteArray *documentTypeIdPtr=nullptr) const override
Gets open file names.
Wrapper for general functionality of a Qt based document workspace.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:29
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:28
Interface for objects which can be enabled/disabled.
Constraints of selection from set of possibilities.
Interface allowing to select single option from list of options.
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
Common interface to define the hierarchical graph structures.
Implementation of hierarchical command based on QAction from Qt.
Common interface for GUI objects using in component context.
Definition IGuiObject.h:27
Base class for all Qt GUI componentes.
A wrapper for saving/restoring of GUI component states in the application settings.
This package contains Qt implementations related to Document/View concept.

© Witold Gantzke and Kirill Lepskiy