1
/* This file is part of the KDE project
2
Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at>
3
Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
4
Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this program; see the file COPYING. If not, write to
18
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA.
22
#ifndef KEXIPROPERTYEDITORITEM_H
23
#define KEXIPROPERTYEDITORITEM_H
25
#include <klistview.h>
29
#include "kexiproperty.h"
31
#define KexiPropertyEditorItem_BranchBoxSize 9
33
/** This class is a subclass of KListViewItem which is associated to a property.
34
It also takes care of drawing custom contents.
36
//! An item in KexiPropertyEditorItem associated to a property
37
class KEXIPROPERTYEDITOR_EXPORT KexiPropertyEditorItem : public KListViewItem
40
typedef QAsciiDict<KexiPropertyEditorItem> Dict;
42
/*! Creates a KexiPropertyEditorItem child of \a parent, associated to \a property.
43
Within property editor, items are created in KexiPropertyEditor::fill(),
44
every time the buffer is updated.
45
It \a property has not desctiption set, its name (i.e. not i18n'ed) is reused.
47
KexiPropertyEditorItem(KexiPropertyEditorItem *parent, KexiProperty *property,
48
KexiPropertyEditorItem *after);
50
//! Creates KexiPropertyEditor Top Item which is necessary for drawing all branches.
51
KexiPropertyEditorItem(KListView *parent, const QString &text);
53
~KexiPropertyEditorItem();
55
//! \return item's name (ie property's name)
56
const QCString name() { return m_property->name(); }
57
//! \return item's QVariant::Type (ie property's QVariant::Type)
58
QVariant::Type type() { return m_property->type(); }
59
// //! \return item's current value
60
// QVariant value() { return m_value; }
61
// //! \return item's old value (ie property's old value)
62
// QVariant oldValue() { return m_oldvalue; }
63
//! \return a pointer to the property associated to this item.
64
KexiProperty* property() { return m_property;}
66
// //! Sets item value to \a value.
67
// void setValue(QVariant value);
68
/*! \return the composed item value.
69
This function is used by property editor to update composed items, ie items with child items.
70
It updates parent item when one of its child changes.
72
// QVariant getComposedValue();
73
/*! Updates the value of child items, when the value of the parent was changed
74
with setValue(). Used by PropertyEditor.
76
void updateChildrenValue();
78
//! \return true if the item has been modified.
79
// bool modified() { return !(m_value==m_oldvalue);}
81
/*! Updates text on of this item, for current property value.
82
If \a alsoParent is true, parent item (if present) is also updated. */
83
virtual void updateValue(bool alsoParent = true);
85
/* typedef enum ItemsOrder {
89
//! Reimplemented for sorting
90
// virtual QString key ( int column, bool ascending ) const;
91
virtual int compare( QListViewItem *i, int col, bool ascending ) const;
93
virtual void paintFocus ( QPainter * p, const QColorGroup & cg, const QRect & r );
96
/*! Reimplemented from KListViewItem to draw custom contents. Properties names are wriiten in bold if
97
modified. Also takes care of drawing borders around the cells as well as pixmaps or colors if necessary.
99
virtual void paintCell(QPainter *p, const QColorGroup & cg, int column, int width, int align);
101
/*! Reimplemented from KListViewItem to draw custom contents. It takes care of drawing the [+] and [-]
102
signs only if the item has children.
104
virtual void paintBranches(QPainter *p, const QColorGroup &cg, int w, int y, int h);
106
//! Reimplemented from KListViewItem to hide the top item.
107
virtual void setup();
109
// /*! Creates a child item based on property child named by \a name.
110
// \return the newly created child item or 0 if there is not such property child. */
111
// KexiPropertyEditorItem* createChildItem(const QString& name);
115
// QVariant m_oldvalue;
116
KexiProperty *m_property;
117
// QPtrList<KexiProperty> *m_childprop;