[Kde-imaging] [Bug 95871] Create Calendar cannot use 4 MPixel Image

Renchi Raju renchi at pooh.tam.uiuc.edu
Tue Dec 28 20:36:45 CET 2004


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
        
http://bugs.kde.org/show_bug.cgi?id=95871        
renchi pooh tam uiuc edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From renchi pooh tam uiuc edu  2004-12-28 20:36 -------
CVS commit by pahlibar: 


* the selection for the month url was being done only if a thumbnail could be
generated. if the image size happens to be larger than the user setting for
the preview data, the url was not being selected (as the thumbnail fails to 
generate). Fixed.
* Also use a generic image icon for the selected url till the thumbnail is
generated
BUG: 95871


  M +1 -1      calsettings.h   1.5
  M +68 -19    monthwidget.cpp   1.12
  M +1 -1      monthwidget.h   1.6


--- kdeextragear-libs-1/kipi-plugins/calendar/monthwidget.cpp  #1.11:1.12
 @ -28,4 +28,5  @
 #include <qdragobject.h>
 #include <qstrlist.h>
+#include <qimage.h>
 
 // KDE includes.
 @ -38,4 +39,7  @
 #include <klocale.h>
 #include <kglobal.h>
+#include <kapplication.h>
+#include <kiconloader.h>
+#include <kdebug.h>
 #include <kio/previewjob.h>
 
 @ -99,18 +103,43  @ void MonthWidget::dropEvent(QDropEvent* 
 {
     KURL::List srcURLs;
-    KURLDrag::decode(event, srcURLs);
+    if ( !KURLDrag::decode(event, srcURLs) )
+        return;
+
+    if ( srcURLs.isEmpty() )
+        return;
+
+    KURL url = srcURLs.first();
+
+    // check if the file is an image
+    if ( QImageIO::imageFormat( url.path() ) )
+    {
+        imagePath_ = url;
+        CalSettings::instance()->setImage(month_, imagePath_);
+
+        KIconLoader* iconLoader = KApplication::kApplication()->iconLoader();
+        QPixmap pix = iconLoader->loadIcon("image", KIcon::NoGroup, 64 );
+        if ( pixmap_ )
+            delete pixmap_;
+        pixmap_ = new QPixmap( pix );
+        update();
+
+        KURL::List urls;
+        urls << url;
 
     KIO::PreviewJob* thumbJob_ =
-        KIO::filePreview( srcURLs,64);
+            KIO::filePreview( urls,64);
     connect(thumbJob_, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)),
             SLOT(slotGotThumbnaiL(const KFileItem*, const QPixmap&)));
+    }
+    else
+    {
+        kdWarning( 51001 ) << "Unknown image format for: "
+                           << url.prettyURL() << endl;
+    }
 }
 
-void MonthWidget::slotGotThumbnaiL(const KFileItem* item, const QPixmap& pix)
+void MonthWidget::slotGotThumbnaiL(const KFileItem* , const QPixmap& pix)
 {
-    imagePath_ = item->url();
-
-    CalSettings::instance()->setImage(month_,imagePath_);
-
+    if ( pixmap_ )
     delete pixmap_;
     QPixmap image = pix;
 @ -132,5 +161,19  @ void MonthWidget::mouseReleaseEvent(QMou
     if (e->button() == Qt::LeftButton) {
         KURL url = KIPI::ImageDialog::getImageURL(this, interface_);
-        if (url.isValid()) {
+        if (url.isValid())
+        {
+            // check if the file is an image
+            if ( QImageIO::imageFormat( url.path() ) )
+            {
+                imagePath_ = url;
+                CalSettings::instance()->setImage(month_, imagePath_);
+
+                KIconLoader* iconLoader = KApplication::kApplication()->iconLoader();
+                QPixmap pix = iconLoader->loadIcon("image", KIcon::NoGroup, 64 );
+                if ( pixmap_ )
+                    delete pixmap_;
+                pixmap_ = new QPixmap( pix );
+                update();
+
             KURL::List urls;
             urls << url;
 @ -141,4 +184,10  @ void MonthWidget::mouseReleaseEvent(QMou
                     SLOT(slotGotThumbnaiL(const KFileItem*, const QPixmap&)));
         }
+            else
+            {
+                kdWarning( 51001 ) << "Unknown image format for: "
+                                   << url.prettyURL() << endl;
+            }
+        }
     }
     else if (e->button() == Qt::RightButton) {


More information about the Kde-imaging mailing list