~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/digikam/folderitem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Description : implementation of item folder 
8
8
 * 
9
9
 * Copyright (C) 2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
 
 
 
10
 * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
11
 *
11
12
 * This program is free software; you can redistribute it
12
13
 * and/or modify it under the terms of the GNU General
13
14
 * Public License as published by the Free Software Foundation;
43
44
          : QListViewItem(parent, text)
44
45
{
45
46
    m_special = special;
46
 
    m_focus = false;
 
47
    m_focus   = false;
47
48
}
48
49
 
49
50
FolderItem::FolderItem(QListViewItem* parent, const QString& text, bool special)
50
51
          : QListViewItem(parent, text)
51
52
{
52
53
    m_special = special;
53
 
    m_focus = false;    
 
54
    m_focus   = false;
54
55
}
55
56
 
56
57
FolderItem::~FolderItem()
67
68
    return m_focus;
68
69
}
69
70
 
70
 
void FolderItem::paintCell(QPainter* p, const QColorGroup & cg, int column,
71
 
                           int width, int align)
 
71
void FolderItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int)
72
72
{
73
73
    FolderView *fv = dynamic_cast<FolderView*>(listView());
74
74
    if (!fv)
76
76
 
77
77
    QFontMetrics fm(p->fontMetrics());
78
78
 
79
 
    QString t = text(column);
80
 
 
81
 
    int margin = fv->itemMargin();
82
 
    int r      = margin;
 
79
    QString t           = text(column);
 
80
    int margin          = fv->itemMargin();
 
81
    int r               = margin;
83
82
    const QPixmap* icon = pixmap(column);
84
83
 
85
84
    if (isSelected())
110
109
        p->setFont(f);
111
110
 
112
111
        p->setPen(isSelected() ? cg.color(QColorGroup::LinkVisited) :
113
 
                  cg.color(QColorGroup::Link));        
 
112
                  cg.color(QColorGroup::Link));
114
113
    }
115
114
 
116
115
    QRect br;
117
 
    p->drawText(r, 0, width-margin-r, height(), Qt::AlignLeft|Qt::AlignVCenter,
118
 
                t, -1, &br);
 
116
    p->drawText(r, 0, width-margin-r, height(), Qt::AlignLeft|Qt::AlignVCenter, t, -1, &br);
119
117
 
120
118
    if (m_special)
121
119
    {
122
120
        p->drawLine(br.right() + 2, height()/2, fv->width(), height()/2);
123
121
    }
124
 
    
 
122
 
125
123
    if (m_focus)
126
124
    {
127
125
        p->setPen(cg.link());
153
151
                                         QCheckListItem::Type tt)
154
152
                   : QCheckListItem(parent, text, tt)
155
153
{
 
154
    m_focus = false;
156
155
}
157
156
 
158
157
FolderCheckListItem::FolderCheckListItem(QListViewItem* parent, const QString& text,
159
158
                                         QCheckListItem::Type tt)
160
159
                   : QCheckListItem(parent, text, tt)
161
160
{
 
161
    m_focus = false;
162
162
}
163
163
 
164
164
FolderCheckListItem::~FolderCheckListItem()
165
165
{
166
166
}
167
167
 
168
 
void FolderCheckListItem::paintCell(QPainter* p, const QColorGroup & cg,
169
 
                                    int column, int width, int)
 
168
void FolderCheckListItem::setFocus(bool b)
 
169
{
 
170
    m_focus = b;
 
171
}
 
172
 
 
173
bool FolderCheckListItem::focus() const
 
174
{
 
175
    return m_focus;
 
176
}
 
177
 
 
178
void FolderCheckListItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int)
170
179
{
171
180
    FolderView *fv = dynamic_cast<FolderView*>(listView());
172
181
    if (!fv)
173
182
        return;
174
 
    
 
183
 
175
184
    QFontMetrics fm(p->fontMetrics());
176
185
 
177
 
    QString t = text(column);
178
 
 
179
 
    int margin = fv->itemMargin();
180
 
    int r      = margin;
 
186
    QString t           = text(column);
 
187
    int margin          = fv->itemMargin();
 
188
    int r               = margin;
181
189
    const QPixmap* icon = pixmap(column);
182
190
 
183
191
    int styleflags = QStyle::Style_Default;
204
212
        (type() == QCheckListItem::CheckBoxController))
205
213
    {
206
214
        int boxsize = fv->style().pixelMetric(QStyle::PM_CheckListButtonSize, fv); 
207
 
        int x = 3;
208
 
        int y = (height() - boxsize)/2 + margin;
 
215
        int x       = 3;
 
216
        int y       = (height() - boxsize)/2 + margin;
209
217
        r += boxsize + 4;
210
218
 
211
219
        p->fillRect(0, 0, r, height(), cg.base());
212
 
        
 
220
 
213
221
        fv->style().drawPrimitive(QStyle::PE_CheckListIndicator, p,
214
222
                                  QRect(x, y, boxsize, height()),
215
223
                                  cg, styleflags, QStyleOption(this));
216
224
    }
217
 
    
 
225
 
218
226
    if (isSelected())
219
227
    {
220
228
        p->drawPixmap(r, 0, fv->itemBasePixmapSelected());
225
233
        p->drawPixmap(r, 0, fv->itemBasePixmapRegular());
226
234
        p->setPen(cg.text());
227
235
    }
228
 
    
 
236
 
229
237
    if (icon)
230
238
    {
231
239
        int xo = r;
237
245
    }
238
246
 
239
247
    p->drawText(r, 0, width-margin-r, height(), Qt::AlignLeft|Qt::AlignVCenter, t);
 
248
 
 
249
    if (m_focus)
 
250
    {
 
251
        p->setPen(cg.link());
 
252
        QRect r = fv->itemRect(this);
 
253
        p->drawRect(0, 0, r.width(), r.height());
 
254
    }
240
255
}
241
256
 
242
257
void FolderCheckListItem::setup()