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 "metadatabase_p.h"
32
#include <QtDesigner/QtDesigner>
35
#include <QtCore/qalgorithms.h>
36
#include <QtCore/qdebug.h>
38
MetaDataBaseItem::MetaDataBaseItem(QObject *object)
44
MetaDataBaseItem::~MetaDataBaseItem()
48
QString MetaDataBaseItem::name() const
51
return m_object->objectName();
54
void MetaDataBaseItem::setName(const QString &name)
57
m_object->setObjectName(name);
60
QList<QWidget*> MetaDataBaseItem::tabOrder() const
65
void MetaDataBaseItem::setTabOrder(const QList<QWidget*> &tabOrder)
67
m_tabOrder = tabOrder;
70
bool MetaDataBaseItem::enabled() const
75
void MetaDataBaseItem::setEnabled(bool b)
80
// -----------------------------------------------------
81
MetaDataBase::MetaDataBase(QDesignerFormEditorInterface *core, QObject *parent)
82
: QDesignerMetaDataBaseInterface(parent),
87
MetaDataBase::~MetaDataBase()
92
QDesignerMetaDataBaseItemInterface *MetaDataBase::item(QObject *object) const
94
MetaDataBaseItem *i = m_items.value(object);
95
if (i == 0 || !i->enabled())
100
void MetaDataBase::add(QObject *object)
102
MetaDataBaseItem *i = m_items.value(object);
103
if (i != 0 && !i->enabled()) {
108
m_items.insert(object, new MetaDataBaseItem(object));
109
connect(object, SIGNAL(destroyed(QObject*)),
110
this, SLOT(slotDestroyed(QObject*)));
112
core()->widgetFactory()->initialize(object);
117
void MetaDataBase::remove(QObject *object)
121
if (MetaDataBaseItem *item = m_items.value(object)) {
122
item->setEnabled(false);
127
QList<QObject*> MetaDataBase::objects() const
129
QList<QObject*> result;
131
ItemMap::const_iterator it = m_items.begin();
132
for (; it != m_items.end(); ++it) {
133
if (it.value()->enabled())
134
result.append(it.key());
140
QDesignerFormEditorInterface *MetaDataBase::core() const
145
void MetaDataBase::slotDestroyed(QObject *object)
147
if (m_items.contains(object)) {
148
MetaDataBaseItem *item = m_items.value(object);
150
m_items.remove(object);