1
/****************************************************************************
3
** Copyright (C) 1992-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 "default_layoutdecoration.h"
30
#include "formwindow.h"
31
#include "qlayout_widget_p.h"
32
#include "qdesigner_widget_p.h"
34
#include <QtGui/QGridLayout>
35
#include <QtCore/qdebug.h>
37
using namespace qdesigner_internal;
39
// ---- QDesignerLayoutDecoration ----
40
QDesignerLayoutDecoration::QDesignerLayoutDecoration(QLayoutWidget *widget, QObject *parent)
42
m_layoutSupport(widget->support())
44
Q_ASSERT(m_layoutSupport);
47
QDesignerLayoutDecoration::QDesignerLayoutDecoration(FormWindow *formWindow, QWidget *widget, QObject *parent)
49
m_layoutSupport(new QLayoutSupport(formWindow, widget, this))
51
Q_ASSERT(m_layoutSupport);
54
QDesignerLayoutDecoration::~QDesignerLayoutDecoration()
58
QList<QWidget*> QDesignerLayoutDecoration::widgets(QLayout *layout) const
60
return m_layoutSupport->widgets(layout);
63
QRect QDesignerLayoutDecoration::itemInfo(int index) const
65
return m_layoutSupport->itemInfo(index);
68
int QDesignerLayoutDecoration::indexOf(QWidget *widget) const
70
return m_layoutSupport->indexOf(widget);
73
int QDesignerLayoutDecoration::indexOf(QLayoutItem *item) const
75
return m_layoutSupport->indexOf(item);
78
QDesignerLayoutDecoration::InsertMode QDesignerLayoutDecoration::currentInsertMode() const
80
return m_layoutSupport->currentInsertMode();
83
void QDesignerLayoutDecoration::insertWidget(QWidget *widget, const QPair<int, int> &cell)
85
m_layoutSupport->insertWidget(widget, cell);
88
void QDesignerLayoutDecoration::removeWidget(QWidget *widget)
90
m_layoutSupport->removeWidget(widget);
93
void QDesignerLayoutDecoration::insertRow(int row)
95
m_layoutSupport->insertRow(row);
98
void QDesignerLayoutDecoration::insertColumn(int column)
100
m_layoutSupport->insertColumn(column);
103
void QDesignerLayoutDecoration::simplify()
105
m_layoutSupport->simplifyLayout();
108
int QDesignerLayoutDecoration::currentIndex() const
110
return m_layoutSupport->currentIndex();
113
QPair<int, int> QDesignerLayoutDecoration::currentCell() const
115
return m_layoutSupport->currentCell();
118
int QDesignerLayoutDecoration::findItemAt(const QPoint &pos) const
120
return m_layoutSupport->findItemAt(pos);
123
int QDesignerLayoutDecoration::findItemAt(int row, int column) const
125
return m_layoutSupport->findItemAt(row, column);
128
void QDesignerLayoutDecoration::adjustIndicator(const QPoint &pos, int index)
130
m_layoutSupport->adjustIndicator(pos, index);
133
// ---- QDesignerLayoutDecorationFactory ----
134
QDesignerLayoutDecorationFactory::QDesignerLayoutDecorationFactory(QExtensionManager *parent)
135
: QExtensionFactory(parent)
139
QObject *QDesignerLayoutDecorationFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const
141
if (iid != Q_TYPEID(QDesignerLayoutDecorationExtension))
144
if (QLayoutWidget *widget = qobject_cast<QLayoutWidget*>(object)) {
145
return new QDesignerLayoutDecoration(widget, parent);
146
} else if (QWidget *widget = qobject_cast<QWidget*>(object)) {
147
if (FormWindow *fw = FormWindow::findFormWindow(widget)) {
148
QDesignerMetaDataBaseItemInterface *item = fw->core()->metaDataBase()->item(widget->layout());
149
return item ? new QDesignerLayoutDecoration(fw, widget, parent) : 0;