~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/widgets/propeditor/propertywidgetproxy.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2004 by Alexander Dymo                                  *
3
 
 *   cloudtemple@mskat.net                                                 *
4
 
 *                                                                         *
5
 
 *   This program is free software; you can redistribute it and/or modify  *
6
 
 *   it under the terms of the GNU Library General Public License as       *
7
 
 *   published by the Free Software Foundation; either version 2 of the    *
8
 
 *   License, or (at your option) any later version.                       *
9
 
 *                                                                         *
10
 
 *   This program is distributed in the hope that it will be useful,       *
11
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 
 *   GNU General Public License for more details.                          *
14
 
 *                                                                         *
15
 
 *   You should have received a copy of the GNU Library General Public     *
16
 
 *   License along with this program; if not, write to the                 *
17
 
 *   Free Software Foundation, Inc.,                                       *
18
 
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19
 
 ***************************************************************************/
20
 
#include "propertywidgetproxy.h"
21
 
 
22
 
#include <qlayout.h>
23
 
 
24
 
#include "propertywidget.h"
25
 
#include "propertymachinefactory.h"
26
 
 
27
 
namespace PropertyLib{
28
 
 
29
 
PropertyWidgetProxy::PropertyWidgetProxy(QWidget *parent, const char *name)
30
 
    :QWidget(parent, name), mp(0), m_propertyType(Property::Invalid), m_editor(0)
31
 
{
32
 
    p = new Property();
33
 
    m_layout = new QHBoxLayout(this, 0, 0);
34
 
}
35
 
 
36
 
PropertyWidgetProxy::~PropertyWidgetProxy()
37
 
{
38
 
    delete mp;
39
 
    delete p;
40
 
}
41
 
 
42
 
void PropertyWidgetProxy::setPropertyType(int propertyType)
43
 
{
44
 
    m_propertyType = static_cast<PropertyType>(propertyType);
45
 
    setWidget();
46
 
}
47
 
 
48
 
void PropertyWidgetProxy::setPropertyType2(PropertyType propertyType)
49
 
{
50
 
    m_propertyType = propertyType;
51
 
    setWidget();
52
 
}
53
 
 
54
 
void PropertyWidgetProxy::setWidget()
55
 
{
56
 
    if (m_editor)
57
 
        delete m_editor;
58
 
    p->setType(m_propertyType);
59
 
    mp = new MultiProperty(p);
60
 
    m_editor = PropertyMachineFactory::getInstance()->machineForProperty(mp)->propertyEditor;
61
 
    if (m_editor)
62
 
    {
63
 
        m_editor->reparent(this, QPoint(0,0), true);
64
 
        m_layout->addWidget(m_editor);
65
 
    }
66
 
}
67
 
 
68
 
QVariant PropertyWidgetProxy::value() const
69
 
{
70
 
    if (m_editor)
71
 
        return m_editor->value();
72
 
    else
73
 
        return QVariant();
74
 
}
75
 
 
76
 
void PropertyWidgetProxy::setValue(const QVariant &value)
77
 
{
78
 
    if (m_editor)
79
 
        m_editor->setValue(value, false);
80
 
}
81
 
 
82
 
bool PropertyWidgetProxy::setProperty( const char * name, const QVariant & value )
83
 
{
84
 
        if( strcmp( name, "value") == 0 )
85
 
        {
86
 
                setPropertyType((int) value.type() );
87
 
                setValue( value );
88
 
                return true;
89
 
        }
90
 
        else
91
 
                return QWidget::setProperty(name, value);
92
 
}
93
 
 
94
 
QVariant PropertyWidgetProxy::property( const char * name ) const
95
 
{
96
 
        if( strcmp( name, "value") == 0 )
97
 
                return value(  );
98
 
        else
99
 
                return QWidget::property(name);
100
 
}
101
 
 
102
 
}
103
 
 
104
 
#ifndef PURE_QT
105
 
#include "propertywidgetproxy.moc"
106
 
#endif