kexi

kexidbdoublespinbox.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 "kexidbdoublespinbox.h"
00022 
00023 #include <qlineedit.h>
00024 
00025 KexiDBDoubleSpinBox::KexiDBDoubleSpinBox(QWidget *parent, const char *name)
00026  : KDoubleSpinBox(parent, name) , KexiFormDataItemInterface()
00027 {
00028     connect(this, SIGNAL(valueChanged(double)), this, SLOT(slotValueChanged()));
00029 }
00030 
00031 KexiDBDoubleSpinBox::~KexiDBDoubleSpinBox()
00032 {
00033 }
00034 
00035 void KexiDBDoubleSpinBox::setInvalidState( const QString& displayText )
00036 {
00037     m_invalidState = true;
00038     setEnabled(false);
00039     setReadOnly(true);
00041     if (focusPolicy() & TabFocus)
00042         setFocusPolicy(QWidget::ClickFocus);
00043     setSpecialValueText(displayText);
00044     KDoubleSpinBox::setValue(minValue());
00045 }
00046 
00047 void
00048 KexiDBDoubleSpinBox::setEnabled(bool enabled)
00049 {
00050      // prevent the user from reenabling the widget when it is in invalid state
00051     if(enabled && m_invalidState)
00052         return;
00053     KDoubleSpinBox::setEnabled(enabled);
00054 }
00055 
00056 void KexiDBDoubleSpinBox::setValueInternal(const QVariant&, bool )
00057 {
00058     KDoubleSpinBox::setValue(m_origValue.toDouble());
00059 }
00060 
00061 QVariant
00062 KexiDBDoubleSpinBox::value()
00063 {
00064     return KDoubleSpinBox::value();
00065 }
00066 
00067 void KexiDBDoubleSpinBox::slotValueChanged()
00068 {
00069     signalValueChanged();
00070 }
00071 
00072 bool KexiDBDoubleSpinBox::valueIsNull()
00073 {
00074     return cleanText().isEmpty();
00075 }
00076 
00077 bool KexiDBDoubleSpinBox::valueIsEmpty()
00078 {
00079     return false;
00080 }
00081 
00082 bool KexiDBDoubleSpinBox::isReadOnly() const
00083 {
00084     return editor()->isReadOnly();
00085 }
00086 
00087 void KexiDBDoubleSpinBox::setReadOnly(bool set)
00088 {
00089     editor()->setReadOnly(set);
00090 }
00091 
00092 QWidget*
00093 KexiDBDoubleSpinBox::widget()
00094 {
00095     return this;
00096 }
00097 
00098 bool KexiDBDoubleSpinBox::cursorAtStart()
00099 {
00100     return false; 
00101 }
00102 
00103 bool KexiDBDoubleSpinBox::cursorAtEnd()
00104 {
00105     return false; 
00106 }
00107 
00108 void KexiDBDoubleSpinBox::clear()
00109 {
00110     KDoubleSpinBox::setValue(minValue());
00111 }
00112 
00113 #include "kexidbdoublespinbox.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys