[Kde-imaging] kdeextragear-libs-1/libkipi/libkipi

Aurélien Gâteau aurelien.gateau at free.fr
Sat May 22 00:46:15 CEST 2004


CVS commit by gateau: 

Added an image preview on the right side of the dialog.
CCMAIL: kde-imaging at kde.org


  M +36 -7     imagecollectiondialog.cpp   1.2
  M +2 -1      imagecollectiondialog.h   1.2


--- kdeextragear-libs-1/libkipi/libkipi/imagecollectiondialog.cpp  #1.1:1.2
@@ -1,10 +1,17 @@
+#include <qguardedptr.h>
 #include <qhbox.h>
+#include <qlabel.h>
 
+#include <kdebug.h>
 #include <klistview.h>
 #include <klocale.h>
 
+#include <libkipi/thumbnailjob.h>
+
 #include "imagecollectiondialog.moc"
 
 
+const int PREVIEW_SIZE=128;
+
 namespace KIPI
 {
@@ -33,5 +40,7 @@ struct ImageCollectionDialog::Private {
     KListView* _albumList;
     KListView* _imageList;
+    QLabel* _preview;
     QValueList<ImageCollection> _albums;
+    QGuardedPtr<KIPI::ThumbnailJob> _thumbJob;
 };
 
@@ -43,4 +52,5 @@ ImageCollectionDialog::ImageCollectionDi
         d=new Private;
         d->_interface=interface;
+    d->_thumbJob=0;
     QHBox* box=makeHBoxMainWidget();
     d->_albumList=new KListView(box);
@@ -51,4 +61,9 @@ ImageCollectionDialog::ImageCollectionDi
     d->_imageList->addColumn(i18n("Image Name"));
 
+    d->_preview=new QLabel(box);
+        d->_preview->setAlignment(AlignHCenter | AlignVCenter | WordBreak);
+    d->_preview->setFixedWidth(PREVIEW_SIZE);
+        d->_preview->setText(i18n("No image selected"));
+
     d->_albums=d->_interface->allAlbums();
     QValueList<ImageCollection>::ConstIterator it=d->_albums.begin();
@@ -61,5 +76,5 @@ ImageCollectionDialog::ImageCollectionDi
 
     connect(d->_imageList, SIGNAL(selectionChanged(QListViewItem*)),
-        this, SLOT(selectImage(QListViewItem*)) );
+        this, SLOT(slotImageSelected(QListViewItem*)) );
 
     enableButtonOK(false);
@@ -102,7 +117,8 @@ void ImageCollectionDialog::fillImageLis
 
 
-void ImageCollectionDialog::selectImage(QListViewItem* item) {
+void ImageCollectionDialog::slotImageSelected(QListViewItem* item) {
     if (!item) {
         enableButtonOK(false);
+                d->_preview->setText(i18n("No image selected"));
         d->_url=KURL();
         return;
@@ -110,4 +126,17 @@ void ImageCollectionDialog::selectImage(
     enableButtonOK(true);
     d->_url=static_cast<ImageLVI*>(item)->_url;
+
+    if (!d->_thumbJob.isNull()) {
+        delete d->_thumbJob;
+    }
+    d->_thumbJob=new KIPI::ThumbnailJob(d->_url, PREVIEW_SIZE); 
+    connect(d->_thumbJob, SIGNAL(signalThumbnail(const KURL&, const QPixmap&)),
+        SLOT(slotGotPreview(const KURL&, const QPixmap&)));
+}
+
+
+void ImageCollectionDialog::slotGotPreview(const KURL&, const QPixmap& pix) {
+        
+    d->_preview->setPixmap(pix);
 }
  

--- kdeextragear-libs-1/libkipi/libkipi/imagecollectiondialog.h  #1.1:1.2
@@ -30,5 +30,6 @@ public:
 private slots:
     void fillImageList(QListViewItem*);
-    void selectImage(QListViewItem*);
+    void slotImageSelected(QListViewItem*);
+        void slotGotPreview(const KURL&, const QPixmap&);
     
 private:




More information about the Kde-imaging mailing list