kexi
kexidbcheckbox.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kexidbcheckbox.h"
00022
00023 #include <kexiutils/utils.h>
00024 #include <kexidb/queryschema.h>
00025
00026 KexiDBCheckBox::KexiDBCheckBox(const QString &text, QWidget *parent, const char *name)
00027 : QCheckBox(text, parent, name), KexiFormDataItemInterface()
00028 {
00029 m_invalidState = false;
00031 setTristate(true);
00032 setFocusPolicy(QWidget::StrongFocus);
00033 connect(this, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int)));
00034 }
00035
00036 KexiDBCheckBox::~KexiDBCheckBox()
00037 {
00038 }
00039
00040 void KexiDBCheckBox::setInvalidState( const QString& displayText )
00041 {
00042 setEnabled(false);
00043 setState(NoChange);
00044 m_invalidState = true;
00046 if (focusPolicy() & TabFocus)
00047 setFocusPolicy(QWidget::ClickFocus);
00048 setText(displayText);
00049 }
00050
00051 void
00052 KexiDBCheckBox::setEnabled(bool enabled)
00053 {
00054 if(enabled && m_invalidState)
00055 return;
00056 QCheckBox::setEnabled(enabled);
00057 }
00058
00059 void KexiDBCheckBox::setValueInternal(const QVariant &add, bool )
00060 {
00061
00062 setState( m_origValue.isNull() ? NoChange : (m_origValue.toBool() ? On : Off) );
00063 }
00064
00065 QVariant
00066 KexiDBCheckBox::value()
00067 {
00068 if (state()==NoChange)
00069 return QVariant();
00070 return QVariant(state()==On, 1);
00071 }
00072
00073 void KexiDBCheckBox::slotStateChanged(int )
00074 {
00075 signalValueChanged();
00076 }
00077
00078 bool KexiDBCheckBox::valueIsNull()
00079 {
00080 return state() == NoChange;
00081 }
00082
00083 bool KexiDBCheckBox::valueIsEmpty()
00084 {
00085 return false;
00086 }
00087
00088 bool KexiDBCheckBox::isReadOnly() const
00089 {
00090 return !isEnabled();
00091 }
00092
00093 QWidget*
00094 KexiDBCheckBox::widget()
00095 {
00096 return this;
00097 }
00098
00099 bool KexiDBCheckBox::cursorAtStart()
00100 {
00101 return false;
00102 }
00103
00104 bool KexiDBCheckBox::cursorAtEnd()
00105 {
00106 return false;
00107 }
00108
00109 void KexiDBCheckBox::clear()
00110 {
00111 setState(NoChange);
00112 }
00113
00114 #include "kexidbcheckbox.moc"
|