6#include <QtDesigner/abstractformeditor.h>
8#include <QtWidgets/qabstractitemview.h>
9#include <QtWidgets/qheaderview.h>
10#include <QtCore/qdebug.h>
14using namespace Qt::StringLiterals;
20 Property(QDesignerPropertySheetExtension *sheet,
int id)
29 QHeaderView *horizontalHeader,
30 QHeaderView *verticalHeader);
60 QHeaderView *horizontalHeader,
61 QHeaderView *verticalHeader)
64 m_propertySheet.insert(horizontalHeader,
65 qt_extension<QDesignerPropertySheetExtension*>
66 (core->extensionManager(), horizontalHeader));
68 m_propertySheet.insert(verticalHeader,
69 qt_extension<QDesignerPropertySheetExtension*>
70 (core->extensionManager(), verticalHeader));
75 if (m_realPropertyNames.isEmpty())
76 m_realPropertyNames = {
77 visibleProperty, cascadingSectionResizesProperty,
78 defaultSectionSizeProperty, highlightSectionsProperty,
79 minimumSectionSizeProperty, showSortIndicatorProperty,
80 stretchLastSectionProperty
82 return m_realPropertyNames;
86 const QString &realName)
89 QString fakeName = prefix + realName.at(0).toUpper() + realName.mid(1);
90 m_propertyNameMap.insert(fakeName, realName);
98
99
100
101
102
103
104
105
106
107
108
109
110
111
114 : QDesignerPropertySheet(treeViewObject, parent),
117 initHeaderProperties(treeViewObject->header(), u"header"_s);
121 : QDesignerPropertySheet(tableViewObject, parent),
123 tableViewObject->horizontalHeader(),
124 tableViewObject->verticalHeader()))
126 initHeaderProperties(tableViewObject->horizontalHeader(), u"horizontalHeader"_s);
127 initHeaderProperties(tableViewObject->verticalHeader(), u"verticalHeader"_s);
137 QDesignerPropertySheetExtension *headerSheet = d->m_propertySheet.value(hv);
138 Q_ASSERT(headerSheet);
139 const QString headerGroupS = headerGroup;
140 const QStringList &realPropertyNames = d->realPropertyNames();
141 for (
const QString &realPropertyName : realPropertyNames) {
142 const int headerIndex = headerSheet->indexOf(realPropertyName);
143 Q_ASSERT(headerIndex != -1);
144 const QVariant defaultValue = realPropertyName == visibleProperty ?
145 QVariant(
true) : headerSheet->property(headerIndex);
146 const QString fakePropertyName = d->fakePropertyName(prefix, realPropertyName);
147 const int fakeIndex = createFakeProperty(fakePropertyName, defaultValue);
148 d->m_propertyIdMap.insert(fakeIndex, Property(headerSheet, headerIndex));
149 setAttribute(fakeIndex,
true);
150 setPropertyGroup(fakeIndex, headerGroupS);
155
156
159 return d->m_propertyNameMap;
164 const auto it = d->m_propertyIdMap.constFind(index);
165 if (it != d->m_propertyIdMap.constEnd())
166 return it.value().m_sheet->property(it.value().m_id);
167 return QDesignerPropertySheet::property(index);
172 const auto it = d->m_propertyIdMap.find(index);
173 if (it != d->m_propertyIdMap.end()) {
174 it.value().m_sheet->setProperty(it.value().m_id, value);
176 QDesignerPropertySheet::setProperty(index, value);
182 const auto it = d->m_propertyIdMap.find(index);
183 if (it != d->m_propertyIdMap.end()) {
184 it.value().m_sheet->setChanged(it.value().m_id, changed);
186 QDesignerPropertySheet::setChanged(index, changed);
192 const auto it = d->m_propertyIdMap.constFind(index);
193 if (it != d->m_propertyIdMap.constEnd())
194 return it.value().m_sheet->isChanged(it.value().m_id);
195 return QDesignerPropertySheet::isChanged(index);
200 const auto it = d->m_propertyIdMap.constFind(index);
201 if (it != d->m_propertyIdMap.constEnd())
202 return it.value().m_sheet->hasReset(it.value().m_id);
203 return QDesignerPropertySheet::hasReset(index);
208 const auto it = d->m_propertyIdMap.find(index);
209 if (it != d->m_propertyIdMap.end()) {
210 QDesignerPropertySheetExtension *headerSheet = it.value().m_sheet;
211 const int headerIndex = it.value().m_id;
212 const bool resetRC = headerSheet->reset(headerIndex);
216 if (!resetRC && headerSheet->propertyName(headerIndex) == visibleProperty) {
217 headerSheet->setProperty(headerIndex, QVariant(
true));
218 headerSheet->setChanged(headerIndex,
false);
223 return QDesignerPropertySheet::reset(index);
Adds header fake properties to QTreeView and QTableView objects.
bool reset(int index) override
void setProperty(int index, const QVariant &value) override
QVariant property(int index) const override
void setChanged(int index, bool changed) override
bool isChanged(int index) const override
QHash< QString, QString > propertyNameMap() const
Returns the mapping of fake property names to real property names.
bool hasReset(int index) const override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static constexpr auto highlightSectionsProperty
static constexpr auto cascadingSectionResizesProperty
static constexpr auto minimumSectionSizeProperty
static constexpr auto defaultSectionSizeProperty
static constexpr auto headerGroup
static constexpr auto stretchLastSectionProperty
static constexpr auto showSortIndicatorProperty
static constexpr auto visibleProperty
QHash< QHeaderView *, QDesignerPropertySheetExtension * > m_propertySheet
QMap< int, Property > m_propertyIdMap
QStringList realPropertyNames()
QHash< QString, QString > m_propertyNameMap
QStringList m_realPropertyNames
ItemViewPropertySheetPrivate(QDesignerFormEditorInterface *core, QHeaderView *horizontalHeader, QHeaderView *verticalHeader)
QString fakePropertyName(const QString &prefix, const QString &realName)
QDesignerPropertySheetExtension * m_sheet
Property(QDesignerPropertySheetExtension *sheet, int id)