~ubuntu-branches/ubuntu/oneiric/kdenetwork/oneiric-updates

« back to all changes in this revision

Viewing changes to .pc/kubuntu_05_samba_sharing.diff/filesharing/advanced/kcm_sambaconf/qmultichecklistitem.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac, Philip Muškovac
  • Date: 2011-07-10 12:36:35 UTC
  • mfrom: (1.1.59 upstream)
  • Revision ID: package-import@ubuntu.com-20110710123635-3db9oyxdswp4sp1e
Tags: 4:4.6.90-0ubuntu1
* New upstream release
 - Bump on kde-sc-dev-latest
 - s/kdebase-runtime-dev/kde-runtime-dev
* Dropped kubuntu_05_samba_sharing.diff <- went upstream
* Added kubuntu_05_make_old_symbols_reappear_and_fix_building.diff
* Refreshed *.install
* Refreshed symbols

[ Philip Muškovac ]
* fix debug package depends on kdebase-runtime-dbg -> kde-runtime-dbg 
  and recommends on kde-workspace-dbg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                          qmultichecklistitem.cpp  -  description
3
 
                             -------------------
4
 
    begin                : Sun Jan 26 2003
5
 
    copyright            : (C) 2003 by Jan Schäfer
6
 
    email                : janschaefer@users.sourceforge.net
7
 
 ***************************************************************************/
8
 
 
9
 
/******************************************************************************
10
 
 *                                                                             *
11
 
 *  This file is part of KSambaPlugin.                                        *
12
 
 *                                                                            *
13
 
 *  KSambaPlugin is free software; you can redistribute it and/or modify      *
14
 
 *  it under the terms of the GNU General Public License as published by      *
15
 
 *  the Free Software Foundation; either version 2 of the License, or         *
16
 
 *  (at your option) any later version.                                       *
17
 
 *                                                                            *
18
 
 *  KSambaPlugin is distributed in the hope that it will be useful,           *
19
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
20
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
21
 
 *  GNU General Public License for more details.                              *
22
 
 *                                                                            *
23
 
 *  You should have received a copy of the GNU General Public License         *
24
 
 *  along with KSambaPlugin; if not, write to the Free Software               *
25
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA  *
26
 
 *                                                                            *
27
 
 ******************************************************************************/
28
 
 
29
 
#include <qpen.h>
30
 
#include <qpainter.h>
31
 
#include <q3header.h>
32
 
//Added by qt3to4:
33
 
#include <QPolygon>
34
 
 
35
 
#include <kdebug.h>
36
 
#include <kmessagebox.h>
37
 
 
38
 
#include "qmultichecklistitem.moc"
39
 
#include "qmultichecklistitem.h"
40
 
 
41
 
static const int BoxSize = 16;
42
 
 
43
 
 
44
 
QMultiCheckListItem::QMultiCheckListItem( Q3ListView *parent) :
45
 
  Q3ListViewItem(parent) 
46
 
{
47
 
}
48
 
 
49
 
void QMultiCheckListItem::resize(int column) {
50
 
  if (column >= (int) checkBoxColumns.size()) {
51
 
    checkBoxColumns.resize(column*2);
52
 
    checkStates.resize(column*2);
53
 
    disableStates.resize(column*2);
54
 
  }
55
 
 
56
 
}
57
 
 
58
 
void QMultiCheckListItem::setOn(int column, bool b) {
59
 
  resize(column);
60
 
  checkStates.setBit(column,b);
61
 
  checkBoxColumns.setBit(column);
62
 
  kDebug(5009) << "setOn : " << column;
63
 
  repaint();
64
 
}
65
 
 
66
 
bool QMultiCheckListItem::isOn(int column) {
67
 
  resize(column);
68
 
  return checkStates.testBit(column);
69
 
}
70
 
 
71
 
bool QMultiCheckListItem::isDisabled(int column) {
72
 
  resize(column);
73
 
  return disableStates.testBit(column);
74
 
}
75
 
 
76
 
