summaryrefslogtreecommitdiff
path: root/libopie/ocheckitem.cpp
authorzecke <zecke>2003-04-13 16:57:28 (UTC)
committer zecke <zecke>2003-04-13 16:57:28 (UTC)
commit0b311079ff19798866291034663757103c6ba935 (patch) (unidiff)
tree70ddccf3a3147475050fa06cc2d807a71ab1d5ee /libopie/ocheckitem.cpp
parent1537ccb435ca725c793db6e94e0b9e83484b57e7 (diff)
downloadopie-0b311079ff19798866291034663757103c6ba935.zip
opie-0b311079ff19798866291034663757103c6ba935.tar.gz
opie-0b311079ff19798866291034663757103c6ba935.tar.bz2
Jumbo API documentation update
and some API fixed ColorDialog is now OColorDialog!!! keep the namespace tidy! ColorPopupMenu is now OColorPopupMenu!!! keep the namespace tidy ColorDialog TT couldn't break bc we can so make it const QColor& OTimePicker add some convience methods more I might have forgot
Diffstat (limited to 'libopie/ocheckitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ocheckitem.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libopie/ocheckitem.cpp b/libopie/ocheckitem.cpp
index d6ddc79..082d7a2 100644
--- a/libopie/ocheckitem.cpp
+++ b/libopie/ocheckitem.cpp
@@ -1,75 +1,106 @@
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> 13#include <qpainter.h>
14 14
15#include "ocheckitem.h" 15#include "ocheckitem.h"
16 16
17/**
18 * Constructs an CheckItem with a QTable as parent
19 * and a sort key for.
20 * The sort key will be used by QTable to sort the table later
21 * @param t The parent QTable where the check item belongs
22 * @param key A sort key
23 */
17OCheckItem::OCheckItem( QTable *t, const QString &key ) 24OCheckItem::OCheckItem( QTable *t, const QString &key )
18 : QTableItem( t, Never, "" ), m_checked( FALSE ), m_sortKey( key ) 25 : QTableItem( t, Never, "" ), m_checked( FALSE ), m_sortKey( key )
19{ 26{
20} 27}
21 28
29/**
30 * reimplemted for internal reasons
31 * @return Returns the sort key of the Item
32 * @see QTableItem
33 */
22QString OCheckItem::key() const 34QString OCheckItem::key() const
23{ 35{
24 return m_sortKey; 36 return m_sortKey;
25} 37}
26 38
39/**
40 * This method can check or uncheck the item. It will
41 * call QTable to update the cell.
42 *
43 * @param b Whether to check or uncheck the item
44 */
27void OCheckItem::setChecked( bool b ) 45void OCheckItem::setChecked( bool b )
28{ 46{
29 m_checked = b; 47 m_checked = b;
30 table()->updateCell( row(), col() ); 48 table()->updateCell( row(), col() );
31} 49}
32 50
51/**
52 * This will toggle the item. If it is checked it'll get
53 * unchecked by this method or vice versa.
54 */
33void OCheckItem::toggle() 55void OCheckItem::toggle()
34{ 56{
35 m_checked = !m_checked; 57 m_checked = !m_checked;
36} 58}
37 59
60/**
61 * This will return the state of the item.
62 *
63 * @return Returns true if the item is checked
64 */
38bool OCheckItem::isChecked() const 65bool OCheckItem::isChecked() const
39{ 66{
40 return m_checked; 67 return m_checked;
41} 68}
42 69
70/**
71 * @internal
72 * This paints the item
73 */
43void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, 74void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr,
44 bool ) 75 bool )
45{ 76{
46 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 77 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
47 78
48 int marg = ( cr.width() - BoxSize ) / 2; 79 int marg = ( cr.width() - BoxSize ) / 2;
49 int x = 0; 80 int x = 0;
50 int y = ( cr.height() - BoxSize ) / 2; 81 int y = ( cr.height() - BoxSize ) / 2;
51 p->setPen( QPen( cg.text() ) ); 82 p->setPen( QPen( cg.text() ) );
52 p->drawRect( x + marg, y, BoxSize, BoxSize ); 83 p->drawRect( x + marg, y, BoxSize, BoxSize );
53 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 84 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
54 p->setPen( darkGreen ); 85 p->setPen( darkGreen );
55 x += 1; 86 x += 1;
56 y += 1; 87 y += 1;
57 if ( m_checked ) { 88 if ( m_checked ) {
58 QPointArray a( 7*2 ); 89 QPointArray a( 7*2 );
59 int i, xx, yy; 90 int i, xx, yy;
60 xx = x+1+marg; 91 xx = x+1+marg;
61 yy = y+2; 92 yy = y+2;
62 for ( i=0; i<3; i++ ) { 93 for ( i=0; i<3; i++ ) {
63 a.setPoint( 2*i, xx, yy ); 94 a.setPoint( 2*i, xx, yy );
64 a.setPoint( 2*i+1, xx, yy+2 ); 95 a.setPoint( 2*i+1, xx, yy+2 );
65 xx++; yy++; 96 xx++; yy++;
66 } 97 }
67 yy -= 2; 98 yy -= 2;
68 for ( i=3; i<7; i++ ) { 99 for ( i=3; i<7; i++ ) {
69 a.setPoint( 2*i, xx, yy ); 100 a.setPoint( 2*i, xx, yy );
70 a.setPoint( 2*i+1, xx, yy+2 ); 101 a.setPoint( 2*i+1, xx, yy+2 );
71 xx++; yy--; 102 xx++; yy--;
72 } 103 }
73 p->drawLineSegments( a ); 104 p->drawLineSegments( a );
74 } 105 }
75} 106}