[Kstars-devel] branches/kstars/summer/kstars/kstars/tools
Prakash Mohan
prak902000 at gmail.com
Sat Jun 27 20:55:22 CEST 2009
SVN commit 988306 by prakash:
Code cleanup patch, makes the process of saving images clearer, avoids code-copy.
CCMAIL: kstars-devel at kde.org
M +17 -22 observinglist.cpp
M +8 -1 observinglist.h
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #988305:988306
@@ -1241,38 +1241,33 @@
setCurrentImage( o );
QString img( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
KUrl url( SDSSUrl );
- if( ! QFile::exists( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) && ! QFile::exists( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) ) ) {
- if( KIO::NetAccess::download( url, img, mainWidget() ) ) {
- if( QFile( KStandardDirs::locateLocal( "appdata", CurrentImage ) ).size() < 9000 ) {//The default image is around 8689 bytes
- url = KUrl( DSSUrl );
- KIO::NetAccess::download( url, img, mainWidget() );
- }
- }
- } else if( QFile::exists( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) ) ) {
- QFile f( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) );
- f.rename( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
- }
+ if( ! o->isSolarSystem() )//TODO find a way for adding support for solar system images
+ saveImage( url, img );
}
} else {
foreach( SkyObject *o, obsList() ) {
setCurrentImage( o );
QString img( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
KUrl url( SDSSUrl );
- if( ! QFile::exists( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) && ! QFile::exists( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) ) ) {
- if( KIO::NetAccess::download( url, img, mainWidget() ) ) {
- if( QFile( KStandardDirs::locateLocal( "appdata", CurrentImage ) ).size() < 9000 ) {//The default image is around 8689 bytes
- url = KUrl( DSSUrl );
- KIO::NetAccess::download( url, img, mainWidget() );
- }
- }
- } else if( QFile::exists( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) ) ) {
- QFile f( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) );
- f.rename( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
- }
+ if( ! o->isSolarSystem() )//TODO find a way for adding support for solar system images
+ saveImage( url, img );
}
}
}
+void ObservingList::saveImage( KUrl url, QString filename ) {
+ if( ! QFile::exists( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) && ! QFile::exists( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) ) ) {
+ if( KIO::NetAccess::download( url, filename, mainWidget() ) ) {
+ if( QFile( KStandardDirs::locateLocal( "appdata", CurrentImage ) ).size() < 9000 ) {//The default image is around 8689 bytes
+ url = KUrl( DSSUrl );
+ KIO::NetAccess::download( url, filename, mainWidget() );
+ }
+ }
+ } else if( QFile::exists( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) ) ) {
+ QFile f( KStandardDirs::locateLocal( "appdata", "Temp_" + CurrentImage ) );
+ f.rename( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
+ }
+}
void ObservingList::slotImageViewer() {
ImageViewer *iv = new ImageViewer( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
ivList.append( iv );
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #988305:988306
@@ -145,6 +145,13 @@
*/
void setSaveImages();
+ /**@short saves the image syncronously from a given URL into a given file
+ *@p url the url from whih the image has to be downloaded
+ *@p filename the file onto which the url has to be copied to
+ *NOTE: This is not a generic image saver, it is specific to the current object
+ */
+ void saveImage( KUrl url, QString filename );
+
public slots:
/**@short add a new object to list
*@p o pointer to the object to add to the list
@@ -256,7 +263,7 @@
*/
void slotGetImage( bool _dss = false );
- /*8 at short Downloads the images of all the objects in the session list
+ /**@short Downloads the images of all the objects in the session list
*Note: This downloads the SDSS image, checks if the size is > default image
*and gets the DSS image if thats the case
*/
More information about the Kstars-devel
mailing list