[Kstars-devel] branches/kstars/summer/kstars/kstars/tools
Prakash Mohan
prak902000 at gmail.com
Fri Jun 5 13:28:35 CEST 2009
SVN commit 977765 by prakash:
Adding DSS images support to observing list.
CCMAIL: kstars-devel at kde.org
M +44 -1 observinglist.cpp
M +9 -1 observinglist.h
M +41 -1 observinglist.ui
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #977764:977765
@@ -26,7 +26,8 @@
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QHeaderView>
-
+#include <QLabel>
+#include <QPainter>
#include <kpushbutton.h>
#include <kstatusbar.h>
#include <ktextedit.h>
@@ -66,6 +67,8 @@
#include "indi/indidevice.h"
#include "indi/devicemanager.h"
#include "indi/indistd.h"
+#include <kio/copyjob.h>
+
#endif
//
@@ -166,6 +169,8 @@
this, SLOT( slotLocation() ) );
connect( ui->Update, SIGNAL( clicked() ),
this, SLOT( slotUpdate() ) );
+ connect( ui->GetImage, SIGNAL( clicked() ),
+ this, SLOT( slotGetImage() ) );
connect( ui->SetTime, SIGNAL( clicked() ),
this, SLOT( slotSetTime() ) );
connect( ui->tabWidget, SIGNAL( currentChanged(int) ),
@@ -187,6 +192,7 @@
ui->AddToSession->setEnabled( false );
ui->SetTime->setEnabled( false );
ui->TimeEdit->setEnabled( false );
+ ui->GetImage->setEnabled( false );
slotLoadWishList();
//Hide the MiniButton until I can figure out how to resize the Dialog!
@@ -436,6 +442,7 @@
void ObservingList::slotNewSelection() {
bool singleSelection = false, found = false;
+ ui->ImagePreview->clearPreview();
QModelIndexList selectedItems;
QString newName;
SkyObject *o;
@@ -478,6 +485,7 @@
if( singleSelection ) {
//Enable buttons
ui->CenterButton->setEnabled( true );
+ ui->GetImage->setEnabled( true );
#ifdef HAVE_INDI_H
ui->ScopeButton->setEnabled( true );
#endif
@@ -534,6 +542,7 @@
m_CurrentObject = 0;
ui->TimeEdit->setEnabled( false );
ui->SetTime->setEnabled( false );
+ ui->GetImage->setEnabled( false );
//Clear the user log text box.
saveCurrentUserLog();
@@ -551,6 +560,7 @@
ui->NotesEdit->setEnabled( false );
ui->TimeEdit->setEnabled( false );
ui->SetTime->setEnabled( false );
+ ui->GetImage->setEnabled( false );
m_CurrentObject = 0;
ui->View->removeAllPlotObjects();
if( !ui->tabWidget->currentIndex() )
@@ -1131,6 +1141,7 @@
ui->AddToSession->setEnabled( false );
ui->TimeEdit->setEnabled( false );
ui->SetTime->setEnabled( false );
+ ui->GetImage->setEnabled( false );
m_CurrentObject = 0;
if(index)
ui->WizardButton->setEnabled( false );
@@ -1177,4 +1188,36 @@
TimeHash [o->name()] = ui->TimeEdit->time();
slotAddObject(o, true, true );
}
+
+void ObservingList::slotGetImage() {
+ QString URLprefix( "http://archive.stsci.edu/cgi-bin/dss_search?v=1" );
+ QString URLsuffix( "&e=J2000&h=15.0&w=15.0&f=gif&c=none&fov=NONE" );
+ dms ra(0.0), dec(0.0);
+ QString RAString, DecString;
+ char decsgn;
+ ra.setH( currentObject()->ra0()->Hours() );
+ dec.setD( currentObject()->dec0()->Degrees() );
+
+ RAString = RAString.sprintf( "%02d+%02d+%02d", ra.hour(), ra.minute(), ra.second() );
+
+ decsgn = '+';
+ if ( dec.Degrees() < 0.0 ) decsgn = '-';
+ int dd = abs( dec.degree() );
+ int dm = abs( dec.arcmin() );
+ int ds = abs( dec.arcsec() );
+ DecString = DecString.sprintf( "%c%02d+%02d+%02d", decsgn, dd, dm, ds );
+ CurrentImage = RAString + DecString;
+ KUrl url (URLprefix + "&r=" + RAString + "&d=" + DecString + URLsuffix);
+ if( !QFile::exists(KStandardDirs::locateLocal( "appdata", CurrentImage ) ) ) {
+ downloadJob = KIO::copy (url, KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
+ connect (downloadJob, SIGNAL (result (KJob *)), SLOT (downloadReady (KJob *)));
+ } else
+ ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ));
+}
+void ObservingList::downloadReady (KJob *job)
+{
+ // set downloadJob to 0, but don't delete it - the job will be deleted automatically
+ downloadJob = 0;
+ ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ));
+}
#include "observinglist.moc"
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #977764:977765
@@ -25,6 +25,7 @@
#include "skyobjects/skyobject.h"
#include "ui_observinglist.h"
#include "kstarsdatetime.h"
+#include <kio/copyjob.h>
#include "geolocation.h"
#include "ksalmanac.h"
class KSAlmanac;
@@ -233,8 +234,14 @@
*/
void slotSetTime();
+ /**@short Gets the corresponding DSS or SDSS image from the web and
+ *displays it
+ */
+ void slotGetImage();
+
protected slots:
void slotClose();
+ void downloadReady (KJob *);
private:
KStars *ks;
@@ -244,11 +251,12 @@
SkyObject *LogObject, *m_CurrentObject, *PlotObject;
uint noNameStars;
bool isModified, bIsLarge;
- QString FileName, SessionName;
+ QString FileName, SessionName, CurrentImage;
KStarsDateTime dt;
GeoLocation *geo;
QStandardItemModel *m_Model, *m_Session;
QSortFilterProxyModel *m_SortModel, *m_SortModelSession;
+ KIO::Job *downloadJob; // download job of image -> 0 == no job is running
QHash<QString, QTime> TimeHash;
};
--- branches/kstars/summer/kstars/kstars/tools/observinglist.ui #977764:977765
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>820</width>
+ <width>861</width>
<height>650</height>
</rect>
</property>
@@ -389,6 +389,13 @@
</widget>
</item>
<item>
+ <widget class="QPushButton" name="GetImage">
+ <property name="text">
+ <string>Get Image</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -567,6 +574,29 @@
</widget>
</item>
<item>
+ <widget class="KSeparator" name="kseparator">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KImageFilePreview" name="ImagePreview">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -622,11 +652,21 @@
</widget>
<customwidgets>
<customwidget>
+ <class>KImageFilePreview</class>
+ <extends>QWidget</extends>
+ <header>kimagefilepreview.h</header>
+ </customwidget>
+ <customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
<customwidget>
+ <class>KSeparator</class>
+ <extends>QFrame</extends>
+ <header>kseparator.h</header>
+ </customwidget>
+ <customwidget>
<class>KTextEdit</class>
<extends>QTextEdit</extends>
<header>ktextedit.h</header>
More information about the Kstars-devel
mailing list