ACF $AcfVersion:0$
CMultiDocumentWorkspaceGuiComp.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// Qt includes
6#include <QtCore/QtGlobal>
7#if QT_VERSION >= 0x050000
8#include <QtWidgets/QMdiArea>
9#include <QtWidgets/QMdiSubWindow>
10#else
11#include <QtGui/QMdiArea>
12#include <QtGui/QMdiSubWindow>
13#endif
14
15// ACF includes
18#include <iprm/IOptionsList.h>
25
26
27namespace iqtdoc
28{
29
30
143 idoc::CMultiDocumentManagerBase,
144 iqtgui::TRestorableGuiWrap<
145 iqtgui::TGuiComponentBase<QMdiArea> > >,
146 virtual public ibase::ICommandsProvider
147{
148 Q_OBJECT
149
150public:
155
156 I_BEGIN_COMPONENT(CMultiDocumentWorkspaceGuiComp);
157 I_REGISTER_INTERFACE(idoc::IDocumentManager);
158 I_REGISTER_INTERFACE(idoc::IDocumentTypesInfo);
159 I_REGISTER_INTERFACE(ibase::ICommandsProvider);
160 I_REGISTER_SUBELEMENT(DocumentSelection);
161 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, iprm::ISelectionParam, ExtractSelectionInfo);
162 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, imod::IModel, ExtractSelectionInfo);
163 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, istd::IChangeable, ExtractSelectionInfo);
164 I_REGISTER_SUBELEMENT_INTERFACE(DocumentSelection, iprm::IOptionsList, ExtractSelectionInfo);
165 I_ASSIGN(m_documentTemplateCompPtr, "DocumentTemplate", "Document template", true, "DocumentTemplate");
166 I_ASSIGN(m_showMaximizedAttrPtr, "ShowViewMaximized", "At start shows the document view maximized", false, true);
167 I_ASSIGN(m_showPathAsTipAttrPtr, "ShowFilePathAsToolTip", "if enabled, the current document file path will be shown as tool tip of document tab", true, false);
168 I_ASSIGN(m_allowViewRepeatingAttrPtr, "AllowViewRepeating", "If enabled, multiple views for the same document are allowed", false, true);
169 I_ASSIGN(m_rememberOpenDocumentsParamPtr, "RememberOpenDocumentsOnExit", "If enabled, restores open documents from previous session", false, "RememberOpenDocumentsOnExit");
170 I_ASSIGN(m_workspaceBackgroundColorAttrPtr, "WorkspaceBackgroundColor", "Background color of the MDI workspace", false, "");
171 I_ASSIGN(m_defaultCreatedDocumentTypeIdAttrPtr, "DefaultCreatedDocumentTypeId", "Type-ID of the document that should be created if the workspace is empty", false, "");
172 I_END_COMPONENT;
173
180
182
183 // reimplemented (idoc::IDocumentManager)
184 virtual void SetActiveView(istd::IPolymorphic* viewPtr) override;
185
186 // reimplemented (ibase::ICommandsProvider)
187 virtual const ibase::IHierarchicalCommand* GetCommands() const override;
188
189 // reimplemented (iqtgui::IGuiObject)
190 virtual void OnTryClose(bool* ignoredPtr = NULL) override;
191 virtual void OnGuiDesignChanged() override;
192
193protected:
199
205 iqtgui::IGuiObject* GetViewFromWidget(const QWidget& widget) const;
206
212 int GetDocumentIndexFromWidget(const QWidget& widget) const;
213
217 virtual void CreateConnections();
218
223
224 // reimplemented (idoc::CMultiDocumentManagerBase)
226 const QString& filePath,
227 bool createView,
228 const QByteArray& viewTypeId,
229 QByteArray& documentTypeId,
230 bool beQuiet,
231 bool* ignoredPtr,
232 ibase::IProgressManager* progressManagerPtr) override;
233
234 // reimplemented (QObject)
235 virtual bool eventFilter(QObject* sourcePtr, QEvent* eventPtr) override;
236
237 // reimplemented (TRestorableGuiWrap)
238 virtual void OnRestoreSettings(const QSettings& settings) override;
239 virtual void OnSaveSettings(QSettings& settings) const override;
240
241 // reimplemented (idoc::CMultiDocumentManagerBase)
242 virtual void CloseAllDocuments() override;
243 virtual QStringList GetOpenFilePaths(const QByteArray* documentTypeIdPtr = NULL) const override;
244 virtual void OnViewRegistered(istd::IPolymorphic* viewPtr, const SingleDocumentData& documentData) override;
245 virtual void OnViewRemoved(istd::IPolymorphic* viewPtr) override;
246 virtual bool QueryDocumentSave(const SingleDocumentData& info, bool* ignoredPtr) override;
247
248 // reimplemented (iqt:CGuiComponentBase)
249 virtual void OnGuiCreated() override;
250 virtual void OnGuiDestroyed() override;
251 virtual void OnRetranslate() override;
252 virtual void OnGuiRetranslate() override;
253
254 // reimplemented (icomp::CComponentBase)
255 virtual void OnComponentCreated() override;
256
257 // reimplemented (istd:IChangeable)
258 virtual void OnEndChanges(const ChangeSet& changeSet) override;
259
260protected Q_SLOTS:
261 void OnWindowActivated(QMdiSubWindow* window);
263
264private:
265 class DocumentSelectionInfo: virtual public iprm::ISelectionParam, virtual public iprm::IOptionsList
266 {
267 public:
268 DocumentSelectionInfo();
269
270 void SetParent(CMultiDocumentWorkspaceGuiComp& parent);
271
272 // reimplemented (iprm::ISelectionParam)
273 virtual const iprm::IOptionsList* GetSelectionConstraints() const override;
274 virtual int GetSelectedOptionIndex() const override;
275 virtual bool SetSelectedOptionIndex(int index) override;
276 virtual iprm::ISelectionParam* GetSubselection(int index) const override;
277
278 // reimplemented (iprm::IOptionsList)
279 virtual int GetOptionsFlags() const override;
280 virtual int GetOptionsCount() const override;
281 virtual QString GetOptionName(int index) const override;
282 virtual QString GetOptionDescription(int index) const override;
283 virtual QByteArray GetOptionId(int index) const override;
284 virtual bool IsOptionEnabled(int index) const override;
285
286 // reimplemented (iser::ISerializable)
287 virtual bool Serialize(iser::IArchive& archive) override;
288
289 private:
290 int m_selectedDocumentIndex;
292 };
293
294 friend class imod::TModelWrap<DocumentSelectionInfo>;
295
296 // static template methods for subelement access
297 template <class InterfaceType>
298 static InterfaceType* ExtractSelectionInfo(CMultiDocumentWorkspaceGuiComp& component)
299 {
300 return &component.m_documentSelectionInfo;
301 }
302
304
305 // global commands
306 iqtgui::CHierarchicalCommand m_windowCommand;
307
308 // window menu group
309 iqtgui::CHierarchicalCommand m_closeAllDocumentsCommand;
310
311 mutable QString m_lastDirectory;
312
313 int m_viewsCount;
314
315 imod::TModelWrap<DocumentSelectionInfo> m_documentSelectionInfo;
316
317 QString m_organizationName;
318 QString m_applicationName;
319
320 bool m_forceQuietClose;
321
322 I_REF(idoc::IDocumentTemplate, m_documentTemplateCompPtr);
323 I_REF(iprm::IEnableableParam, m_rememberOpenDocumentsParamPtr);
324 I_ATTR(bool, m_showMaximizedAttrPtr);
325 I_ATTR(bool, m_showPathAsTipAttrPtr);
326 I_ATTR(bool, m_allowViewRepeatingAttrPtr);
327 I_ATTR(QString, m_workspaceBackgroundColorAttrPtr);
328 I_ATTR(QByteArray, m_defaultCreatedDocumentTypeIdAttrPtr);
329};
330
331
332} // namespace iqtdoc
333
334
Interface for a provider of the heriarchical commands.
Consume information about progress of some process.
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.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Definition TModelWrap.h:24
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.
This class is a Qt-based workspace implementation of a multi-document manager.
virtual void OnGuiCreated() override
Called just after GUI is initialized.
virtual void OnRestoreSettings(const QSettings &settings) override
virtual void OnGuiRetranslate() override
Called from widget event filter when GUI should be retranslated.
virtual void CloseAllDocuments() override
virtual void OnRetranslate() override
Called when non-GUI elements (like commands) should be retranslated.
virtual void CreateConnections()
Creates signal/slot connnections for the implementation.
virtual void OnEndChanges(const ChangeSet &changeSet) override
Callback function for end change event.
virtual void OnSaveSettings(QSettings &settings) const override
virtual bool QueryDocumentSave(const SingleDocumentData &info, bool *ignoredPtr) override
Query user if this document should be saved.
virtual const ibase::IHierarchicalCommand * GetCommands() const override
Get list of menu commands.
virtual bool eventFilter(QObject *sourcePtr, QEvent *eventPtr) override
virtual void SetActiveView(istd::IPolymorphic *viewPtr) override
Indicate that some view is active now.
virtual void OnViewRegistered(istd::IPolymorphic *viewPtr, const SingleDocumentData &documentData) override
Called after view is registered.
iqtgui::IGuiObject * GetViewFromWidget(const QWidget &widget) const
Find view object associated with specified Qt widget.
virtual void OnGuiDesignChanged() override
int GetDocumentIndexFromWidget(const QWidget &widget) const
Find index of document associated with specified Qt widget.
virtual void OnComponentCreated() override
virtual QStringList GetOpenFilePaths(const QByteArray *documentTypeIdPtr=NULL) const override
Gets open file names.
void UpdateAllTitles()
Update titles of views or all views of specified document.
virtual void OnTryClose(bool *ignoredPtr=NULL) override
Called when the application is attempting to close.
iqtdoc::TQtDocumentManagerWrap< idoc::CMultiDocumentManagerBase, iqtgui::TRestorableGuiWrap< iqtgui::TGuiComponentBase< QMdiArea > > > BaseClass
void OnViewsCountChanged()
Called when number of windows changed.
virtual void OnViewRemoved(istd::IPolymorphic *viewPtr) override
Called before view is removed.
virtual void OnGuiDestroyed() override
Called just before GUI is released.
virtual istd::IChangeableSharedPtr OpenSingleDocument(const QString &filePath, bool createView, const QByteArray &viewTypeId, QByteArray &documentTypeId, bool beQuiet, bool *ignoredPtr, ibase::IProgressManager *progressManagerPtr) override
Open single document using its file path.
void OnWindowActivated(QMdiSubWindow *window)
Wrapper for general functionality of a Qt based document workspace.
Implementation of hierarchical command based on QAction from Qt.
Common interface for GUI objects used in ACF component context.
Definition IGuiObject.h:133
Base class for all Qt GUI componentes.
A wrapper for saving/restoring of GUI component states in the application settings.
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
Set of change flags (its IDs).
Definition IChangeable.h:36
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
Base interface for all used interfaces and implementations.
Common interface to define the hierarchical graph structures.
#define NULL
Definition istd.h:74
This package contains Qt implementations related to Document/View concept.