1
/****************************************************************************
3
** Copyright (C) 2005-2005 Trolltech AS. All rights reserved.
5
** This file is part of the designer application of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#include "qdesigner_promotedwidget_p.h"
31
#include <QtDesigner/QExtensionManager>
33
#include <QtGui/QVBoxLayout>
34
#include <QtCore/QEvent>
35
#include <QtCore/QVariant>
36
#include <QtCore/qdebug.h>
38
PromotedWidgetPropertySheet::PromotedWidgetPropertySheet(QDesignerPromotedWidget *promoted,
39
QExtensionManager *extension_manager, QObject *parent)
42
m_promoted = promoted;
43
QWidget *child = promoted->child();
44
m_sheet = qt_extension<QDesignerPropertySheetExtension*>(extension_manager, child);
47
PromotedWidgetPropertySheet::~PromotedWidgetPropertySheet()
51
int PromotedWidgetPropertySheet::count() const
53
return m_sheet->count();
56
int PromotedWidgetPropertySheet::indexOf(const QString &name) const
58
return m_sheet->indexOf(name);
61
QString PromotedWidgetPropertySheet::propertyName(int index) const
63
return m_sheet->propertyName(index);
66
QString PromotedWidgetPropertySheet::propertyGroup(int index) const
68
return m_sheet->propertyGroup(index);
71
void PromotedWidgetPropertySheet::setPropertyGroup(int index, const QString &group)
73
m_sheet->setPropertyGroup(index, group);
76
bool PromotedWidgetPropertySheet::hasReset(int index) const
78
return m_sheet->hasReset(index);
81
bool PromotedWidgetPropertySheet::reset(int index)
83
return m_sheet->reset(index);
86
bool PromotedWidgetPropertySheet::isVisible(int index) const
88
return m_sheet->isVisible(index);
91
void PromotedWidgetPropertySheet::setVisible(int index, bool b)
93
m_sheet->setVisible(index, b);
96
bool PromotedWidgetPropertySheet::isAttribute(int index) const
98
return m_sheet->isAttribute(index);
101
void PromotedWidgetPropertySheet::setAttribute(int index, bool b)
103
m_sheet->setAttribute(index, b);
106
QVariant PromotedWidgetPropertySheet::property(int index) const
110
QString name = propertyName(index);
111
if (name == QLatin1String("geometry")) {
112
result = m_promoted->geometry();
114
result = m_sheet->property(index);
120
void PromotedWidgetPropertySheet::setProperty(int index, const QVariant &value)
122
QString name = propertyName(index);
123
if (name == QLatin1String("geometry")) {
124
if (value.type() == QVariant::Rect)
125
m_promoted->setGeometry(value.toRect());
127
m_sheet->setProperty(index, value);
131
bool PromotedWidgetPropertySheet::isChanged(int index) const
133
return m_sheet->isChanged(index);
136
void PromotedWidgetPropertySheet::setChanged(int index, bool changed)
138
m_sheet->setChanged(index, changed);
141
PromotedWidgetPropertySheetFactory::PromotedWidgetPropertySheetFactory(QExtensionManager *parent)
142
: QExtensionFactory(parent)
146
QObject *PromotedWidgetPropertySheetFactory::createExtension(QObject *object,
147
const QString &iid, QObject *parent) const
149
if (iid != Q_TYPEID(QDesignerPropertySheetExtension))
151
QDesignerPromotedWidget *promoted = qobject_cast<QDesignerPromotedWidget*>(object);
154
return new PromotedWidgetPropertySheet(promoted,
155
qobject_cast<QExtensionManager*>(this->parent()),
159
QDesignerPromotedWidget::QDesignerPromotedWidget(QDesignerWidgetDataBaseItemInterface *item, QWidget *parent)
160
: QWidget(parent), m_child(0)
162
(new QVBoxLayout(this))->setMargin(0);
165
m_custom_class_name = item->name().toUtf8();
168
QDesignerPromotedWidget::~QDesignerPromotedWidget()
172
void QDesignerPromotedWidget::setChildWidget(QWidget *widget)
175
layout()->removeWidget(m_child);
176
m_child->setSizePolicy(sizePolicy());
177
m_child->setParent(0);
183
m_child->setParent(this);
184
setSizePolicy(m_child->sizePolicy());
185
m_child->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
186
layout()->addWidget(m_child);
190
QSize QDesignerPromotedWidget::sizeHint() const
194
return m_child->sizeHint();
197
QSize QDesignerPromotedWidget::minimumSizeHint() const
201
return m_child->minimumSizeHint();