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

Jason Harris kstars at 30doradus.org
Tue Jul 25 17:21:11 CEST 2006


SVN commit 566161 by harris:

dms: more robust error checking in setFromString()

dmsBox: make sure color turns to black when text is entered.

LocationDialog:  don't show "I18N_EMPTY_STRING" in province field when 
there is no province name.

MapCanvas:  Fix drawing of city points in the map; fix clicking on map 
to find nearby cities.

TODO: the "DST Rule" KActiveLabel in LocationDialog is still not 
clickable (it should display a window explaining the DST rules).

CCMAIL: kstars-devel at kde.org



 M  +4 -6      dms.cpp  
 M  +5 -1      locationdialog.cpp  
 M  +3 -0      widgets/dmsbox.cpp  
 M  +6 -9      widgets/mapcanvas.cpp  
 M  +9 -3      widgets/mapcanvas.h  


--- trunk/KDE/kdeedu/kstars/kstars/dms.cpp #566160:566161
@@ -66,16 +66,14 @@
 	entry.replace( QRegExp("d"), QString() );
 	entry.replace( QRegExp("m"), QString() );
 	entry.replace( QRegExp("s"), QString() );
-	QString sdeg;
-	sdeg.sprintf("%c", 176);
-	entry.replace( QRegExp(sdeg), QString() );
+	entry.replace( QChar(176), QString() );
 	entry.replace( QRegExp("\'"), QString() );
 	entry.replace( QRegExp("\""), QString() );
 
 	//Account for localized decimal-point settings
 	//QString::toDouble() requires that the decimal symbol is "."
 	entry.replace( KGlobal::locale()->decimalSymbol(), "." );
- 
+
 	//empty entry returns false
 	if ( entry.isEmpty() ) {
 		setD( 0.0 );
@@ -103,8 +101,8 @@
 
 	//check for colon-delimiters or space-delimiters
 	if ( entry.contains(':') )
-		fields = entry.split( ':' );
-	else fields = entry.split( " " );
+		fields = entry.split( ':', QString::SkipEmptyParts );
+	else fields = entry.split( " ", QString::SkipEmptyParts );
 
 	//anything with one field is invalid!
 	if ( fields.count() == 1 ) {
--- trunk/KDE/kdeedu/kstars/kstars/locationdialog.cpp #566160:566161
@@ -176,7 +176,11 @@
 	if ( SelectedCity ) {
 		KStars *p = (KStars *)parent();
 		ui->NewCityName->setText( SelectedCity->translatedName() );
-		ui->NewProvinceName->setText( SelectedCity->translatedProvince() );
+		if ( SelectedCity->province().isEmpty() )
+			ui->NewProvinceName->setText( QString() );
+		else
+			ui->NewProvinceName->setText( SelectedCity->translatedProvince() );
+		
 		ui->NewCountryName->setText( SelectedCity->translatedCountry() );
 		ui->NewLong->showInDegrees( SelectedCity->lng() );
 		ui->NewLat->showInDegrees( SelectedCity->lat() );
--- trunk/KDE/kdeedu/kstars/kstars/widgets/dmsbox.cpp #566160:566161
@@ -35,6 +35,9 @@
 	setDegType( dg );
 	psave = palette();
 
+	//Somehow, the color is getting reset to grey already!
+	psave.setColor( QPalette::Active, QPalette::Text, Qt::black );
+
 	connect( this, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotTextChanged( const QString & ) ) );
 }
 
--- trunk/KDE/kdeedu/kstars/kstars/widgets/mapcanvas.cpp #566160:566161
@@ -27,15 +27,17 @@
 #include "../kstars.h"
 #include "../kstarsdata.h"
 
-MapCanvas::MapCanvas( QWidget *parent ) : QFrame(parent) {
-	//FIXME: pass ld and kstars pointers as ctor arguments
-	LocationDialog *ld = (LocationDialog *)topLevelWidget();
-	KStars *ks = (KStars *)ld->parent();
+MapCanvas::MapCanvas( QWidget *parent ) : QFrame( parent ) {
+	ld = (LocationDialog *)topLevelWidget();
+	ks = (KStars *)ld->parent();
 
 	setAutoFillBackground( false );
 
 	QString bgFile = ks->data()->stdDirs->findResource( "data", "kstars/geomap.png" );
 	bgImage = new QPixmap( bgFile );
+
+	origin.setX( bgImage->width()/2 );
+	origin.setY( bgImage->height()/2 );
 }
 
 MapCanvas::~MapCanvas(){
@@ -55,8 +57,6 @@
 }
 
 void MapCanvas::mousePressEvent( QMouseEvent *e ) {
-	LocationDialog *ld = (LocationDialog *)topLevelWidget();
-
 	//Determine Lat/Long corresponding to event press
 	int lng = ( e->x() - origin.x() );
 	int lat  = ( origin.y() - e->y() );
@@ -66,8 +66,6 @@
 
 void MapCanvas::paintEvent( QPaintEvent * ) {
 	QPainter p;
-	LocationDialog *ld = (LocationDialog *)topLevelWidget();
-  KStars *ks = (KStars *)ld->parent();
 
 	//prepare the canvas
 	p.begin( this );
@@ -76,7 +74,6 @@
 
 	//Draw cities
 	QPoint o;
-
 	foreach ( GeoLocation *g, ks->data()->geoList ) {
 		o.setX( int( g->lng()->Degrees() + origin.x() ) );
 		o.setY( height() - int( g->lat()->Degrees() + origin.y() ) );
--- trunk/KDE/kdeedu/kstars/kstars/widgets/mapcanvas.h #566160:566161
@@ -34,15 +34,19 @@
 	*/
 
 class QPixmap;
+class LocationDialog;
+class KStars;
 
 class MapCanvas : public QFrame {
 	Q_OBJECT
 public: 
 	/**Default constructor.  Initialize the widget: create pixmaps, load the
-		*world map bitmap, set pointers to the main window and the
-		*LocationDialog parent.
+		*world map image
+		*@param ks pointer to the KStars object
+		*@param ld pointer to the parent LocationDialog
 		*/
-	MapCanvas(QWidget *parent=0);
+	MapCanvas( QWidget *parent );
+
 	/**Destructor (empty)
 		*/
 	~MapCanvas();
@@ -85,6 +89,8 @@
 	virtual void mousePressEvent( QMouseEvent *e );
 
 private:
+	KStars *ks;
+	LocationDialog *ld;
 	QPixmap *bgImage;
 	QString BGColor;
 	QPoint origin;


More information about the Kstars-devel mailing list