kexi

kexidbdoublespinbox.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004-2005 Jaroslaw Staniek <js@iidea.pl>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "kexidbdoublespinbox.h"
22
23#include <tqlineedit.h>
24
25KexiDBDoubleSpinBox::KexiDBDoubleSpinBox(TQWidget *parent, const char *name)
26 : KDoubleSpinBox(parent, name) , KexiFormDataItemInterface()
27{
28 connect(this, TQ_SIGNAL(valueChanged(double)), this, TQ_SLOT(slotValueChanged()));
29}
30
31KexiDBDoubleSpinBox::~KexiDBDoubleSpinBox()
32{
33}
34
35void KexiDBDoubleSpinBox::setInvalidState( const TQString& displayText )
36{
37 m_invalidState = true;
38 setEnabled(false);
39 setReadOnly(true);
41 if (focusPolicy() & TabFocus)
42 setFocusPolicy(TQWidget::ClickFocus);
43 setSpecialValueText(displayText);
44 KDoubleSpinBox::setValue(minValue());
45}
46
47void
48KexiDBDoubleSpinBox::setEnabled(bool enabled)
49{
50 // prevent the user from reenabling the widget when it is in invalid state
51 if(enabled && m_invalidState)
52 return;
53 KDoubleSpinBox::setEnabled(enabled);
54}
55
56void KexiDBDoubleSpinBox::setValueInternal(const TQVariant&, bool )
57{
58 KDoubleSpinBox::setValue(m_origValue.toDouble());
59}
60
61TQVariant
63{
64 return KDoubleSpinBox::value();
65}
66
67void KexiDBDoubleSpinBox::slotValueChanged()
68{
70}
71
73{
74 return cleanText().isEmpty();
75}
76
78{
79 return false;
80}
81
83{
84 return editor()->isReadOnly();
85}
86
87void KexiDBDoubleSpinBox::setReadOnly(bool set)
88{
89 editor()->setReadOnly(set);
90}
91
92TQWidget*
94{
95 return this;
96}
97
99{
100 return false;
101}
102
104{
105 return false;
106}
107
109{
110 KDoubleSpinBox::setValue(minValue());
111}
112
113#include "kexidbdoublespinbox.moc"
virtual TQVariant value()
virtual bool isReadOnly() const
virtual void setValueInternal(const TQVariant &add, bool removeOld)
virtual void setInvalidState(const TQString &displayText)
virtual void clear()
clears item's data, so the data will contain NULL data
virtual TQWidget * widget()
An interface for declaring form widgets to be data-aware.