[Kstars-devel] KDE/kdeedu/kstars/kstars/tools

Prakash Mohan prak902000 at gmail.com
Tue Jul 6 16:56:22 CEST 2010


SVN commit 1146743 by prakash:

Remove code repetition. Add a function to set the default image in the image preview.

CCMAIL:kstars-devel at kde.org


 M  +10 -12    observinglist.cpp  
 M  +4 -0      observinglist.h  


--- trunk/KDE/kdeedu/kstars/kstars/tools/observinglist.cpp #1146742:1146743
@@ -137,12 +137,7 @@
     ui->ImagePreview->installEventFilter( this );
     ui->TableView->viewport()->installEventFilter( this );
     ui->SessionView->viewport()->installEventFilter( this );
-    QFile file;
-    if ( KSUtils::openDataFile( file, "noimage.png" ) ) {
-       file.close();
-       ui->ImagePreview->showPreview( KUrl( file.fileName() ) );
-    } else
-        ui->ImagePreview->hide();
+    setDefaultImage();
     //Connections
     connect( this, SIGNAL( closeClicked() ), this, SLOT( slotClose() ) );
     connect( ui->TableView, SIGNAL( doubleClicked( const QModelIndex& ) ),
@@ -450,12 +445,7 @@
     showScope = false;
     ui->ImagePreview->clearPreview();
     ui->ImagePreview->setCursor( Qt::ArrowCursor );
-    QFile file;
-    if ( KSUtils::openDataFile( file, "noimage.png" ) ) {
-       file.close();
-       ui->ImagePreview->showPreview( KUrl( file.fileName() ) );
-    } else
-        ui->ImagePreview->hide();
+    setDefaultImage();
     QModelIndexList selectedItems;
     QString newName;
     SkyObject *o;
@@ -1429,4 +1419,12 @@
     }
 }
 
+void ObservingList::setDefaultImage() {
+    QFile file;
+    if ( KSUtils::openDataFile( file, "noimage.png" ) ) {
+       file.close();
+       ui->ImagePreview->showPreview( KUrl( file.fileName() ) );
+    } else
+        ui->ImagePreview->hide();
+}
 #include "observinglist.moc"
--- trunk/KDE/kdeedu/kstars/kstars/tools/observinglist.h #1146742:1146743
@@ -174,6 +174,10 @@
      */
     void selectObject( SkyObject *o );
 
+    /**@short set the default image in the image preview.
+     */
+    void setDefaultImage();
+
 public slots:
     /**@short add a new object to list
         *@p o pointer to the object to add to the list


More information about the Kstars-devel mailing list