kexi
kexibooltableedit.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kexibooltableedit.h"
00021
00022 #include <kexidb/field.h>
00023
00024 #include <qpainter.h>
00025
00026 #include <kglobal.h>
00027 #include <klocale.h>
00028 #include <kdebug.h>
00029 #include <kglobalsettings.h>
00030
00031
00032 KexiBoolTableEdit::KexiBoolTableEdit(KexiTableViewColumn &column, QScrollView *parent)
00033 : KexiTableEdit(column, parent, "KexiBoolTableEdit")
00034 {
00035 init();
00036 }
00037
00038 KexiBoolTableEdit::~KexiBoolTableEdit()
00039 {
00040 }
00041
00042 void KexiBoolTableEdit::init()
00043 {
00044 kdDebug() << "KexiBoolTableEdit: m_origValue.typeName()==" << m_origValue.typeName() << endl;
00045 kdDebug() << "KexiBoolTableEdit: type== " << field()->typeName() << endl;
00046
00047 m_hasFocusableWidget = false;
00048 }
00049
00050 void KexiBoolTableEdit::setValueInternal(const QVariant& , bool )
00051 {
00052 m_currentValue = m_origValue;
00053
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063 bool KexiBoolTableEdit::valueIsNull()
00064 {
00065 return m_currentValue.isNull();
00066 }
00067
00068 bool KexiBoolTableEdit::valueIsEmpty()
00069 {
00070 return m_currentValue.isNull();
00071 }
00072
00073 QVariant KexiBoolTableEdit::value()
00074 {
00075
00076 return m_currentValue;
00077 }
00078
00079 void KexiBoolTableEdit::clear()
00080 {
00081 m_currentValue = QVariant();
00082 }
00083
00084 bool KexiBoolTableEdit::cursorAtStart()
00085 {
00086 return true;
00087 }
00088
00089 bool KexiBoolTableEdit::cursorAtEnd()
00090 {
00091 return true;
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101 void KexiBoolTableEdit::setupContents( QPainter *p, bool , QVariant val,
00102 QString &, int &, int &, int &y_offset, int &w, int &h )
00103 {
00104 #ifdef Q_WS_WIN
00105
00106 y_offset = -1;
00107 #else
00108
00109 y_offset = 0;
00110 #endif
00111 int s = QMAX(h - 5, 12);
00112 s = QMIN( h-3, s );
00113 s = QMIN( w-3, s );
00114
00115 QRect r( QMAX( w/2 - s/2, 0 ) , h/2 - s/2 , s, s);
00116 p->setPen(QPen(colorGroup().text(), 1));
00117 p->drawRect(r);
00118 if (val.asBool()) {
00119 p->drawLine(r.x(), r.y(), r.right(), r.bottom());
00120 p->drawLine(r.x(), r.bottom(), r.right(), r.y());
00121
00122
00123 }
00124 }
00125
00126 void KexiBoolTableEdit::clickedOnContents()
00127 {
00128 m_currentValue = QVariant( !m_currentValue.toBool(), 0 );
00129 }
00130
00131
00132
00133 KexiBoolEditorFactoryItem::KexiBoolEditorFactoryItem()
00134 {
00135 }
00136
00137 KexiBoolEditorFactoryItem::~KexiBoolEditorFactoryItem()
00138 {
00139 }
00140
00141 KexiTableEdit* KexiBoolEditorFactoryItem::createEditor(
00142 KexiTableViewColumn &column, QScrollView* parent)
00143 {
00144 return new KexiBoolTableEdit(column, parent);
00145 }
00146
00147 #include "kexibooltableedit.moc"
00148
|