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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2002-2004 by Alexander Dymo  <cloudtemple@mskat.net>    *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU Library General Public License as       *
 
6
 *   published by the Free Software Foundation; either version 2 of the    *
 
7
 *   License, or (at your option) any later version.                       *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU Library General Public     *
 
15
 *   License along with this program; if not, write to the                 *
 
16
 *   Free Software Foundation, Inc.,                                       *
 
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
18
 ***************************************************************************/
 
19
#include "property.h"
 
20
 
 
21
#include <qstring.h>
 
22
 
 
23
namespace PropertyLib{
 
24
 
 
25
Property::Property(int type, const QString &name, const QString &description,
 
26
    const QVariant &value, bool save, bool readOnly):
 
27
    m_type(type), m_name(name), m_description(description), m_value(value), m_save(save),
 
28
    m_readOnly(readOnly), m_visible(true)
 
29
{
 
30
}
 
31
 
 
32
Property::Property(const QString &name, const QMap<QString, QVariant> &v_valueList,
 
33
    const QString &description, const QVariant &value, bool save, bool readOnly):
 
34
    valueList(v_valueList), m_type(ValueFromList), m_name(name),
 
35
    m_description(description), m_value(value), m_save(save), m_readOnly(readOnly),
 
36
    m_visible(true)
 
37
{
 
38
}
 
39
 
 
40
Property::~Property()
 
41
{
 
42
}
 
43
 
 
44
bool Property::allowSaving() const
 
45
{
 
46
   return m_save;
 
47
}
 
48
 
 
49
bool Property::operator<(const Property &prop) const
 
50
{
 
51
    if ((type() < prop.type()) && (name() < prop.name()))
 
52
        return true;
 
53
    else
 
54
        return false;
 
55
}
 
56
 
 
57
QString Property::name() const
 
58
{
 
59
    return m_name;
 
60
}
 
61
 
 
62
void Property::setName(const QString &name)
 
63
{
 
64
    m_name = name;
 
65
}
 
66
 
 
67
int Property::type() const
 
68
{
 
69
    return m_type;
 
70
}
 
71
 
 
72
void Property::setType(int type)
 
73
{
 
74
    m_type = type;
 
75
}
 
76
 
 
77
QVariant Property::value() const
 
78
{
 
79
    return m_value;
 
80
}
 
81
 
 
82
void Property::setValue(const QVariant &value, bool rememberOldValue)
 
83
{
 
84
    if (rememberOldValue)
 
85
        m_oldValue = m_value;
 
86
    else
 
87
        m_oldValue = value;
 
88
    m_value = value;
 
89
}
 
90
 
 
91
QString Property::description() const
 
92
{
 
93
    return m_description;
 
94
}
 
95
 
 
96
void Property::setDescription(const QString &description)
 
97
{
 
98
    m_description = description;
 
99
}
 
100
 
 
101
void Property::setValueList(const QMap<QString, QVariant> &v_valueList)
 
102
{
 
103
    valueList = v_valueList;
 
104
}
 
105
 
 
106
bool Property::readOnly() const
 
107
{
 
108
    return m_readOnly;
 
109
}
 
110
 
 
111
bool Property::visible() const
 
112
{
 
113
    return m_visible;
 
114
}
 
115
 
 
116
void Property::setVisible( const bool visible )
 
117
{
 
118
    m_visible = visible;
 
119
}
 
120
 
 
121
QVariant Property::oldValue() const
 
122
{
 
123
    if (m_oldValue.isNull())
 
124
        return m_value;
 
125
    else
 
126
        return m_oldValue;
 
127
}
 
128
 
 
129
}