~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to themedesigner/themediconview.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Rohan Garg, Philip Muškovac, Felix Geyer
  • Date: 2011-09-23 18:18:55 UTC
  • mfrom: (1.2.36 upstream)
  • Revision ID: package-import@ubuntu.com-20110923181855-ifs67wxkugshev9k
Tags: 2:2.1.1-0ubuntu1
[ Rohan Garg ]
* New upstream release (LP: #834190)
  - debian/control
    + Build with libqtwebkit-dev
 - debian/kipi-plugins-common
    + Install libkvkontakte required by kipi-plugins
 - debian/digikam
    + Install panoramagui

[ Philip Muškovac ]
* New upstream release
  - debian/control:
    + Add libcv-dev, libcvaux-dev, libhighgui-dev, libboost-graph1.46-dev,
      libksane-dev, libxml2-dev, libxslt-dev, libqt4-opengl-dev, libqjson-dev,
      libgpod-dev and libqca2-dev to build-deps
    + Add packages for kipi-plugins, libmediawiki, libkface, libkgeomap and
      libkvkontakte
  - debian/rules:
    + Don't build with gphoto2 since it doesn't build with it.
  - Add kubuntu_fix_test_linking.diff to fix linking of the dngconverter test
  - update install files
  - update kubuntu_01_mysqld_executable_name.diff for new cmake layout
    and rename to kubuntu_mysqld_executable_name.diff
* Fix typo in digikam-data description (LP: #804894)
* Fix Vcs links

[ Felix Geyer ]
* Move library data files to the new packages libkface-data, libkgeomap-data
  and libkvkontakte-data.
* Override version of the embedded library packages to 1.0~digikam<version>.
* Exclude the library packages from digikam-dbg to prevent file conflicts in
  the future.
* Call dh_install with --list-missing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ============================================================
2
 
 *
3
 
 * This file is a part of digiKam project
4
 
 * http://www.digikam.org
5
 
 *
6
 
 * Date        : 2005-07-15
7
 
 * Description : themed icon view
8
 
 *
9
 
 * Copyright (C) 2005 by Renchi Raju <renchi at pooh.tam.uiuc.edu>
10
 
 * Copyright (C) 2007-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
 
 *
12
 
 * This program is free software; you can redistribute it
13
 
 * and/or modify it under the terms of the GNU General
14
 
 * Public License as published by the Free Software Foundation;
15
 
 * either version 2, or (at your option)
16
 
 * any later version.
17
 
 *
18
 
 * This program 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
 
 * ============================================================ */
24
 
 
25
 
#include "themediconview.moc"
26
 
 
27
 
// Local includes
28
 
 
29
 
#include "themedicongroupitem.h"
30
 
#include "themediconitem.h"
31
 
#include "themeengine.h"
32
 
 
33
 
namespace Digikam
34
 
{
35
 
 
36
 
class ThemedIconViewPriv
37
 
{
38
 
public:
39
 
 
40
 
    ThemedIconViewPriv() :
41
 
        thumbSize(128)
42
 
    {
43
 
    }
44
 
 
45
 
    int     thumbSize;
46
 
 
47
 
    QRect   itemRect;
48
 
    QRect   itemDateRect;
49
 
    QRect   itemPixmapRect;
50
 
    QRect   itemNameRect;
51
 
    QRect   itemCommentsRect;
52
 
    QRect   itemResolutionRect;
53
 
    QRect   itemSizeRect;
54
 
    QRect   itemTagRect;
55
 
    QRect   bannerRect;
56
 
 
57
 
    QPixmap itemRegPixmap;
58
 
    QPixmap itemSelPixmap;
59
 
    QPixmap bannerPixmap;
60
 
 
61
 
    QFont   fnReg;
62
 
    QFont   fnCom;
63
 
    QFont   fnXtra;
64
 
};
65
 
 
66
 
ThemedIconView::ThemedIconView(QWidget* parent)
67
 
    : IconView(parent), d(new ThemedIconViewPriv)
68
 
{
69
 
    ThemedIconGroupItem* groupItem = new ThemedIconGroupItem(this);
70
 
 
71
 
    for (int i=0; i<10; ++i)
72
 
    {
73
 
        ThemedIconItem* item = new ThemedIconItem(groupItem);
74
 
 
75
 
        if (i > 0 && i < 3)
76
 
        {
77
 
            item->setSelected(true, false);
78
 
        }
79
 
    }
80
 
 
81
 
    updateBannerRectPixmap();
82
 
    updateItemRectsPixmap();
83
 
 
84
 
    connect(ThemeEngine::instance(), SIGNAL(signalThemeChanged()),
85
 
            this, SLOT(slotThemeChanged()));
86
 
}
87
 
 
88
 
ThemedIconView::~ThemedIconView()
89
 
{
90
 
    delete d;
91
 
}
92
 
 
93
 
QRect ThemedIconView::itemRect() const
94
 
{
95
 
    return d->itemRect;
96
 
}
97
 
 
98
 
QRect ThemedIconView::itemDateRect() const
99
 
{
100
 
    return d->itemDateRect;
101
 
}
102
 
 
103
 
QRect ThemedIconView::itemPixmapRect() const
104
 
{
105
 
    return d->itemPixmapRect;
106
 
}
107
 
 
108
 
QRect ThemedIconView::itemNameRect() const
109
 
{
110
 
    return d->itemNameRect;
111
 
}
112
 
 
113
 
QRect ThemedIconView::itemCommentsRect() const
114
 
{
115
 
    return d->itemCommentsRect;
116
 
}
117
 
 
118
 
QRect ThemedIconView::itemResolutionRect() const
119
 
{
120
 
    return d->itemResolutionRect;
121
 
}
122
 
 
123
 
QRect ThemedIconView::itemTagRect() const
124
 
{
125
 
    return d->itemTagRect;
126
 
}
127
 
 
128
 
QRect ThemedIconView::itemSizeRect() const
129
 
{
130
 
    return d->itemSizeRect;
131
 
}
132
 
 
133
 
QRect ThemedIconView::bannerRect() const
134
 
{
135
 
    return d->bannerRect;
136
 
}
137
 
 
138
 
QPixmap* ThemedIconView::itemBaseRegPixmap() const
139
 
{
140
 
    return &d->itemRegPixmap;
141
 
}
142
 
 
143
 
QPixmap* ThemedIconView::itemBaseSelPixmap() const
144
 
{
145
 
    return &d->itemSelPixmap;
146
 
}
147
 
 
148
 
QPixmap ThemedIconView::bannerPixmap() const
149
 
{
150
 
    return d->bannerPixmap;
151
 
}
152
 
 
153
 
QFont ThemedIconView::itemFontReg() const
154
 
{
155
 
    return d->fnReg;
156
 
}
157
 
 
158
 
QFont ThemedIconView::itemFontCom() const
159
 
{
160
 
    return d->fnCom;
161
 
}
162
 
 
163
 
QFont ThemedIconView::itemFontXtra() const
164
 
{
165
 
    return d->fnXtra;
166
 
}
167
 
 
168
 
void ThemedIconView::slotThemeChanged()
169
 
{
170
 
    updateBannerRectPixmap();
171
 
    updateItemRectsPixmap();
172
 
    viewport()->update();
173
 
}
174
 
 
175
 
void ThemedIconView::resizeEvent(QResizeEvent* e)
176
 
{
177
 
    IconView::resizeEvent(e);
178
 
 
179
 
    if (d->bannerRect.width() != frameRect().width())
180
 
    {
181
 
        updateBannerRectPixmap();
182
 
    }
183
 
}
184
 
 
185
 
void ThemedIconView::updateBannerRectPixmap()
186
 
{
187
 
    d->bannerRect = QRect(0, 0, 0, 0);
188
 
 
189
 
    // Title --------------------------------------------------------
190
 
    QFont fn(font());
191
 
    int fnSize = fn.pointSize();
192
 
    bool usePointSize;
193
 
 
194
 
    if (fnSize > 0)
195
 
    {
196
 
        fn.setPointSize(fnSize+2);
197
 
        usePointSize = true;
198
 
    }
199
 
    else
200
 
    {
201
 
        fnSize = fn.pixelSize();
202
 
        fn.setPixelSize(fnSize+2);
203
 
        usePointSize = false;
204
 
    }
205
 
 
206
 
    fn.setBold(true);
207
 
    QFontMetrics fm(fn);
208
 
    QRect tr = fm.boundingRect(0, 0, frameRect().width(),
209
 
                               0xFFFFFFFF, Qt::AlignLeft | Qt::AlignVCenter,
210
 
                               "XXX");
211
 
    d->bannerRect.setHeight(tr.height());
212
 
 
213
 
    if (usePointSize)
214
 
    {
215
 
        fn.setPointSize(font().pointSize());
216
 
    }
217
 
    else
218
 
    {
219
 
        fn.setPixelSize(font().pixelSize());
220
 
    }
221
 
 
222
 
    fn.setBold(false);
223
 
    fm = QFontMetrics(fn);
224
 
 
225
 
    tr = fm.boundingRect(0, 0, frameRect().width(),
226
 
                         0xFFFFFFFF, Qt::AlignLeft | Qt::AlignVCenter,
227
 
                         "XXX");
228
 
 
229
 
    d->bannerRect.setHeight(d->bannerRect.height() + tr.height() + 10);
230
 
    d->bannerRect.setWidth(frameRect().width());
231
 
    d->bannerPixmap = ThemeEngine::instance()->bannerPixmap(d->bannerRect.width(), d->bannerRect.height());
232
 
}
233
 
 
234
 
void ThemedIconView::updateItemRectsPixmap()
235
 
{
236
 
    d->itemRect           = QRect(0, 0, 0, 0);
237
 
    d->itemDateRect       = QRect(0, 0, 0, 0);
238
 
    d->itemPixmapRect     = QRect(0, 0, 0, 0);
239
 
    d->itemNameRect       = QRect(0, 0, 0, 0);
240
 
    d->itemCommentsRect   = QRect(0, 0, 0, 0);
241
 
    d->itemResolutionRect = QRect(0, 0, 0, 0);
242
 
    d->itemSizeRect       = QRect(0, 0, 0, 0);
243
 
    d->itemTagRect        = QRect(0, 0, 0, 0);
244
 
    d->fnReg              = font();
245
 
    d->fnCom              = font();
246
 
    d->fnXtra             = font();
247
 
    d->fnCom.setItalic(true);
248
 
 
249
 
    int fnSz = d->fnReg.pointSize();
250
 
 
251
 
    if (fnSz > 0)
252
 
    {
253
 
        d->fnCom.setPointSize(fnSz-1);
254
 
        d->fnXtra.setPointSize(fnSz-2);
255
 
    }
256
 
    else
257
 
    {
258
 
        fnSz = d->fnReg.pixelSize();
259
 
        d->fnCom.setPixelSize(fnSz-1);
260
 
        d->fnXtra.setPixelSize(fnSz-2);
261
 
    }
262
 
 
263
 
    int margin = 5;
264
 
    int w      = d->thumbSize + 2*margin;
265
 
 
266
 
    QFontMetrics fm(d->fnReg);
267
 
    QRect oneRowRegRect = fm.boundingRect(0, 0, w, 0xFFFFFFFF,
268
 
                                          Qt::AlignTop | Qt::AlignHCenter,
269
 
                                          "XXXXXXXXX");
270
 
    fm = QFontMetrics(d->fnCom);
271
 
    QRect oneRowComRect = fm.boundingRect(0, 0, w, 0xFFFFFFFF,
272
 
                                          Qt::AlignTop | Qt::AlignHCenter,
273
 
                                          "XXXXXXXXX");
274
 
    fm = QFontMetrics(d->fnXtra);
275
 
    QRect oneRowXtraRect = fm.boundingRect(0, 0, w, 0xFFFFFFFF,
276
 
                                           Qt::AlignTop | Qt::AlignHCenter,
277
 
                                           "XXXXXXXXX");
278
 
 
279
 
    int y             = margin;
280
 
    d->itemPixmapRect = QRect(margin, y, w, d->thumbSize + margin);
281
 
    y = d->itemPixmapRect.bottom();
282
 
 
283
 
    {
284
 
        d->itemNameRect = QRect(margin, y, w, oneRowRegRect.height());
285
 
        y = d->itemNameRect.bottom();
286
 
    }
287
 
 
288
 
    {
289
 
        d->itemCommentsRect = QRect(margin, y, w, oneRowComRect.height());
290
 
        y = d->itemCommentsRect.bottom();
291
 
    }
292
 
 
293
 
    {
294
 
        d->itemDateRect = QRect(margin, y, w, oneRowXtraRect.height());
295
 
        y = d->itemDateRect.bottom();
296
 
    }
297
 
 
298
 
    {
299
 
        d->itemTagRect = QRect(margin, y, w, oneRowComRect.height());
300
 
        y = d->itemTagRect.bottom();
301
 
    }
302
 
 
303
 
    d->itemRect      = QRect(0, 0, w+2*margin, y+margin);
304
 
    d->itemRegPixmap = ThemeEngine::instance()->thumbRegPixmap(d->itemRect.width(), d->itemRect.height());
305
 
    d->itemSelPixmap = ThemeEngine::instance()->thumbSelPixmap(d->itemRect.width(), d->itemRect.height());
306
 
}
307
 
 
308
 
}  // namespace Digikam