kexi

kexidbintspinbox.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2004-2005 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this program; see the file COPYING.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "kexidbintspinbox.h"
00022 
00023 #include <qlineedit.h>
00024 #include <knumvalidator.h>
00025 
00026 KexiDBIntSpinBox::KexiDBIntSpinBox(QWidget *parent, const char *name)
00027  : KIntSpinBox(parent, name) , KexiFormDataItemInterface()
00028 {
00029     connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged()));
00030 }
00031 
00032 KexiDBIntSpinBox::~KexiDBIntSpinBox()
00033 {
00034 }
00035 
00036 void KexiDBIntSpinBox::setInvalidState( const QString& displayText )
00037 {
00038     m_invalidState = true;
00039     setEnabled(false);
00040     setReadOnly(true);
00042     if (focusPolicy() & TabFocus)
00043         setFocusPolicy(QWidget::ClickFocus);
00044     setSpecialValueText(displayText);
00045     KIntSpinBox::setValue(minValue());
00046 }
00047 
00048 void
00049 KexiDBIntSpinBox::setEnabled(bool enabled)
00050 {
00051      // prevent the user from reenabling the widget when it is in invalid state
00052     if(enabled && m_invalidState)
00053         return;
00054     KIntSpinBox::setEnabled(enabled);
00055 }
00056 
00057 void KexiDBIntSpinBox::setValueInternal(const QVariant&, bool)
00058 {
00059     KIntSpinBox::setValue(m_origValue.toInt());
00060 }
00061 
00062 QVariant
00063 KexiDBIntSpinBox::value()
00064 {
00065     return KIntSpinBox::value();
00066 }
00067 
00068 void KexiDBIntSpinBox::slotValueChanged()
00069 {
00070     signalValueChanged();
00071 }
00072 
00073 bool KexiDBIntSpinBox::valueIsNull()
00074 {
00075     return cleanText().isEmpty();
00076 }
00077 
00078 bool KexiDBIntSpinBox::valueIsEmpty()
00079 {
00080     return false;
00081 }
00082 
00083 bool KexiDBIntSpinBox::isReadOnly() const
00084 {
00085     return editor()->isReadOnly();
00086 }
00087 
00088 void KexiDBIntSpinBox::setReadOnly(bool set)
00089 {
00090     editor()->setReadOnly(set);
00091 }
00092 
00093 QWidget*
00094 KexiDBIntSpinBox::widget()
00095 {
00096     return this;
00097 }
00098 
00099 bool KexiDBIntSpinBox::cursorAtStart()
00100 {
00101     return false; 
00102 }
00103 
00104 bool KexiDBIntSpinBox::cursorAtEnd()
00105 {
00106     return false; 
00107 }
00108 
00109 void KexiDBIntSpinBox::clear()
00110 {
00111     KIntSpinBox::setValue(minValue()); 
00112 }
00113 
00114 #include "kexidbintspinbox.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys