[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/graphics/digikam/utilities/queuemanager
From:       Gilles Caulier <caulier.gilles () gmail ! com>
Date:       2010-07-30 8:34:41
Message-ID: 20100730083441.983B9AC782 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1157100 by cgilles:

use more private internal container.
constify icon size
factoring code to render preview icon
preview icon is always visible if item is selected on the list


 M  +34 -16    queuelist.cpp  
 M  +7 -5      queuelist.h  


--- trunk/extragear/graphics/digikam/utilities/queuemanager/queuelist.cpp \
#1157099:1157100 @@ -6,7 +6,7 @@
  * Date        : 2008-11-21
  * Description : Batch Queue Manager items list.
  *
- * Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Copyright (C) 2008-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -21,8 +21,6 @@
  *
  * ============================================================ */
 
-#define ICONSIZE 64
-
 #include "queuelist.moc"
 
 // Qt includes
@@ -58,7 +56,7 @@
 namespace Digikam
 {
 
-class QueueListViewItemPriv
+class QueueListViewItem::QueueListViewItemPriv
 {
 
 public:
@@ -100,14 +98,28 @@
     return d->info;
 }
 
+void QueueListViewItem::setPixmap(const QPixmap& pix)
+{
+    QIcon icon = QIcon(pix);
+    //  We make sure the preview icon stays the same regardless of the role
+    icon.addPixmap(pix, QIcon::Selected, QIcon::On);
+    icon.addPixmap(pix, QIcon::Selected, QIcon::Off);
+    icon.addPixmap(pix, QIcon::Active,   QIcon::On);
+    icon.addPixmap(pix, QIcon::Active,   QIcon::Off);
+    icon.addPixmap(pix, QIcon::Normal,   QIcon::On);
+    icon.addPixmap(pix, QIcon::Normal,   QIcon::Off);
+    setIcon(0, icon);
+}
+
 void QueueListViewItem::setThumb(const QPixmap& pix)
 {
-    QPixmap pixmap(ICONSIZE+2, ICONSIZE+2);
+    QSize iSize = treeWidget()->iconSize();
+    QPixmap pixmap(iSize.width()+2, iSize.height()+2);
     pixmap.fill(Qt::transparent);
     QPainter p(&pixmap);
     p.drawPixmap((pixmap.width()/2) - (pix.width()/2), (pixmap.height()/2) - \
(pix.height()/2), pix);  d->preview = pixmap;
-    setIcon(0, QIcon(d->preview));
+    setPixmap(d->preview);
 }
 
 void QueueListViewItem::setProgressIcon(const QPixmap& icon)
@@ -118,26 +130,26 @@
     QPainter p(&preview);
     p.drawPixmap(0, 0, mask);
     p.drawPixmap((preview.width()/2) - (icon.width()/2), (preview.height()/2) - \
                (icon.height()/2), icon);
-    setIcon(0, QIcon(preview));
+    setPixmap(preview);
 }
 
 void QueueListViewItem::setCanceled()
 {
-    setIcon(0, QIcon(d->preview));
+    setPixmap(d->preview);
     setIcon(1, SmallIcon("dialog-cancel"));
     d->done = false;
 }
 
 void QueueListViewItem::setFailed()
 {
-    setIcon(0, QIcon(d->preview));
+    setPixmap(d->preview);
     setIcon(1, SmallIcon("dialog-error"));
     d->done = false;
 }
 
 void QueueListViewItem::setDone()
 {
-    setIcon(0, QIcon(d->preview));
+    setPixmap(d->preview);
     setIcon(1, SmallIcon("dialog-ok"));
     d->done = true;
 }
@@ -149,7 +161,7 @@
 
 void QueueListViewItem::reset()
 {
-    setIcon(0, QIcon(d->preview));
+    setPixmap(d->preview);
     setIcon(1, QIcon());
     d->done = false;
 }
@@ -179,7 +191,7 @@
 
 // ---------------------------------------------------------------------------
 
-class QueueListViewPriv
+class QueueListView::QueueListViewPriv
 {
 
 public:
@@ -194,6 +206,7 @@
 public:
 
     QueueListViewPriv()
+        : iconSize(64)
     {
         showTips        = false;
         toolTipTimer    = 0;
@@ -204,6 +217,8 @@
 
     bool                 showTips;
 
+    const int            iconSize;
+
     QTimer*              toolTipTimer;
 
     ThumbnailLoadThread* thumbLoadThread;
@@ -220,7 +235,7 @@
 QueueListView::QueueListView(QWidget *parent)
              : QTreeWidget(parent), d(new QueueListViewPriv)
 {
-    setIconSize(QSize(ICONSIZE, ICONSIZE));
+    setIconSize(QSize(d->iconSize, d->iconSize));
     setSelectionMode(QAbstractItemView::ExtendedSelection);
     setWhatsThis(i18n("This is the list of images to batch process."));
 
@@ -597,9 +612,9 @@
         if (item->info().fileUrl() == KUrl(desc.filePath))
         {
             if (pix.isNull())
-                item->setThumb(SmallIcon("image-x-generic", ICONSIZE, \
KIconLoader::DisabledState)); +                \
item->setThumb(SmallIcon("image-x-generic", d->iconSize, \
KIconLoader::DisabledState));  else
-                item->setThumb(pix.scaled(ICONSIZE, ICONSIZE, Qt::KeepAspectRatio));
+                item->setThumb(pix.scaled(d->iconSize, d->iconSize, \
Qt::KeepAspectRatio));  
             return;
         }
@@ -852,7 +867,10 @@
             {
                 ParseSettings settings(info);
                 settings.parseString = parseString;
-                settings.fileUrl     = \
KUrl(QString("%1/%2.%3").arg(fi.absolutePath()).arg(fi.completeBaseName()).arg(newSuffix));
 +                settings.fileUrl     = KUrl(QString("%1/%2.%3")
+                                            .arg(fi.absolutePath())
+                                            .arg(fi.completeBaseName())
+                                            .arg(newSuffix));
                 newName              = p.parse(settings);
             }
 
--- trunk/extragear/graphics/digikam/utilities/queuemanager/queuelist.h \
#1157099:1157100 @@ -6,7 +6,7 @@
  * Date        : 2008-11-21
  * Description : Batch Queue Manager items list.
  *
- * Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Copyright (C) 2008-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -42,9 +42,6 @@
 namespace Digikam
 {
 
-class QueueListViewItemPriv;
-class QueueListPriv;
-
 class QueueListViewItem : public QTreeWidgetItem
 {
 
@@ -78,13 +75,17 @@
 
 private:
 
+    void setPixmap(const QPixmap& pix);
+
+private:
+
+    class QueueListViewItemPriv;
     QueueListViewItemPriv* const d;
 };
 
 // -------------------------------------------------------------------------
 
 class CollectionImageChangeset;
-class QueueListViewPriv;
 
 class QueueListView : public QTreeWidget
 {
@@ -157,6 +158,7 @@
 
 private:
 
+    class QueueListViewPriv;
     QueueListViewPriv* const d;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic