summaryrefslogtreecommitdiff
path: root/libopie/ocheckitem.cpp
Unidiff
Diffstat (limited to 'libopie/ocheckitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/ocheckitem.cpp105
1 files changed, 0 insertions, 105 deletions
diff --git a/libopie/ocheckitem.cpp b/libopie/ocheckitem.cpp
deleted file mode 100644
index cd763c1..0000000
--- a/libopie/ocheckitem.cpp
+++ b/dev/null
@@ -1,105 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de
3**
4** This file may be distributed and/or modified under the terms of the
5** GNU Library General Public License version 2 as published by the
6** Free Software Foundation and appearing in the file LICENSE.GPL
7** included in the packaging of this file.
8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11**********************************************************************/
12
13
14#include "ocheckitem.h"
15
16/**
17 * Constructs an CheckItem with a QTable as parent
18 * and a sort key for.
19 * The sort key will be used by QTable to sort the table later
20 * @param t The parent QTable where the check item belongs
21 * @param key A sort key
22 */
23OCheckItem::OCheckItem( QTable *t, const QString &key )
24 : QTableItem( t, Never, "" ), m_checked( FALSE ), m_sortKey( key )
25{
26}
27
28/**
29 * reimplemted for internal reasons
30 * @return Returns the sort key of the Item
31 * @see QTableItem
32 */
33QString OCheckItem::key() const
34{
35 return m_sortKey;
36}
37
38/**
39 * This method can check or uncheck the item. It will
40 * call QTable to update the cell.
41 *
42 * @param b Whether to check or uncheck the item
43 */
44void OCheckItem::setChecked( bool b )
45{
46 m_checked = b;
47 table()->updateCell( row(), col() );
48}
49
50/**
51 * This will toggle the item. If it is checked it'll get
52 * unchecked by this method or vice versa.
53 */
54void OCheckItem::toggle()
55{
56 m_checked = !m_checked;
57}
58
59/**
60 * This will return the state of the item.
61 *
62 * @return Returns true if the item is checked
63 */
64bool OCheckItem::isChecked() const
65{
66 return m_checked;
67}
68
69/**
70 * @internal
71 * This paints the item
72 */
73void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr,
74 bool )
75{
76 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
77
78 int marg = ( cr.width() - BoxSize ) / 2;
79 int x = 0;
80 int y = ( cr.height() - BoxSize ) / 2;
81 p->setPen( QPen( cg.text() ) );
82 p->drawRect( x + marg, y, BoxSize, BoxSize );
83 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
84 p->setPen( darkGreen );
85 x += 1;
86 y += 1;
87 if ( m_checked ) {
88 QPointArray a( 7*2 );
89 int i, xx, yy;
90 xx = x+1+marg;
91 yy = y+2;
92 for ( i=0; i<3; i++ ) {
93 a.setPoint( 2*i, xx, yy );
94 a.setPoint( 2*i+1, xx, yy+2 );
95 xx++; yy++;
96 }
97 yy -= 2;
98 for ( i=3; i<7; i++ ) {
99 a.setPoint( 2*i, xx, yy );
100 a.setPoint( 2*i+1, xx, yy+2 );
101 xx++; yy--;
102 }
103 p->drawLineSegments( a );
104 }
105}