ACF $AcfVersion:0$
CSingletonDocApplicationComp.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/QSharedMemory>
7#include <QtCore/QObject>
8#include <QtCore/QTimer>
9#include <QtCore/QString>
10#include <QtCore/QStringList>
11
12// ACF includes
19
20
21namespace iqtdoc
22{
23
24
30 public QObject,
32 protected imod::TSingleModelObserverBase<ibase::IRuntimeStatusProvider>,
33 virtual public ibase::IApplication
34{
35 Q_OBJECT
36public:
39
40 I_BEGIN_COMPONENT(CSingletonDocApplicationComp);
41 I_REGISTER_INTERFACE(ibase::IApplication);
42 I_ASSIGN(m_applicationInfoCompPtr, "ApplicationInfo", "Application info used to identify the application in the system", false, "ApplicationInfo");
43 I_ASSIGN(m_slaveApplicationCompPtr, "Application", "Application component to be executed", true, "Application");
44 I_ASSIGN_TO(m_slaveGuiApplicationCompPtr, m_slaveApplicationCompPtr, false);
45 I_ASSIGN(m_documentManagerCompPtr, "DocumentManager", "Document manager used for opening of documents triggered by the shell", false, "DocumentManager");
46 I_ASSIGN(m_runtimeStatusProviderCompPtr, "RuntimeStatus", "Runtime status of the application", false, "RuntimeStatus");
47 I_ASSIGN_TO(m_runtimeStatusProviderModelCompPtr, m_runtimeStatusProviderCompPtr, false);
48 I_END_COMPONENT;
49
51
52 // reimplemented (ibase::IApplication)
53 virtual bool InitializeApplication(int argc, char** argv) override;
54 virtual int Execute(int argc, char** argv) override;
55 virtual QString GetHelpText() const override;
56 virtual QStringList GetApplicationArguments() const override;
57
58protected:
59 // reimplemented (imod::CSingleModelObserverBase)
60 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
61
62 // reimplemented (icomp::CComponentBase)
63 virtual void OnComponentCreated() override;
64 virtual void OnComponentDestroyed() override;
65
66private:
67 void ShareDocumentsForOpening(int argc, char** argv);
68 QStringList PopDocumentsForOpening() const;
69
70private Q_SLOTS:
71 void OnUpdateDocumentList();
72
73private:
74 enum{
78 MAX_DOCUMENT_PATH_LENGTH = 1024,
82 MAX_DOCUMENTS_COUNT = 100
83 };
84
88 struct RunningProcessInfo
89 {
90 qint64 processId;
91 char requestedDocuments[MAX_DOCUMENTS_COUNT][MAX_DOCUMENT_PATH_LENGTH];
92 };
93
94 I_REF(ibase::IApplicationInfo, m_applicationInfoCompPtr);
95 I_REF(ibase::IApplication, m_slaveApplicationCompPtr);
96 I_REF(iqtgui::IGuiApplication, m_slaveGuiApplicationCompPtr);
97
98 istd::TDelPtr<QSharedMemory> m_processDataPtr;
99 bool m_isAlreadyRunning;
100 QTimer m_documentUpdateTimer;
101
102 bool m_isApplicationInitialized;
103
104 I_REF(idoc::IDocumentManager, m_documentManagerCompPtr);
105 I_REF(ibase::IRuntimeStatusProvider, m_runtimeStatusProviderCompPtr);
106 I_REF(imod::IModel, m_runtimeStatusProviderModelCompPtr);
107};
108
109
110} // namespace iqtdoc
111
112
Interface for the main entry point of a component-based application.
This interface provides some information about the application.
Provider of the run-time status.
Base class for component implementation.
Provide set of user actions needed to manage documents in MVC (Model View Controller) concept.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Basic implementation for a single model observer with binding to concrete data object interface.
virtual QString GetHelpText() const override
Get information about the possible command line arguments of this application.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet) override
Called on update of observed model.
virtual void OnComponentCreated() override
virtual void OnComponentDestroyed() override
virtual bool InitializeApplication(int argc, char **argv) override
Initialize the application object.
imod::TSingleModelObserverBase< ibase::IRuntimeStatusProvider > BaseClass2
virtual int Execute(int argc, char **argv) override
Start execution loop of the application.
virtual QStringList GetApplicationArguments() const override
Get the command line arguments of this application.
Interface for Qt based application with GUI.
Set of change flags (its IDs).
Definition IChangeable.h:36
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
This package contains Qt implementations related to Document/View concept.