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;
00030 setTristate(true);
00031 connect(this, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int)));
00032 }
00033
00034 KexiDBCheckBox::~KexiDBCheckBox()
00035 {
00036 }
00037
00038 void KexiDBCheckBox::setInvalidState( const QString& displayText )
00039 {
00040 setEnabled(false);
00041 setState(NoChange);
00042 m_invalidState = true;
00044 if (focusPolicy() & TabFocus)
00045 setFocusPolicy(QWidget::ClickFocus);
00046 setText(displayText);
00047 }
00048
00049 void
00050 KexiDBCheckBox::setEnabled(bool enabled)
00051 {
00052 if(enabled && m_invalidState)
00053 return;
00054 QCheckBox::setEnabled(enabled);
00055 }
00056
00057 void KexiDBCheckBox::setValueInternal(const QVariant &add, bool )
00058 {
00059 setState( add.isNull() ? NoChange : (add.toBool() ? On : Off) );
00060 }
00061
00062 QVariant
00063 KexiDBCheckBox::value()
00064 {
00065 return QVariant( isChecked(), 3 );
00066 }
00067
00068 void KexiDBCheckBox::slotStateChanged(int )
00069 {
00070 signalValueChanged();
00071 }
00072
00073 bool KexiDBCheckBox::valueIsNull()
00074 {
00075 return state() == NoChange;
00076 }
00077
00078 bool KexiDBCheckBox::valueIsEmpty()
00079 {
00080 return false;
00081 }
00082
00083 bool KexiDBCheckBox::isReadOnly() const
00084 {
00085 return !isEnabled();
00086 }
00087
00088 QWidget*
00089 KexiDBCheckBox::widget()
00090 {
00091 return this;
00092 }
00093
00094 bool KexiDBCheckBox::cursorAtStart()
00095 {
00096 return false;
00097 }
00098
00099 bool KexiDBCheckBox::cursorAtEnd()
00100 {
00101 return false;
00102 }
00103
00104 void KexiDBCheckBox::clear()
00105 {
00106 setState(NoChange);
00107 }
00108
00109 #include "kexidbcheckbox.moc"
|