~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/designer/src/components/formeditor/default_layoutdecoration.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the designer application of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include "default_layoutdecoration.h"
 
30
#include "formwindow.h"
 
31
#include "qlayout_widget_p.h"
 
32
#include "qdesigner_widget_p.h"
 
33
 
 
34
#include <QtGui/QGridLayout>
 
35
#include <QtCore/qdebug.h>
 
36
 
 
37
using namespace qdesigner_internal;
 
38
 
 
39
// ---- QDesignerLayoutDecoration ----
 
40
QDesignerLayoutDecoration::QDesignerLayoutDecoration(QLayoutWidget *widget, QObject *parent)
 
41
    : QObject(parent),
 
42
      m_layoutSupport(widget->support())
 
43
{
 
44
    Q_ASSERT(m_layoutSupport);
 
45
}
 
46
 
 
47
QDesignerLayoutDecoration::QDesignerLayoutDecoration(FormWindow *formWindow, QWidget *widget, QObject *parent)
 
48
    : QObject(parent),
 
49
      m_layoutSupport(new QLayoutSupport(formWindow, widget, this))
 
50
{
 
51
    Q_ASSERT(m_layoutSupport);
 
52
}
 
53
 
 
54
QDesignerLayoutDecoration::~QDesignerLayoutDecoration()
 
55
{
 
56
}
 
57
 
 
58
QList<QWidget*> QDesignerLayoutDecoration::widgets(QLayout *layout) const
 
59
{
 
60
    return m_layoutSupport->widgets(layout);
 
61
}
 
62
 
 
63
QRect QDesignerLayoutDecoration::itemInfo(int index) const
 
64
{
 
65
    return m_layoutSupport->itemInfo(index);
 
66
}
 
67
 
 
68
int QDesignerLayoutDecoration::indexOf(QWidget *widget) const
 
69
{
 
70
    return m_layoutSupport->indexOf(widget);
 
71
}
 
72
 
 
73
int QDesignerLayoutDecoration::indexOf(QLayoutItem *item) const
 
74
{
 
75
    return m_layoutSupport->indexOf(item);
 
76
}
 
77
 
 
78
QDesignerLayoutDecoration::InsertMode QDesignerLayoutDecoration::currentInsertMode() const
 
79
{
 
80
    return m_layoutSupport->currentInsertMode();
 
81
}
 
82
 
 
83
void QDesignerLayoutDecoration::insertWidget(QWidget *widget, const QPair<int, int> &cell)
 
84
{
 
85
    m_layoutSupport->insertWidget(widget, cell);
 
86
}
 
87
 
 
88
void QDesignerLayoutDecoration::removeWidget(QWidget *widget)
 
89
{
 
90
    m_layoutSupport->removeWidget(widget);
 
91
}
 
92
 
 
93
void QDesignerLayoutDecoration::insertRow(int row)
 
94
{
 
95
    m_layoutSupport->insertRow(row);
 
96
}
 
97
 
 
98
void QDesignerLayoutDecoration::insertColumn(int column)
 
99
{
 
100
    m_layoutSupport->insertColumn(column);
 
101
}
 
102
 
 
103
void QDesignerLayoutDecoration::simplify()
 
104
{
 
105
    m_layoutSupport->simplifyLayout();
 
106
}
 
107
 
 
108
int QDesignerLayoutDecoration::currentIndex() const
 
109
{
 
110
    return m_layoutSupport->currentIndex();
 
111
}
 
112
 
 
113
QPair<int, int> QDesignerLayoutDecoration::currentCell() const
 
114
{
 
115
    return m_layoutSupport->currentCell();
 
116
}
 
117
 
 
118
int QDesignerLayoutDecoration::findItemAt(const QPoint &pos) const
 
119
{
 
120
    return m_layoutSupport->findItemAt(pos);
 
121
}
 
122
 
 
123
int QDesignerLayoutDecoration::findItemAt(int row, int column) const
 
124
{
 
125
    return m_layoutSupport->findItemAt(row, column);
 
126
}
 
127
 
 
128
void QDesignerLayoutDecoration::adjustIndicator(const QPoint &pos, int index)
 
129
{
 
130
    m_layoutSupport->adjustIndicator(pos, index);
 
131
}
 
132
 
 
133
// ---- QDesignerLayoutDecorationFactory ----
 
134
QDesignerLayoutDecorationFactory::QDesignerLayoutDecorationFactory(QExtensionManager *parent)
 
135
    : QExtensionFactory(parent)
 
136
{
 
137
}
 
138
 
 
139
QObject *QDesignerLayoutDecorationFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const
 
140
{
 
141
    if (iid != Q_TYPEID(QDesignerLayoutDecorationExtension))
 
142
        return 0;
 
143
 
 
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;
 
150
        }
 
151
    }
 
152
 
 
153
    return 0;
 
154
}