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

© 2007-2017 Witold Gantzke and Kirill Lepskiy