QtCanpool 3.3.0
载入中...
搜索中...
未找到
QxPlugin::QxPluginContext类 参考abstract

The thin surface a plugin programs against. 更多...

#include <qxplugin/qxplugincontext.h>

类 QxPlugin::QxPluginContext 继承关系图:

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 行定义.

成员枚举类型说明

◆ DockArea

Where a newly added dock lands.

Mirrors Qx::DockWidgetArea without coupling the plugin to qxdock.

枚举值
LeftDock 
RightDock 
TopDock 
BottomDock 

在文件 qxplugincontext.h 第 56 行定义.

◆ ToastLevel

Toast severity understood by every host.

The host maps it onto its own toast types.

枚举值
Information 
Success 
Warning 
Error 

在文件 qxplugincontext.h 第 64 行定义.

构造及析构函数说明

◆ QxPluginContext()

QxPlugin::QxPluginContext::QxPluginContext ( QxObjectPool *  pool = Q_NULLPTR)
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 行定义.

◆ ~QxPluginContext()

QxPlugin::QxPluginContext::~QxPluginContext ( )
virtualdefault

成员函数说明

◆ addDock()

virtual QWidget * QxPlugin::QxPluginContext::addDock ( DockArea  area,
const QString &  id,
const QString &  title,
QWidget *  widget 
)
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.

◆ addObject()

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 行定义.

◆ addPage()

virtual void QxPlugin::QxPluginContext::addPage ( const QString &  id,
const QIcon &  icon,
const QString &  title,
QWidget *  page 
)
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.

◆ clearProgress()

virtual void QxPlugin::QxPluginContext::clearProgress ( )
pure virtual

Hides the progress or busy indicator and resets it to the minimum.

◆ currentPageId()

virtual QString QxPlugin::QxPluginContext::currentPageId ( ) const
pure virtual

Id of the page currently on screen, or an empty string when there is none.

◆ object()

template<typename T >
T * QxPlugin::QxPluginContext::object ( ) const
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 行定义.

◆ objectByName()

QObject * QxPlugin::QxPluginContext::objectByName ( const QString &  name) const

The first live published object named name, or null.

在文件 qxplugincontext.cpp 第 33 行定义.

◆ objects()

QList< QObject * > QxPlugin::QxPluginContext::objects ( ) const

Everything published by any plugin and still alive, in publication order.

在文件 qxplugincontext.cpp 第 28 行定义.

◆ removeObject()

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 行定义.

◆ setBusy()

virtual void QxPlugin::QxPluginContext::setBusy ( bool  busy)
pure virtual

Shows or hides the host's indeterminate "working" indicator.

◆ setCurrentPage()

virtual void QxPlugin::QxPluginContext::setCurrentPage ( const QString &  id)
pure virtual

Brings the page registered under id to the front.

Unknown id: no-op.

◆ setProgress()

virtual void QxPlugin::QxPluginContext::setProgress ( int  value)
pure virtual

Shows how far the work has got, clamped to the range set by setProgressRange().

◆ setProgressRange()

virtual void QxPlugin::QxPluginContext::setProgressRange ( int  minimum,
int  maximum 
)
pure virtual

Sets the range the progress runs in; maximum must be above minimum.

◆ setStatusMessage()

virtual void QxPlugin::QxPluginContext::setStatusMessage ( const QString &  message)
pure virtual

Replaces the host's persistent status-line message.

◆ settings()

virtual QxCore::QxSettings * QxPlugin::QxPluginContext::settings ( ) const
pure virtual

The settings object backing persistence; never null.

◆ showToast()

virtual void QxPlugin::QxPluginContext::showToast ( const QString &  text,
ToastLevel  level = ToastLevel::Information,
int  timeoutMs = -1 
)
pure virtual

Shows a toast over the host; timeoutMs < 0 means the host's default.

类成员变量说明

◆ m_pool

QxObjectPool* QxPlugin::QxPluginContext::m_pool = Q_NULLPTR
protected

The host's pool, or null when the host offers none.

Owned by the host.

在文件 qxplugincontext.h 第 155 行定义.


该类的文档由以下文件生成: