ImagingTools Core SDK
CSingleDocumentWorkspaceGuiComp.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// ACF includes
6#include <imod/CMultiModelDispatcherBase.h>
7#include <idoc/CSingleDocumentManagerBase.h>
8#include <iqtdoc/CSingleDocumentWorkspaceGuiComp.h>
9
10// ImtCore includes
11#include <imtgui/IDocumentViewDecorator.h>
12
13
14namespace imtgui
15{
16
17
18class SdiDocumentViewDecorator;
19
20
21class CSingleDocumentWorkspaceGuiComp: public iqtdoc::CSingleDocumentWorkspaceGuiComp, public imod::CMultiModelDispatcherBase
22{
23 Q_OBJECT
24
25public:
26 typedef iqtdoc::CSingleDocumentWorkspaceGuiComp BaseClass;
27
28 I_BEGIN_COMPONENT(CSingleDocumentWorkspaceGuiComp);
29 I_REGISTER_SUBELEMENT(Commands);
30 I_REGISTER_SUBELEMENT_INTERFACE(Commands, ibase::ICommandsProvider, ExtractCommands);
31 I_REGISTER_SUBELEMENT_INTERFACE(Commands, istd::IChangeable, ExtractCommands);
32 I_REGISTER_SUBELEMENT_INTERFACE(Commands, imod::IModel, ExtractCommands);
33 I_ASSIGN(m_iconSizeAttrPtr, "IconSize", "Size of the icon used in the document command tool bar", true, 16);
34 I_ASSIGN(m_showDocumentTitleAttrPtr, "ShowDocumentTitle", "If enabled, the document title is shown inside of the decorator area", true, true);
35 I_ASSIGN(m_undoButtonsStyleAttrPtr, "UndoButtonsStyle", "Style of the command buttons for undo manager (See Qt::QToolButtonStyle for reference)", true, Qt::ToolButtonFollowStyle);
36 I_ASSIGN(m_fileButtonsStyleAttrPtr, "FileButtonsStyle", "Style of the command buttons for file operations (See Qt::QToolButtonStyle for reference)", true, Qt::ToolButtonFollowStyle);
37 I_ASSIGN(m_documentButtonsStyleAttrPtr, "DocumentButtonsStyle", "Style of the command buttons for document operations (See Qt::QToolButtonStyle for reference)", true, Qt::ToolButtonFollowStyle);
38 I_END_COMPONENT;
39
40 CSingleDocumentWorkspaceGuiComp();
41protected:
42 virtual IDocumentViewDecorator* CreateDocumentViewDecorator(
43 istd::IPolymorphic* viewPtr,
44 QWidget* parentWidgetPtr,
45 const ifile::IFilePersistence* persistencePtr);
46
47 // reimplemented (iqtdoc::CSingleDocumentWorkspaceGuiComp)
48 virtual void UpdateTitle() override;
49
50 // reimplemented (idoc::CSingleDocumentManagerBase)
51 virtual void OnViewRegistered(istd::IPolymorphic* viewPtr) override;
52 virtual void OnViewRemoved(istd::IPolymorphic* viewPtr) override;
53
54 // reimplemented (imod::CMultiModelDispatcherBase)
55 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
56
57public Q_SLOTS:
58 void OnNew();
59 void OnOpen();
60 void OnSaveDocument();
61 void OnSaveDocumentAs();
62 virtual void OnCloseDocument();
63 virtual void OnUndo();
64 virtual void OnRedo();
65
66protected:
67 class Commands: virtual public ibase::ICommandsProvider
68 {
69 public:
70 Commands();
71
72 void SetParent(CSingleDocumentWorkspaceGuiComp* parentPtr);
73
74 protected:
75 // reimplemented (ibase::ICommandsProvider)
76 virtual const ibase::IHierarchicalCommand* GetCommands() const override;
77
78 private:
79 CSingleDocumentWorkspaceGuiComp* m_parentPtr;
80 };
81
82 template <typename InterfaceType>
83 static InterfaceType* ExtractCommands(CSingleDocumentWorkspaceGuiComp& component)
84 {
85 return &component.m_commands;
86 }
87
88protected:
89 enum DataRole
90 {
91 DR_PATH = Qt::UserRole,
92 DR_TYPE_ID
93 };
94 enum ModelIds
95 {
96 MI_VISUAL_STATUS,
97 MI_DOCUMENT_COMMANDS
98 };
99
100 friend class SdiDocumentViewDecorator;
101
102 imod::TModelWrap<Commands> m_commands;
103
104 istd::TDelPtr<IDocumentViewDecorator> m_documentViewPtr;
105
106 I_ATTR(int, m_iconSizeAttrPtr);
107 I_ATTR(bool, m_showDocumentTitleAttrPtr);
108 I_ATTR(int, m_undoButtonsStyleAttrPtr);
109 I_ATTR(int, m_fileButtonsStyleAttrPtr);
110 I_ATTR(int, m_documentButtonsStyleAttrPtr);
111};
112
113
114} // namespace imtgui
115
116