[Kstars-devel] branches/kstars/summer/kstars/kstars
Prakash Mohan
prak902000 at gmail.com
Sun Jun 14 09:18:08 CEST 2009
SVN commit 981697 by prakash:
Adding functionality in the Observing List to show the bigger version of the DSS/SDSS images using the ImageViewer.
CCMAIL: kstars-devel at kde.org
M +31 -2 imageviewer.cpp
M +2 -0 imageviewer.h
M +20 -2 tools/observinglist.cpp
M +7 -1 tools/observinglist.h
M +15 -2 tools/observinglist.ui
--- branches/kstars/summer/kstars/kstars/imageviewer.cpp #981696:981697
@@ -51,8 +51,7 @@
ImageLabel::~ImageLabel()
{}
-void ImageLabel::paintEvent (QPaintEvent */*ev*/)
-{
+void ImageLabel::paintEvent (QPaintEvent */*ev*/) {
QPainter p;
p.begin( this );
int x = 0;
@@ -112,6 +111,36 @@
loadImageFromURL();
}
+ImageViewer::ImageViewer ( QString FileName )
+ : KDialog( KStars::Instance() ), ks( KStars::Instance() ), fileIsImage(true), downloadJob(0)
+{
+ setModal( false );
+ setCaption( i18n( "KStars image viewer" ) + QString( " : " ) + FileName );
+ setButtons( KDialog::Close );
+
+ Page = new QFrame( this );
+ setMainWidget( Page );
+ View = new ImageLabel( Page );
+ Caption = new QLabel( Page );
+ View->setAutoFillBackground( true );
+ //Reverse colors
+ QPalette p = palette();
+ p.setColor( QPalette::Window, palette().color( QPalette::WindowText ) );
+ p.setColor( QPalette::WindowText, palette().color( QPalette::Window ) );
+ Caption->setPalette( p );
+ View->setPalette( p );
+
+ vlay = new QVBoxLayout( Page );
+ vlay->setSpacing( 0 );
+ vlay->setMargin( 0 );
+ vlay->addWidget( View );
+ setWindowTitle ( FileName); // the title of the window
+
+ file.setFileName( FileName );
+ showImage();
+
+}
+
ImageViewer::~ImageViewer() {
// check if download job is running
checkJob();
--- branches/kstars/summer/kstars/kstars/imageviewer.h #981696:981697
@@ -66,6 +66,8 @@
/**Constructor. */
ImageViewer (const KUrl &imageURL, const QString &capText, KStars *ks );
+ ImageViewer ( QString FileName );
+
/**Destructor. If there is a partially downloaded image file, delete it.*/
~ImageViewer();
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #981696:981697
@@ -56,6 +56,7 @@
#include "tools/altvstime.h"
#include "tools/wutdialog.h"
#include "Options.h"
+#include "imageviewer.h"
#include <config-kstars.h>
@@ -168,6 +169,8 @@
this, SLOT( slotUpdate() ) );
connect( ui->GetImage, SIGNAL( clicked() ),
this, SLOT( slotGetImage() ) );
+ connect( ui->ExpandImage, SIGNAL( clicked() ),
+ this, SLOT( slotImageViewer() ) );
connect( ui->SetTime, SIGNAL( clicked() ),
this, SLOT( slotSetTime() ) );
connect( ui->tabWidget, SIGNAL( currentChanged(int) ),
@@ -193,12 +196,18 @@
ui->TimeEdit->setEnabled( false );
ui->GetImage->setEnabled( false );
ui->saveImages->setEnabled( false );
+ ui->ExpandImage->setEnabled( false );
slotLoadWishList(); //Load the wishlist from disk if present
//Hide the MiniButton until I can figure out how to resize the Dialog!
// ui->MiniButton->hide();
}
+ObservingList::~ObservingList() {
+ foreach( ImageViewer *iv, ivList ) {
+ delete iv;
+ }
+}
//SLOTS
void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
@@ -361,6 +370,7 @@
}
void ObservingList::slotRemoveSelectedObjects() {
+ ui->ExpandImage->setEnabled( false );
if( sessionView )
{
//Find each object by name in the session list, and remove it
@@ -422,6 +432,7 @@
void ObservingList::slotNewSelection() {
bool singleSelection = false, found = false;
ui->ImagePreview->clearPreview();
+ ui->ExpandImage->setEnabled( false );
QModelIndexList selectedItems;
QString newName;
SkyObject *o;
@@ -502,8 +513,10 @@
ui->NotesEdit->clear();
ui->NotesEdit->setEnabled( false );
}
- if( QFile::exists( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) )//If the image is present, show it!
+ if( QFile::exists( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) ) {//If the image is present, show it!
ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ));
+ ui->ExpandImage->setEnabled( true );
+ }
} else {
kDebug() << i18n( "Object %1 not found in list.", newName );
@@ -1175,7 +1188,7 @@
DecString = DecString.sprintf( "%c%02d+%02d+%02d", decsgn, dd, dm, ds );
RA = RA.sprintf( "ra=%f", o->ra0()->Degrees() );
Dec = Dec.sprintf( "&dec=%f", o->dec0()->Degrees() );
- CurrentImage = o->name().remove(' ');
+ CurrentImage = "image_" + o->name().remove(' ');
if( o->name() == "star" ) {
CurrentImage = "image" + RAString + DecString;
CurrentImage = CurrentImage.remove('+').remove('-') + decsgn;
@@ -1201,4 +1214,9 @@
}
}
+void ObservingList::slotImageViewer() {
+ ImageViewer *iv = new ImageViewer( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
+ ivList.append( iv );
+ iv->show();
+}
#include "observinglist.moc"
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #981696:981697
@@ -29,6 +29,7 @@
#include "kstarsdatetime.h"
#include "geolocation.h"
#include "ksalmanac.h"
+#include "imageviewer.h"
class KSAlmanac;
class QSortFilterProxyModel;
@@ -85,7 +86,7 @@
ObservingList( KStars *_ks );
/**@short Destuctor (empty)
*/
- ~ObservingList() {}
+ ~ObservingList();
/**@return true if the object is in the observing list
*@p o pointer to the object to test.
@@ -256,6 +257,10 @@
*/
void slotSaveImages();
+ /**@short Shows the image in a ImageViewer window.
+ */
+ void slotImageViewer();
+
protected slots:
void slotClose();
void downloadReady();
@@ -277,6 +282,7 @@
KIO::Job *downloadJob; // download job of image -> 0 == no job is running
QHash<QString, QTime> TimeHash;
QList<QString> ImageList;
+ QList<ImageViewer*> ivList;
};
#endif // OBSERVINGLIST_H_
--- branches/kstars/summer/kstars/kstars/tools/observinglist.ui #981696:981697
@@ -612,20 +612,33 @@
<widget class="KImageFilePreview" name="ImagePreview">
<property name="minimumSize">
<size>
- <width>50</width>
+ <width>200</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item>
+ <widget class="QPushButton" name="ExpandImage">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show in ImageViewer</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>40</width>
+ <width>20</width>
<height>20</height>
</size>
</property>
More information about the Kstars-devel
mailing list