Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
extensionfactory_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
// Qt-Security score:significant reason:default
4
5
//
6
// W A R N I N G
7
// -------------
8
//
9
// This file is not part of the Qt API. It exists for the convenience
10
// of Qt Designer. This header
11
// file may change from version to version without notice, or even be removed.
12
//
13
// We mean it.
14
//
15
16
#
ifndef
SHARED_EXTENSIONFACTORY_H
17
#
define
SHARED_EXTENSIONFACTORY_H
18
19
#
include
<
QtDesigner
/
default_extensionfactory
.
h
>
20
#
include
<
QtDesigner
/
qextensionmanager
.
h
>
21
22
QT_BEGIN_NAMESPACE
23
24
namespace
qdesigner_internal {
25
26
// Extension factory for registering an extension for an object type.
27
template
<
class
ExtensionInterface,
class
Object,
class
Extension>
28
class
ExtensionFactory:
public
QExtensionFactory
29
{
30
public
:
31
explicit
ExtensionFactory(
const
QString &iid, QExtensionManager *parent =
nullptr
);
32
33
// Convenience for registering the extension. Do not use for derived classes.
34
static
void
registerExtension(QExtensionManager *mgr,
const
QString &iid);
35
36
protected
:
37
QObject *createExtension(QObject *qObject,
const
QString &iid, QObject *parent)
const
override;
38
39
private
:
40
// Can be overwritten to perform checks on the object.
41
// Default does a qobject_cast to the desired class.
42
virtual
Object *checkObject(QObject *qObject)
const
;
43
44
const
QString m_iid;
45
};
46
47
template
<
class
ExtensionInterface,
class
Object,
class
Extension>
48
ExtensionFactory<ExtensionInterface, Object, Extension>::ExtensionFactory(
const
QString &iid, QExtensionManager *parent) :
49
QExtensionFactory(parent),
50
m_iid(iid)
51
{
52
}
53
54
template
<
class
ExtensionInterface,
class
Object,
class
Extension>
55
Object *ExtensionFactory<ExtensionInterface, Object, Extension>::checkObject(QObject *qObject)
const
56
{
57
return
qobject_cast<Object*>(qObject);
58
}
59
60
template
<
class
ExtensionInterface,
class
Object,
class
Extension>
61
QObject *ExtensionFactory<ExtensionInterface, Object, Extension>::createExtension(QObject *qObject,
const
QString &iid, QObject *parent)
const
62
{
63
if
(iid != m_iid)
64
return
nullptr
;
65
66
Object *object = checkObject(qObject);
67
if
(!object)
68
return
nullptr
;
69
70
return
new
Extension(object, parent);
71
}
72
73
template
<
class
ExtensionInterface,
class
Object,
class
Extension>
74
void
ExtensionFactory<ExtensionInterface, Object, Extension>::registerExtension(QExtensionManager *mgr,
const
QString &iid)
75
{
76
auto
*factory =
new
ExtensionFactory(iid, mgr);
77
mgr->registerExtensions(factory, iid);
78
}
79
}
// namespace qdesigner_internal
80
81
QT_END_NAMESPACE
82
83
#
endif
// SHARED_EXTENSIONFACTORY_H
actionIndexAt
int actionIndexAt(const Widget *w, const QPoint &pos, Qt::Orientation orientation)
Definition
actionprovider_p.h:43
QDesignerActionProviderExtension
Definition
actionprovider_p.h:29
QDesignerActionProviderExtension::~QDesignerActionProviderExtension
virtual ~QDesignerActionProviderExtension()=default
QDesignerActionProviderExtension::actionGeometry
virtual QRect actionGeometry(QAction *action) const =0
QDesignerActionProviderExtension::actionAt
virtual QAction * actionAt(const QPoint &pos) const =0
QDesignerActionProviderExtension::adjustIndicator
virtual void adjustIndicator(const QPoint &pos)=0
QT_FORMEDITOR_EXPORT
#define QT_FORMEDITOR_EXPORT
Definition
formeditor_global.h:17
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:67
qdesigner_internal::verticalIndicatorRect
static QRect verticalIndicatorRect(const QRect &rect)
Definition
default_actionprovider.cpp:51
qdesigner_internal::horizontalIndicatorRect
static QRect horizontalIndicatorRect(const QRect &rect, Qt::LayoutDirection layoutDirection)
Definition
default_actionprovider.cpp:41
qdesigner_internal::indicatorSize
@ indicatorSize
Definition
default_actionprovider.cpp:37
qttools
src
designer
src
lib
shared
extensionfactory_p.h
Generated on
for Qt by
1.18.0