1
/* This file is part of the KDE project
2
Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this program; see the file COPYING. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
20
#include "kexibooltableedit.h"
22
#include <kexidb/field.h>
29
#include <kglobalsettings.h>
32
KexiBoolTableEdit::KexiBoolTableEdit(KexiTableViewColumn &column, QScrollView *parent)
33
: KexiTableEdit(column, parent, "KexiBoolTableEdit")
38
KexiBoolTableEdit::~KexiBoolTableEdit()
42
void KexiBoolTableEdit::init()
44
kdDebug() << "KexiBoolTableEdit: m_origValue.typeName()==" << m_origValue.typeName() << endl;
45
kdDebug() << "KexiBoolTableEdit: type== " << field()->typeName() << endl;
47
m_hasFocusableWidget = false;
50
void KexiBoolTableEdit::setValueInternal(const QVariant& /*add*/, bool /*removeOld*/)
52
m_currentValue = m_origValue;
53
//nothing to do more...
56
/*bool KexiBoolTableEdit::valueChanged()
58
if (m_lineedit->text()!=m_origText)
60
return KexiTableEdit::valueChanged();
63
bool KexiBoolTableEdit::valueIsNull()
65
return m_currentValue.isNull();
68
bool KexiBoolTableEdit::valueIsEmpty()
70
return m_currentValue.isNull();
73
QVariant KexiBoolTableEdit::value()
76
return m_currentValue;
79
void KexiBoolTableEdit::clear()
81
m_currentValue = QVariant();
84
bool KexiBoolTableEdit::cursorAtStart()
89
bool KexiBoolTableEdit::cursorAtEnd()
94
/*QSize KexiBoolTableEdit::totalSize()
98
return m_lineedit->size();
101
void KexiBoolTableEdit::setupContents( QPainter *p, bool /*focused*/, QVariant val,
102
QString &/*txt*/, int &/*align*/, int &/*x*/, int &y_offset, int &w, int &h )
111
int s = QMAX(h - 5, 12);
113
s = QMIN( w-3, s );//avoid too large box
114
// QRect r(w/2 - s/2 + x, h/2 - s/2 - 1, s, s);
115
QRect r( QMAX( w/2 - s/2, 0 ) , h/2 - s/2 /*- 1*/, s, s);
116
p->setPen(QPen(colorGroup().text(), 1));
119
p->drawLine(r.x(), r.y(), r.right(), r.bottom());
120
p->drawLine(r.x(), r.bottom(), r.right(), r.y());
121
// p->drawLine(r.x() + 2, r.y() + 2, r.right() - 1, r.bottom() - 1);
122
// p->drawLine(r.x() + 2, r.bottom() - 2, r.right() - 1, r.y() + 1);
126
void KexiBoolTableEdit::clickedOnContents()
128
m_currentValue = QVariant( !m_currentValue.toBool(), 0 );
131
//======================================================
133
KexiBoolEditorFactoryItem::KexiBoolEditorFactoryItem()
137
KexiBoolEditorFactoryItem::~KexiBoolEditorFactoryItem()
141
KexiTableEdit* KexiBoolEditorFactoryItem::createEditor(
142
KexiTableViewColumn &column, QScrollView* parent)
144
return new KexiBoolTableEdit(column, parent);
147
#include "kexibooltableedit.moc"