54
QPixmap* CameraIconViewItem::m_newEmblem = 0;
56
CameraIconViewItem::CameraIconViewItem(IconGroupItem* parent,
57
const GPItemInfo& itemInfo,
59
const QString& downloadName)
62
m_itemInfo = new GPItemInfo(itemInfo);
63
m_downloadName = downloadName;
101
const char *CameraIconViewItemPriv::unknowPicture_xpm[] =
200
CameraIconViewItem::CameraIconViewItem(IconGroupItem* parent, const GPItemInfo& itemInfo,
201
const QImage& thumbnail, const QString& downloadName)
204
d = new CameraIconViewItemPriv;
205
d->itemInfo = new GPItemInfo(itemInfo);
206
d->downloadName = downloadName;
207
d->thumbnail = thumbnail;
69
210
CameraIconViewItem::~CameraIconViewItem()
74
void CameraIconViewItem::setPixmap(const QPixmap& pixmap)
216
void CameraIconViewItem::setThumbnail(const QImage& thumbnail)
218
d->thumbnail = thumbnail;
221
GPItemInfo* CameraIconViewItem::itemInfo() const
79
226
void CameraIconViewItem::paintItem()
81
IconView* view = iconView();
82
QColorGroup cg = view->colorGroup();
228
CameraIconView* view = (CameraIconView*)iconView();
229
QColorGroup cg = view->colorGroup();
83
230
QFont fn(view->font());
87
QPixmap pix(r.width(), r.height());
88
pix.fill(isSelected() ? view->colorGroup().highlight() :
89
view->colorGroup().base());
93
p.drawPixmap(m_pixRect.x() + (m_pixRect.width() - m_pixmap.width())/2,
94
m_pixRect.y() + (m_pixRect.height() - m_pixmap.height())/2,
100
pen.setColor(cg.highlight());
102
p.drawRect(0, 0, pix.width(), pix.height());
103
p.fillRect(0, m_textRect.y(), pix.width(),
104
m_textRect.height(), cg.highlight() );
105
p.setPen( QPen( cg.highlightedText() ) );
236
pix = *(view->itemBaseSelPixmap());
110
pen.setColor(cg.button());
112
p.drawRect(0, 0, pix.width(), pix.height());
113
p.fillRect(0, m_textRect.y(), pix.width(),
114
m_textRect.height(), cg.button() );
115
p.setPen( cg.text() );
238
pix = *(view->itemBaseRegPixmap());
119
p.drawText(m_textRect, Qt::WordBreak|Qt::BreakAnywhere|
120
Qt::AlignHCenter|Qt::AlignTop, m_itemInfo->name);
122
if (!m_downloadName.isEmpty())
240
ThemeEngine* te = ThemeEngine::instance();
244
QString itemName = AlbumIconItem::squeezedText(&p, r.width()-5, d->itemInfo->name);
245
QString downloadName = AlbumIconItem::squeezedText(&p, r.width()-5, d->downloadName);
246
calcRect(itemName, downloadName);
248
p.setPen(isSelected() ? te->textSelColor() : te->textRegColor());
250
p.drawPixmap(d->pixRect.x() + (d->pixRect.width() - d->pixmap.width()) /2,
251
d->pixRect.y() + (d->pixRect.height() - d->pixmap.height()) /2,
254
p.drawText(d->textRect, Qt::AlignHCenter|Qt::AlignTop, itemName);
256
if (!d->downloadName.isEmpty())
124
258
if (fn.pointSize() > 0)
126
259
fn.setPointSize(QMAX(fn.pointSize()-2, 6));
131
p.setPen(QPen("steelblue"));
132
p.drawText(m_extraRect, Qt::WordBreak|
133
Qt::BreakAnywhere|Qt::AlignHCenter|
134
Qt::AlignTop,m_downloadName);
262
p.setPen(isSelected() ? te->textSpecialSelColor() : te->textSpecialRegColor());
263
p.drawText(d->extraRect, Qt::AlignHCenter|Qt::AlignTop, downloadName);
137
266
if (this == iconView()->currentItem())
139
p.setPen(QPen(isSelected() ? Qt::white : Qt::black,
268
p.setPen(QPen(isSelected() ? Qt::white : Qt::black, 1, Qt::DotLine));
141
269
p.drawRect(0, 0, r.width(), r.height());
272
// Draw download status icon.
144
if (m_itemInfo->downloaded == 0)
275
switch (d->itemInfo->downloaded)
146
int x = rect().width() - m_newEmblem->width() - 5;
148
p.drawPixmap(x, y, *m_newEmblem);
277
case GPItemInfo::NewPicture:
279
downloaded = d->pixmapNewPicture;
282
case GPItemInfo::DownloadedYes:
284
downloaded = SmallIcon( "button_ok" );
287
case GPItemInfo::DownloadStarted:
289
downloaded = SmallIcon( "run" );
292
case GPItemInfo::DownloadFailed:
294
downloaded = SmallIcon( "button_cancel" );
297
/* TODO: see B.K.O #107316 : disable temporally the unknow download status until
298
a new method to identify the already downloaded pictures from camera is
301
case GPItemInfo::DownloadUnknow:
303
downloaded = d->pixmapUnknowPicture;
309
if (!downloaded.isNull())
310
p.drawPixmap(rect().width() - downloaded.width() - 5, 5, downloaded);
312
// If camera item is locked (read only), draw a "Lock" icon.
313
if (d->itemInfo->writePermissions == 0)
314
p.drawPixmap(5, 5, SmallIcon( "encrypted" ));
153
318
r = QRect(view->contentsToViewport(QPoint(r.x(), r.y())),
159
324
void CameraIconViewItem::setDownloadName(const QString& downloadName)
161
m_downloadName = downloadName;
326
d->downloadName = downloadName;
166
330
QString CameraIconViewItem::getDownloadName() const
168
return m_downloadName;
171
void CameraIconViewItem::setDownloaded()
173
if (m_itemInfo->downloaded != 1)
175
m_itemInfo->downloaded = 1;
180
void CameraIconViewItem::calcRect()
182
const int thumbSize = 128;
184
m_pixRect = QRect(0,0,0,0);
185
m_textRect = QRect(0,0,0,0);
186
m_extraRect = QRect(0,0,0,0);
187
QRect itemRect = rect();
188
itemRect.moveTopLeft(QPoint(0,0));
190
m_pixRect.setWidth(thumbSize);
191
m_pixRect.setHeight(thumbSize);
332
return d->downloadName;
335
void CameraIconViewItem::setDownloaded(int status)
337
d->itemInfo->downloaded = status;
341
void CameraIconViewItem::toggleLock()
343
if (d->itemInfo->writePermissions == 0)
344
d->itemInfo->writePermissions = 1;
346
d->itemInfo->writePermissions = 0;
351
void CameraIconViewItem::calcRect(const QString& itemName, const QString& downloadName)
353
CameraIconView* view = (CameraIconView*)iconView();
354
int thumbSize = view->thumbnailSize().size();
355
d->pixmap = QPixmap(d->thumbnail.smoothScale(thumbSize, thumbSize, QImage::ScaleMin));
356
d->pixRect = QRect(0,0,0,0);
357
d->textRect = QRect(0,0,0,0);
358
d->extraRect = QRect(0,0,0,0);
359
QRect itemRect = rect();
360
itemRect.moveTopLeft(QPoint(0, 0));
362
d->pixRect.setWidth(thumbSize);
363
d->pixRect.setHeight(thumbSize);
193
365
QFontMetrics fm(iconView()->font());
194
366
QRect r = QRect(fm.boundingRect(0, 0, thumbSize, 0xFFFFFFFF,
195
Qt::AlignHCenter | Qt::AlignTop |
196
Qt::WordBreak | Qt::BreakAnywhere,
198
m_textRect.setWidth(r.width());
199
m_textRect.setHeight(r.height());
367
Qt::AlignHCenter | Qt::AlignTop,
369
d->textRect.setWidth(r.width());
370
d->textRect.setHeight(r.height());
201
if (!m_downloadName.isEmpty())
372
if (!d->downloadName.isEmpty())
203
374
QFont fn(iconView()->font());
204
375
if (fn.pointSize() > 0)
209
380
fm = QFontMetrics(fn);
210
r = QRect(fm.boundingRect(0, 0, thumbSize, 0xFFFFFFFF,
211
Qt::AlignHCenter | Qt::WordBreak |
212
Qt::BreakAnywhere | Qt::AlignTop,
214
m_extraRect.setWidth(r.width());
215
m_extraRect.setHeight(r.height());
381
r = QRect(fm.boundingRect(0, 0, thumbSize, 0xFFFFFFFF,
382
Qt::AlignHCenter | Qt::WordBreak,
384
d->extraRect.setWidth(r.width());
385
d->extraRect.setHeight(r.height());
217
m_textRect.setWidth(QMAX(m_textRect.width(), m_extraRect.width()));
218
m_textRect.setHeight(m_textRect.height() + m_extraRect.height());
387
d->textRect.setWidth(QMAX(d->textRect.width(), d->extraRect.width()));
388
d->textRect.setHeight(d->textRect.height() + d->extraRect.height());
221
int w = QMAX(m_textRect.width(), m_pixRect.width() );
222
int h = m_textRect.height() + m_pixRect.height() ;
391
int w = QMAX(d->textRect.width(), d->pixRect.width() );
392
int h = d->textRect.height() + d->pixRect.height() ;
224
394
itemRect.setWidth(w+4);
225
395
itemRect.setHeight(h+4);
227
397
// Center the pix and text rect
228
m_pixRect = QRect(2, 2, m_pixRect.width(), m_pixRect.height());
229
m_textRect = QRect((itemRect.width() - m_textRect.width())/2,
230
itemRect.height() - m_textRect.height(),
231
m_textRect.width(), m_textRect.height());
398
d->pixRect = QRect(2, 2, d->pixRect.width(), d->pixRect.height());
399
d->textRect = QRect((itemRect.width() - d->textRect.width())/2,
400
itemRect.height() - d->textRect.height(),
401
d->textRect.width(), d->textRect.height());
233
if (!m_extraRect.isEmpty())
403
if (!d->extraRect.isEmpty())
235
m_extraRect = QRect((itemRect.width() - m_extraRect.width())/2,
236
itemRect.height() - m_extraRect.height(),
237
m_extraRect.width(), m_extraRect.height());
405
d->extraRect = QRect((itemRect.width() - d->extraRect.width())/2,
406
itemRect.height() - d->extraRect.height(),
407
d->extraRect.width(), d->extraRect.height());
241
411
QRect CameraIconViewItem::clickToOpenRect()
245
if (m_pixmap.isNull())
415
if (d->pixmap.isNull())
247
QRect pixRect(m_pixRect);
417
QRect pixRect(d->pixRect);
248
418
pixRect.moveBy(r.x(), r.y());
253
QRect pixRect(m_pixRect.x() + (m_pixRect.width() - m_pixmap.width())/2,
254
m_pixRect.y() + (m_pixRect.height() - m_pixmap.height())/2,
422
QRect pixRect(d->pixRect.x() + (d->pixRect.width() - d->pixmap.width())/2,
423
d->pixRect.y() + (d->pixRect.height() - d->pixmap.height())/2,
424
d->pixmap.width(), d->pixmap.height());
257
425
pixRect.moveBy(r.x(), r.y());
429
} // namespace Digikam