[Kstars-devel] branches/kstars/summer/kstars/kstars/tools

Prakash Mohan prak902000 at gmail.com
Sun Jun 28 22:12:28 CEST 2009


SVN commit 988832 by prakash:

Saving a thumbnail of the downloaded image for the Details dialog when the user downloads an image in the Observation Planner.

CCMAIL: kstars-devel at kde.org


 M  +13 -0     observinglist.cpp  
 M  +3 -1      observinglist.h  


--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #988831:988832
@@ -1223,6 +1223,7 @@
     downloadJob = 0;
     if( QFile( KStandardDirs::locateLocal( "appdata", CurrentImage ) ).size() > 13000 ) {//The default image is around 8689 bytes
         ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
+        saveThumbImage();
         ui->ImagePreview->show();
         ui->ImagePreview->setCursor( Qt::PointingHandCursor );
         if( CurrentImage.contains( "Temp" ) ) {
@@ -1250,6 +1251,7 @@
         CurrentImage = "Temp_Image_" +  o->name().remove(' ');
     else
         CurrentImage = "Image_" +  o->name().remove(' ');
+    ThumbImage = "thumb-" + o->name().toLower().remove(' ') + ".png";
     if( o->name() == "star" ) {
         if( temp )
             CurrentImage = "Temp_Image" + RAString + DecString;
@@ -1300,6 +1302,7 @@
                 url = KUrl( DSSUrl );
                 KIO::NetAccess::download( url, filename, mainWidget() );
             }
+            saveThumbImage();
         }
     } else if( QFile::exists( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) ) ) {
         QFile f( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) );
@@ -1379,6 +1382,7 @@
         if ( tp->imageFound() ) {
             tp->image()->save( f.fileName(), "PNG" ); 
             ui->ImagePreview->showPreview( KUrl( f.fileName() ) );
+            saveThumbImage();
             slotNewSelection();
         }
     }
@@ -1390,4 +1394,13 @@
     QFile::remove( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) );
     slotNewSelection();
 }
+
+void ObservingList::saveThumbImage() {
+    if( ! QFile::exists( KStandardDirs::locateLocal( "appdata", ThumbImage ) ) ) {
+        QImage img( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
+        img = img.scaled( 200, 200, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
+        img.save( KStandardDirs::locateLocal( "appdata", ThumbImage ) );
+    }
+}
+
 #include "observinglist.moc"
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #988831:988832
@@ -147,6 +147,8 @@
 
     bool eventFilter( QObject *obj, QEvent *event );
 
+    void saveThumbImage();
+
 public slots:
     /**@short add a new object to list
         *@p o pointer to the object to add to the list
@@ -301,7 +303,7 @@
     SkyObject *LogObject, *m_CurrentObject;
     uint noNameStars;
     bool isModified, bIsLarge, sessionView, dss;
-    QString FileName, SessionName, CurrentImage, DSSUrl, SDSSUrl;
+    QString FileName, SessionName, CurrentImage, DSSUrl, SDSSUrl, ThumbImage;
     char decsgn;
     KStarsDateTime dt;
     GeoLocation *geo;


More information about the Kstars-devel mailing list