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
listwidgeteditor.cpp
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
#
include
"listwidgeteditor.h"
6
#
include
<
designerpropertymanager
.
h
>
7
#
include
<
abstractformbuilder
.
h
>
8
9
#
include
<
QtDesigner
/
abstractsettings
.
h
>
10
#
include
<
QtDesigner
/
abstractformeditor
.
h
>
11
12
#
include
<
QtWidgets
/
qcombobox
.
h
>
13
#
include
<
QtWidgets
/
qgroupbox
.
h
>
14
#
include
<
QtWidgets
/
qdialogbuttonbox
.
h
>
15
16
QT_BEGIN_NAMESPACE
17
18
namespace
qdesigner_internal
{
19
20
ListWidgetEditor
::ListWidgetEditor(QDesignerFormWindowInterface *form,
21
QWidget
*parent)
22
: QDialog(parent)
23
{
24
QDialogButtonBox *buttonBox =
new
QDialogButtonBox;
25
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
26
connect(buttonBox, &QDialogButtonBox::accepted,
this
, &QDialog::accept);
27
connect(buttonBox, &QDialogButtonBox::rejected,
this
, &QDialog::reject);
28
29
m_itemsEditor =
new
ItemListEditor(form,
nullptr
);
30
m_itemsEditor->layout()->setContentsMargins(QMargins());
31
m_itemsEditor->setNewItemText(tr(
"New Item"
));
32
33
QFrame *sep =
new
QFrame;
34
sep->setFrameStyle(QFrame::HLine | QFrame::Sunken);
35
36
QBoxLayout *box =
new
QVBoxLayout(
this
);
37
box->addWidget(m_itemsEditor);
38
box->addWidget(sep);
39
box->addWidget(buttonBox);
40
41
// Numbers copied from itemlisteditor.ui
42
// (Automatic resizing doesn't work because ui has parent).
43
resize(550, 360);
44
}
45
46
static
AbstractItemEditor
::
PropertyDefinition
listBoxPropList
[] = {
47
{
Qt
::
DisplayPropertyRole
, 0,
DesignerPropertyManager
::
designerStringTypeId
,
"text"
},
48
{
Qt
::
DecorationPropertyRole
, 0,
DesignerPropertyManager
::
designerIconTypeId
,
"icon"
},
49
{
Qt
::
ToolTipPropertyRole
, 0,
DesignerPropertyManager
::
designerStringTypeId
,
"toolTip"
},
50
{
Qt
::
StatusTipPropertyRole
, 0,
DesignerPropertyManager
::
designerStringTypeId
,
"statusTip"
},
51
{
Qt
::
WhatsThisPropertyRole
, 0,
DesignerPropertyManager
::
designerStringTypeId
,
"whatsThis"
},
52
{
Qt
::
FontRole
,
QMetaType
::
QFont
,
nullptr
,
"font"
},
53
{
Qt
::
TextAlignmentRole
, 0,
DesignerPropertyManager
::
designerAlignmentTypeId
,
"textAlignment"
},
54
{
Qt
::
BackgroundRole
,
QMetaType
::
QBrush
,
nullptr
,
"background"
},
55
{
Qt
::
ForegroundRole
,
QMetaType
::
QBrush
,
nullptr
,
"foreground"
},
56
{
ItemFlagsShadowRole
, 0,
QtVariantPropertyManager
::
flagTypeId
,
"flags"
},
57
{
Qt
::
CheckStateRole
, 0,
QtVariantPropertyManager
::
enumTypeId
,
"checkState"
},
58
{ 0, 0,
nullptr
,
nullptr
}
59
};
60
61
ListContents
ListWidgetEditor
::
fillContentsFromListWidget
(QListWidget *listWidget)
62
{
63
setWindowTitle(tr(
"Edit List Widget"
));
64
65
ListContents
retVal;
66
retVal.createFromListWidget(listWidget,
false
);
67
retVal.applyToListWidget(m_itemsEditor->listWidget(), m_itemsEditor->iconCache(),
true
);
68
69
m_itemsEditor->setupEditor(listWidget,
listBoxPropList
);
70
71
return
retVal;
72
}
73
74
static
AbstractItemEditor
::
PropertyDefinition
comboBoxPropList
[] = {
75
{
Qt
::
DisplayPropertyRole
, 0,
DesignerPropertyManager
::
designerStringTypeId
,
"text"
},
76
{
Qt
::
DecorationPropertyRole
, 0,
DesignerPropertyManager
::
designerIconTypeId
,
"icon"
},
77
{ 0, 0,
nullptr
,
nullptr
}
78
};
79
80
ListContents
ListWidgetEditor
::
fillContentsFromComboBox
(QComboBox *comboBox)
81
{
82
setWindowTitle(tr(
"Edit Combobox"
));
83
84
ListContents
retVal;
85
retVal.createFromComboBox(comboBox);
86
retVal.applyToListWidget(m_itemsEditor->listWidget(), m_itemsEditor->iconCache(),
true
);
87
88
m_itemsEditor->setupEditor(comboBox,
comboBoxPropList
);
89
90
return
retVal;
91
}
92
93
ListContents
ListWidgetEditor
::
contents
()
const
94
{
95
ListContents
retVal;
96
retVal.createFromListWidget(m_itemsEditor->listWidget(),
true
);
97
return
retVal;
98
}
99
100
}
// namespace qdesigner_internal
101
102
QT_END_NAMESPACE
QPainter::QWidget
friend class QWidget
Definition
qpainter.h:432
qdesigner_internal::AbstractItemEditor
Definition
itemlisteditor.h:42
qdesigner_internal::ListWidgetEditor
Definition
listwidgeteditor.h:22
qdesigner_internal::ListWidgetEditor::fillContentsFromComboBox
ListContents fillContentsFromComboBox(QComboBox *comboBox)
Definition
listwidgeteditor.cpp:80
qdesigner_internal::ListWidgetEditor::fillContentsFromListWidget
ListContents fillContentsFromListWidget(QListWidget *listWidget)
Definition
listwidgeteditor.cpp:61
qdesigner_internal::ListWidgetEditor::contents
ListContents contents() const
Definition
listwidgeteditor.cpp:93
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::listBoxPropList
static AbstractItemEditor::PropertyDefinition listBoxPropList[]
Definition
listwidgeteditor.cpp:46
qdesigner_internal::comboBoxPropList
static AbstractItemEditor::PropertyDefinition comboBoxPropList[]
Definition
listwidgeteditor.cpp:74
qdesigner_internal::AbstractItemEditor::PropertyDefinition
Definition
itemlisteditor.h:51
qdesigner_internal::ListContents
Definition
qdesigner_command_p.h:841
qttools
src
designer
src
components
taskmenu
listwidgeteditor.cpp
Generated on
for Qt by
1.18.0