[Kstars-devel] KDE/kdeedu/kstars/kstars
Alexey Khudyakov
alexey.skladnoy at gmail.com
Thu Aug 27 00:09:30 CEST 2009
SVN commit 1016064 by khudyakov:
Short: make ImageViewer manage its own deleteion.
Long: use Qt facilities to delete ImageViewer. It will be
deleted when dialog window is closed.
* Set delete on close flag in ImageViewer's constructor
With this it will be deleted when window is closed.
* Remove close event handler in ImageViewer. It no longer needed
* Remove {add,delete}ImageViewer in KStars. It will be
deleted automatically. So there is no need to delete it
manually. List with image viewers deleted too
* Use constructor to create dialog not KStars::addImageViewer
* In observing list remove ivList. ImageViewers delete themselves now.
CCMAIL: kstars-devel at kde.org
M +2 -5 imageviewer.cpp
M +0 -3 imageviewer.h
M +0 -12 kstars.cpp
M +0 -5 kstars.h
M +2 -4 kstarsactions.cpp
M +9 -6 skymap.cpp
M +1 -1 tools/lcgenerator.cpp
M +9 -10 tools/observinglist.cpp
M +0 -1 tools/observinglist.h
--- trunk/KDE/kdeedu/kstars/kstars/imageviewer.cpp #1016063:1016064
@@ -67,6 +67,7 @@
fileIsImage(false),
downloadJob(0)
{
+ setAttribute( Qt::WA_DeleteOnClose, true );
setModal( false );
setCaption( i18n("KStars image viewer")+QString(" : ")+url.fileName() );
setButtons( KDialog::User1|KDialog::Close );
@@ -119,6 +120,7 @@
fileIsImage(true),
downloadJob(0)
{
+ setAttribute( Qt::WA_DeleteOnClose, true );
setModal( false );
setCaption( i18n( "KStars image viewer" ) + QString( " : " ) + FileName );
setButtons( KDialog::Close );
@@ -159,11 +161,6 @@
update();
}
-void ImageViewer::closeEvent (QCloseEvent * ev)
-{
- KStars::Instance()->removeImageViewer( this );
-}
-
void ImageViewer::loadImageFromURL()
{
KUrl saveURL = KUrl::fromPath( file.fileName() );
--- trunk/KDE/kdeedu/kstars/kstars/imageviewer.h #1016063:1016064
@@ -77,9 +77,6 @@
*/
void resizeEvent (QResizeEvent *ev);
- /** Make sure all events have been processed before closing the dialog */
- void closeEvent (QCloseEvent *ev);
-
private:
/**Display the downloaded image. Resize the window to fit the image, If the image is
* larger than the screen, make the image as large as possible while preserving the
--- trunk/KDE/kdeedu/kstars/kstars/kstars.cpp #1016063:1016064
@@ -253,18 +253,6 @@
}
}
-ImageViewer* KStars::addImageViewer( const KUrl &url, const QString &message ) {
- ImageViewer *iv = new ImageViewer( url, message, this );
- m_ImageViewerList.append( iv );
- return iv;
-}
-
-void KStars::removeImageViewer( ImageViewer *iv ) {
- int i = m_ImageViewerList.indexOf( iv );
- if ( i != -1 )
- m_ImageViewerList.takeAt( i )->deleteLater();
-}
-
Execute* KStars::getExecute() {
if( !execute )
execute = new Execute();
--- trunk/KDE/kdeedu/kstars/kstars/kstars.h #1016063:1016064
@@ -49,7 +49,6 @@
class ScriptBuilder;
class PlanetViewer;
class JMoonTool;
-class ImageViewer;
class FlagManager;
class ObservingList;
class EquipmentWriter;
@@ -129,9 +128,6 @@
Execute* getExecute();
- ImageViewer* addImageViewer(const KUrl &url, const QString &message );
- void removeImageViewer( ImageViewer* );
-
/**@return pointer to InfoBoxes object. */
InfoBoxes* infoBoxes();
@@ -685,7 +681,6 @@
ScriptBuilder *sb;
PlanetViewer *pv;
JMoonTool *jmt;
- QList<ImageViewer*> m_ImageViewerList;
FlagManager *fm;
INDIMenu *indimenu;
--- trunk/KDE/kdeedu/kstars/kstars/kstarsactions.cpp #1016063:1016064
@@ -1049,11 +1049,9 @@
//Delete dialog window pointers
clearCachedFindDialog();
- if( ! Options::obsListSaveImage() )
+ if( !Options::obsListSaveImage() ) {
foreach ( QString file, obsList->imageList() )
QFile::remove( KStandardDirs::locateLocal( "appdata", file ) );
-
- while ( ! m_ImageViewerList.isEmpty() )
- delete m_ImageViewerList.takeFirst();
+ }
}
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #1016063:1016064
@@ -370,8 +370,9 @@
KStars* kstars = KStars::Instance();
if( kstars ) {
- ImageViewer *iv = kstars->addImageViewer(
- url, i18n( "Digitized Sky Survey image provided by the Space Telescope Science Institute [public domain]." ));
+ ImageViewer *iv = new ImageViewer( url,
+ i18n( "Digitized Sky Survey image provided by the Space Telescope Science Institute [public domain]." ),
+ this );
iv->show();
}
}
@@ -408,8 +409,9 @@
KStars* kstars = KStars::Instance();
if( kstars ) {
- ImageViewer *iv = kstars->addImageViewer(
- url, i18n( "Sloan Digital Sky Survey image provided by the Astrophysical Research Consortium [free for non-commercial use]." ) );
+ ImageViewer *iv = new ImageViewer( url,
+ i18n( "Sloan Digital Sky Survey image provided by the Astrophysical Research Consortium [free for non-commercial use]." ),
+ this );
iv->show();
}
}
@@ -491,9 +493,10 @@
}
KUrl url ( sURL );
- if ( url.isEmpty() ) return;
+ if( url.isEmpty() )
+ return;
- KStars::Instance()->addImageViewer( url, clickedObject()->messageFromTitle(message) );
+ ImageViewer* iv = new ImageViewer( url, clickedObject()->messageFromTitle(message), this );
}
void SkyMap::slotInfo() {
--- trunk/KDE/kdeedu/kstars/kstars/tools/lcgenerator.cpp #1016063:1016064
@@ -133,7 +133,7 @@
KUrl url(buf);
QString message = i18n( "Light Curve produced by the American Amateur Variable Star Observers" );
- ImageViewer *iv = KStars::Instance()->addImageViewer( url, message );
+ ImageViewer *iv = new ImageViewer( url, message, this );
iv->show();
}
--- trunk/KDE/kdeedu/kstars/kstars/tools/observinglist.cpp #1016063:1016064
@@ -211,16 +211,15 @@
// ui->MiniButton->hide();
}
-ObservingList::~ObservingList() {
- foreach( ImageViewer *iv, ivList ) {
- delete iv;
- }
-}
+ObservingList::~ObservingList()
+{}
+
//SLOTS
void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
bool addToWishList=true;
- if ( ! obj ) obj = ks->map()->clickedObject();
+ if( ! obj )
+ obj = ks->map()->clickedObject();
if( obj->name() == "star" ) {
KMessageBox::sorry(0, i18n( "Unnamed stars are not supported in the observing lists"));
@@ -1250,14 +1249,14 @@
}
void ObservingList::slotImageViewer() {
- ImageViewer *iv;
+ ImageViewer *iv = 0;
if( QFile::exists( CurrentImagePath ) )
iv = new ImageViewer( CurrentImagePath, this );
else if( QFile::exists( CurrentTempPath ) )
iv = new ImageViewer( CurrentTempPath, this );
- // FIXME: iv may be uninitialized here
- ivList.append( iv );
- iv->show();
+
+ if( iv )
+ iv->show();
}
void ObservingList::slotDeleteImages() {
--- trunk/KDE/kdeedu/kstars/kstars/tools/observinglist.h #1016063:1016064
@@ -347,7 +347,6 @@
KIO::Job *downloadJob; // download job of image -> 0 == no job is running
QHash<QString, QTime> TimeHash;
QList<QString> ImageList;
- QList<ImageViewer*> ivList;
ObsListPopupMenu *pmenu;
};
More information about the Kstars-devel
mailing list