|
QtCanpool 3.3.0
|
The thin surface a plugin programs against. 更多...
#include <qxplugin/qxplugincontext.h>

Public 类型 | |
| enum | DockArea { LeftDock = 0x1 , RightDock = 0x2 , TopDock = 0x4 , BottomDock = 0x8 } |
| Where a newly added dock lands. 更多... | |
| enum class | ToastLevel { Information , Success , Warning , Error } |
| Toast severity understood by every host. 更多... | |
Public 成员函数 | |
| QxPluginContext (QxObjectPool *pool=Q_NULLPTR) | |
| pool is the host's object pool - QxAppShell hands over its own - and stays the host's property. | |
| virtual | ~QxPluginContext () |
| virtual void | addPage (const QString &id, const QIcon &icon, const QString &title, QWidget *page)=0 |
| Adds a page to the host's central workspace and registers it under id, which must be stable and unique across the session. | |
| virtual void | setCurrentPage (const QString &id)=0 |
| Brings the page registered under id to the front. | |
| virtual QString | currentPageId () const =0 |
| Id of the page currently on screen, or an empty string when there is none. | |
| virtual QWidget * | addDock (DockArea area, const QString &id, const QString &title, QWidget *widget)=0 |
| Creates a dock widget named id, titled title, filled with widget and dropped in area. | |
| virtual void | setStatusMessage (const QString &message)=0 |
| Replaces the host's persistent status-line message. | |
| virtual void | setBusy (bool busy)=0 |
| Shows or hides the host's indeterminate "working" indicator. | |
| virtual void | setProgressRange (int minimum, int maximum)=0 |
| Sets the range the progress runs in; maximum must be above minimum. | |
| virtual void | setProgress (int value)=0 |
| Shows how far the work has got, clamped to the range set by setProgressRange(). | |
| virtual void | clearProgress ()=0 |
| Hides the progress or busy indicator and resets it to the minimum. | |
| virtual void | showToast (const QString &text, ToastLevel level=ToastLevel::Information, int timeoutMs=-1)=0 |
| Shows a toast over the host; timeoutMs < 0 means the host's default. | |
| virtual QxCore::QxSettings * | settings () const =0 |
| The settings object backing persistence; never null. | |
| void | addObject (QObject *object) |
| Publishes object under its objectName(), where other plugins can find it. | |
| void | removeObject (QObject *object) |
| Takes object out of the pool. | |
| QList< QObject * > | objects () const |
| Everything published by any plugin and still alive, in publication order. | |
| QObject * | objectByName (const QString &name) const |
| The first live published object named name, or null. | |
| template<typename T > | |
| T * | object () const |
| The first live published object castable to T, or null. | |
Protected 属性 | |
| QxObjectPool * | m_pool = Q_NULLPTR |
| The host's pool, or null when the host offers none. | |
The thin surface a plugin programs against.
The host - the application shell that loaded the plugin - implements this interface and hands it to the plugin as the context; a plugin never sees the host's window class. Keeping the surface in qxplugin, which depends on nothing above qxcore, is what stops a host rename (a K14 concern) from rippling into every plugin: the host implements this interface, the plugin codes against it.
The surface only lists the host abilities a plugin is allowed to use. Adding a capability here is therefore a deliberate, versioned extension of the plugin contract; anything host-specific stays behind the concrete host class.
"A plugin never sees the host's window class" leaves one gap that a host-mediated surface cannot close by itself: two plugins that want to cooperate - one offering something, one wanting it - have no way to find each other. The object pool below is the host's answer to that, and it is deliberately the whole of it. What a plugin publishes is a choice it makes; what it gets back is only ever a QObject, so the two ends still need no common header and no link between them. See QxObjectPool for the mechanics.
在文件 qxplugincontext.h 第 44 行定义.
Where a newly added dock lands.
Mirrors Qx::DockWidgetArea without coupling the plugin to qxdock.
| 枚举值 | |
|---|---|
| LeftDock | |
| RightDock | |
| TopDock | |
| BottomDock | |
在文件 qxplugincontext.h 第 56 行定义.
|
strong |
Toast severity understood by every host.
The host maps it onto its own toast types.
| 枚举值 | |
|---|---|
| Information | |
| Success | |
| Warning | |
| Error | |
在文件 qxplugincontext.h 第 64 行定义.
|
explicit |
pool is the host's object pool - QxAppShell hands over its own - and stays the host's property.
A host that offers no pool passes nothing, and every pool call below then does nothing.
在文件 qxplugincontext.cpp 第 9 行定义.
|
virtualdefault |
|
pure virtual |
Creates a dock widget named id, titled title, filled with widget and dropped in area.
Returns the dock, or null when id is empty or already in use.
| void QxPlugin::QxPluginContext::addObject | ( | QObject * | object | ) |
Publishes object under its objectName(), where other plugins can find it.
Publishing is deliberate: a plugin that publishes nothing stays unreachable, which is why this is a call and not something that happens to every plugin automatically.
The pool does not take ownership, and the entry disappears when object is destroyed. Removing it in shutdown() anyway is the tidier habit: it goes away before the plugin does, rather than with it.
在文件 qxplugincontext.cpp 第 16 行定义.
|
pure virtual |
Adds a page to the host's central workspace and registers it under id, which must be stable and unique across the session.
icon and title identify the page in the host's navigation; the host decides how to surface them (for example a rail entry). The host takes ownership of page while it is installed.
|
pure virtual |
Hides the progress or busy indicator and resets it to the minimum.
|
pure virtual |
Id of the page currently on screen, or an empty string when there is none.
|
inline |
The first live published object castable to T, or null.
For the cases where the two ends share a declaration of T - a host service, or a type both link the same library for. Where they share nothing, objectByName() is the lookup that still works.
在文件 qxplugincontext.h 第 149 行定义.
| QObject * QxPlugin::QxPluginContext::objectByName | ( | const QString & | name | ) | const |
The first live published object named name, or null.
在文件 qxplugincontext.cpp 第 33 行定义.
| QList< QObject * > QxPlugin::QxPluginContext::objects | ( | ) | const |
Everything published by any plugin and still alive, in publication order.
在文件 qxplugincontext.cpp 第 28 行定义.
| void QxPlugin::QxPluginContext::removeObject | ( | QObject * | object | ) |
Takes object out of the pool.
The object is not deleted; an unknown one is a no-op.
在文件 qxplugincontext.cpp 第 22 行定义.
|
pure virtual |
Shows or hides the host's indeterminate "working" indicator.
|
pure virtual |
Brings the page registered under id to the front.
Unknown id: no-op.
|
pure virtual |
Shows how far the work has got, clamped to the range set by setProgressRange().
|
pure virtual |
Sets the range the progress runs in; maximum must be above minimum.
|
pure virtual |
Replaces the host's persistent status-line message.
|
pure virtual |
The settings object backing persistence; never null.
|
pure virtual |
Shows a toast over the host; timeoutMs < 0 means the host's default.
|
protected |
The host's pool, or null when the host offers none.
Owned by the host.
在文件 qxplugincontext.h 第 155 行定义.