void QMultiCheckListItem::toggle(int column) {
77
 
  resize(column);
78
 
  checkBoxColumns.setBit(column);
79
 
  checkStates.toggleBit(column);
80
 
  emit stateChanged(column,checkStates.testBit(column));
81
 
 
82
 
  repaint();
83
 
}
84
 
 
85
 
void QMultiCheckListItem::setDisabled(int column, bool b) {
86
 
  resize(column);
87
 
 
88
 
  disableStates.setBit(column,b);
89
 
//  KMessageBox::information(0L,QString("setDisabled"),QString("disable %1 ").arg(column));
90
 
  repaint();
91
 
}
92
 
 
93
 
void QMultiCheckListItem::paintCell(QPainter *p,const QColorGroup & cg, int col, int width, int align)
94
 
{
95
 
  resize(col);
96
 
 
97
 
  if ( !p )
98
 
    return;
99
 
 
100
 
  Q3ListView *lv = listView();
101
 
  if ( !lv )
102
 
    return;
103
 
 
104
 
  Q3ListViewItem::paintCell(p,cg,col,width,align );
105
 
 
106
 
  int marg = lv->itemMargin();
107
 
//  int width = BoxSize + marg*2;
108
 
  // use a provate color group and set the text/highlighted text colors
109
 
  QColorGroup mcg = cg;
110
 
 
111
 
  if (checkBoxColumns.testBit(col)) {
112
 
    // Bold/Italic/use default checkboxes
113
 
    // code almost identical to QCheckListItem
114
 
    Q_ASSERT( lv ); //###
115
 
    // I use the text color of defaultStyles[0], normalcol in parent listview
116
 
//    mcg.setColor( QPalette::Text, ((StyleListView*)lv)->normalcol );
117
 
    int x = 0;
118
 
    if ( align == Qt::AlignCenter ) {
119
 
      QFontMetrics fm( lv->font() );
120
 
      x = (width - BoxSize - fm.width(text(0)))/2;
121
 
    }
122
 
    int y = (height() - BoxSize) / 2;
123
 
 
124
 
    if ( !isEnabled() || disableStates.testBit(col))
125
 
      p->setPen( QPen( lv->palette().color( QPalette::Disabled, QPalette::Text ), 2 ) );
126
 
    else
127
 
      p->setPen( QPen( mcg.text(), 2 ) );
128
 
 
129
 
    if ( isSelected() && lv->header()->mapToSection( 0 ) != 0 ) {
130
 
      p->fillRect( 0, 0, x + marg + BoxSize + 4, height(),
131
 
             mcg.brush( QPalette::Highlight ) );
132
 
      if ( isEnabled() )
133
 
          p->setPen( QPen( mcg.color( QPalette::HighlightedText), 2 ) ); // FIXME! - use defaultstyles[0].selecol. luckily not used :)
134
 
    }
135
 
    p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
136
 
    x++;
137
 
    y++;
138
 
    if ( checkStates.testBit(col) ) {
139
 
      QPolygon a( 7*2 );
140
 
      int i, xx, yy;
141
 
      xx = x+1+marg;
142
 
      yy = y+5;
143
 
      for ( i=0; i<3; i++ ) {
144
 
        a.setPoint( 2*i,   xx, yy );
145
 
        a.setPoint( 2*i+1, xx, yy+2 );
146
 
        xx++; yy++;
147
 
      }
148
 
      yy -= 2;
149
 
      for ( i=3; i<7; i++ ) {
150
 
        a.setPoint( 2*i,   xx, yy );
151
 
        a.setPoint( 2*i+1, xx, yy+2 );
152
 
        xx++; yy--;
153
 
      }
154
 
      p->drawLineSegments( a );
155
 
    }
156
 
 
157
 
  }
158
 
 
159
 
 
160
 
}
161
 
 
162
 
 
163