kexi

kexidbintspinbox.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 "kexidbintspinbox.h"
22
23#include <tqlineedit.h>
24#include <knumvalidator.h>
25
26KexiDBIntSpinBox::KexiDBIntSpinBox(TQWidget *parent, const char *name)
27 : KIntSpinBox(parent, name) , KexiFormDataItemInterface()
28{
29 connect(this, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(slotValueChanged()));
30}
31
32KexiDBIntSpinBox::~KexiDBIntSpinBox()
33{
34}
35
36void KexiDBIntSpinBox::setInvalidState( const TQString& displayText )
37{
38 m_invalidState = true;
39 setEnabled(false);
40 setReadOnly(true);
42 if (focusPolicy() & TabFocus)
43 setFocusPolicy(TQWidget::ClickFocus);
44 setSpecialValueText(displayText);
45 KIntSpinBox::setValue(minValue());
46}
47
48void
49KexiDBIntSpinBox::setEnabled(bool enabled)
50{
51 // prevent the user from reenabling the widget when it is in invalid state
52 if(enabled && m_invalidState)
53 return;
54 KIntSpinBox::setEnabled(enabled);
55}
56
57void KexiDBIntSpinBox::setValueInternal(const TQVariant&, bool)
58{
59 KIntSpinBox::setValue(m_origValue.toInt());
60}
61
62TQVariant
64{
65 return KIntSpinBox::value();
66}
67
68void KexiDBIntSpinBox::slotValueChanged()
69{
71}
72
74{
75 return cleanText().isEmpty();
76}
77
79{
80 return false;
81}
82
84{
85 return editor()->isReadOnly();
86}
87
88void KexiDBIntSpinBox::setReadOnly(bool set)
89{
90 editor()->setReadOnly(set);
91}
92
93TQWidget*
95{
96 return this;
97}
98
100{
101 return false;
102}
103
105{
106 return false;
107}
108
110{
111 KIntSpinBox::setValue(minValue());
112}
113
114#include "kexidbintspinbox.moc"
virtual TQVariant value()
virtual bool isReadOnly() const
virtual bool cursorAtEnd()
virtual void setValueInternal(const TQVariant &add, bool removeOld)
virtual void setInvalidState(const TQString &displayText)
virtual bool valueIsNull()
virtual bool cursorAtStart()
virtual void clear()
clears item's data, so the data will contain NULL data
virtual TQWidget * widget()
virtual bool valueIsEmpty()
An interface for declaring form widgets to be data-aware.