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

Jason Harris kstars at 30doradus.org
Mon Aug 27 17:53:10 CEST 2007


SVN commit 705263 by harris:

Restoring image and info links to the popup menu.  They were removed
by the commit that intended to remove the "Add links..." action from
the menu.

CCMAIL: kstars-devel at kde.org



 M  +46 -4     kspopupmenu.cpp  
 M  +11 -0     kspopupmenu.h  


--- trunk/KDE/kdeedu/kstars/kstars/kspopupmenu.cpp #705262:705263
@@ -69,16 +69,18 @@
 	addAction( i18nc( "Second Generation Digitized Sky Survey", "Show 2nd-Gen DSS Image" ), ks->map(), SLOT( slotDSS2() ) );
 }
 
-void KSPopupMenu::createStarMenu( StarObject *star ) 
-{
+void KSPopupMenu::createStarMenu( StarObject *star ) {
 	//Add name, rise/set time, center/track, and detail-window items
 	initPopupMenu( star, star->translatedLongName(), i18n( "Spectral type: %1" , star->sptype()),
 		i18n( "star" ) );
 
 //If the star is named, add custom items to popup menu based on object's ImageList and InfoList
+	if ( star->name() != "star" ) {
+		addLinksToMenu( star );
+	} else {
 		addAction( i18nc( "First Generation Digitized Sky Survey", "Show 1st-Gen DSS Image" ), ks->map(), SLOT( slotDSS() ) );
 		addAction( i18nc( "Second Generation Digitized Sky Survey", "Show 2nd-Gen DSS Image" ), ks->map(), SLOT( slotDSS2() ) );
-	
+	}
 }
 
 void KSPopupMenu::createDeepSkyObjectMenu( SkyObject *obj ) {
@@ -87,6 +89,7 @@
 	if ( obj->longname() != obj->name() ) secondName = obj->translatedLongName();
 
 	initPopupMenu( obj, obj->translatedName(), secondName, TypeName );
+	addLinksToMenu( obj );
 }
 
 void KSPopupMenu::createCustomObjectMenu( SkyObject *obj ) {
@@ -96,6 +99,7 @@
 
 	initPopupMenu( obj, obj->translatedName(), secondName, TypeName );
 
+	addLinksToMenu( obj, true ); 
 }
 
 void KSPopupMenu::createPlanetMenu( SkyObject *p ) {
@@ -105,6 +109,7 @@
 		oname = ((KSMoon *)p)->phaseName();
 	}
 	initPopupMenu( p, p->translatedName(), oname, i18n("Solar System"), true, true, true, true, addTrail );
+	addLinksToMenu( p, false ); //don't offer DSS images for planets
 }
 
 void KSPopupMenu::initPopupMenu( SkyObject *obj, const QString &_s1, const QString &s2, const QString &s3,
@@ -243,6 +248,42 @@
 		addSeparator();
 }
 
+void KSPopupMenu::addLinksToMenu( SkyObject *obj, bool showDSS ) {
+	QString sURL;
+	QStringList::Iterator itList, itTitle, itListEnd;
+
+	itList  = obj->ImageList.begin();
+	itTitle = obj->ImageTitle.begin();
+	itListEnd = obj->ImageList.end();
+
+	int id = 100;
+	for ( ; itList != itListEnd; ++itList ) {
+		QString t = QString(*itTitle);
+		sURL = QString(*itList);
+		addAction( i18nc( "Image/info menu item (should be translated)", t.toLocal8Bit() ), ks->map(), SLOT( slotImage() ) );
+		++itTitle;
+	}
+
+	if ( showDSS ) {
+	  addAction( i18nc( "First Generation Digitized Sky Survey", "Show 1st-Gen DSS Image" ), ks->map(), SLOT( slotDSS() ) );
+	  addAction( i18nc( "Second Generation Digitized Sky Survey", "Show 2nd-Gen DSS Image" ), ks->map(), SLOT( slotDSS2() ) );
+	  addSeparator();
+	}
+	else if ( obj->ImageList.count() ) addSeparator();
+
+	itList  = obj->InfoList.begin();
+	itTitle = obj->InfoTitle.begin();
+	itListEnd = obj->InfoList.end();
+
+	id = 200;
+	for ( ; itList != itListEnd; ++itList ) {
+		QString t = QString(*itTitle);
+		sURL = QString(*itList);
+		addAction( i18nc( "Image/info menu item (should be translated)", t.toLocal8Bit() ), ks->map(), SLOT( slotInfo() ) );
+		++itTitle;
+	}
+}
+
 bool KSPopupMenu::addINDI(void)
 {
 	INDIMenu *indiMenu = ks->getINDIMenu();
@@ -251,6 +292,7 @@
 	INDI_G *grp;
 	INDI_P *prop(NULL);
 	INDI_E *element;
+	int id=0;
 
 	if (indiMenu->mgr.count() == 0)
 		return false;
@@ -326,7 +368,7 @@
 			{
 				menuDevice->addSeparator();
 				//menuDevice->insertItem(i18n("Center && Track Crosshair"), id++);
-				menuDevice->addAction(i18n("Center && Track Crosshair"));
+				QAction *a = menuDevice->addAction(i18n("Center && Track Crosshair"));
 				if (dev->findElem("RA"))
 					prop = dev->findElem("RA")->pp;
 				else
--- trunk/KDE/kdeedu/kstars/kstars/kspopupmenu.h #705262:705263
@@ -69,6 +69,17 @@
 			bool addTrail=false, bool showAngularDistance=true,
 			bool showObsList=true );
 
+/**Add an item to the popup menu for each of the URL links associated with 
+	*this object.  URL links appear in two categories: images and information pages.
+	*For some objects, a link to Digitized Sky Survey images will automatically be added
+	*in addition to the object's normal image links.  Also, for some objects, an
+	*"Add link..." item will be included, which allows the user to add their own custom 
+	*URLs for this object.
+	*@param obj pointer to the skyobject which the menu describes
+	*@param showDSS if true, include DSS Image links
+	*/
+	void addLinksToMenu( SkyObject *obj, bool showDSS=true );
+	
 /**@short Create a popup menu for a star.  
 	*
 	*Stars get the following labels: a primary name and/or a genetive name, 


More information about the Kstars-devel mailing list