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