[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Thu Apr 22 09:09:14 CEST 2004


CVS commit by harris: 

Fixing FOV symbols, which have apparently been broken since we switched 
to KConfigXT.

CCMAIL: kstars-devel at kde.org


  M +46 -0     fov.cpp   1.2
  M +3 -1      fov.h   1.4
  M +7 -2      kstarsactions.cpp   1.99


--- kdeedu/kstars/kstars/fov.cpp  #1.1:1.2
@@ -17,6 +17,8 @@
 
 #include <qpainter.h>
+#include <qfile.h>
 #include <kdebug.h>
 #include <klocale.h>
+#include <kstandarddirs.h>
 
 #include "fov.h"
@@ -26,4 +28,48 @@ FOV::FOV( QString n, float sz, int sh, Q
 {}
 
+FOV::FOV() : Name( i18n( "No FOV" ) ), Size( 0.0 ), Shape( 0 ), Color( "#FFFFFF" )
+{}
+
+FOV::FOV( QString sname ) {
+        QFile f;
+        f.setName( locateLocal( "appdata", "fov.dat" ) );
+        
+        int sh;
+        float sz;
+
+        if ( f.open( IO_ReadOnly ) ) {
+                QTextStream stream( &f );
+                while ( !stream.eof() ) {
+                        QStringList fields = QStringList::split( ":", stream.readLine() );
+                        bool ok( false );
+
+                        if ( fields.count() == 4 ) {
+                                if ( fields[0] == sname ) {
+                                        sz = (float)(fields[1].toDouble( &ok ));
+                                        if ( ok ) {
+                                                sh = fields[2].toInt( &ok );
+                                                if ( ok ) {
+                                                        Name = fields[0];
+                                                        Size = sz;
+                                                        Shape = sh;
+                                                        Color = fields[3]; 
+                                                        
+                                                        return;
+                                                }
+                                        }
+                                        
+                                        break;
+                                }
+                        }
+                }
+        }
+        
+        //If we get here, then the symbol could not be assigned
+        Name = i18n( "No FOV" );
+        Size = 0.0;
+        Shape = 0;
+        Color = "#FFFFFF";
+}
+
 void FOV::draw( QPainter &p, float pixelsize ) {
         p.setPen( QColor( color() ) );

--- kdeedu/kstars/kstars/fov.h  #1.3:1.4
@@ -31,5 +31,7 @@ class QPainter;
 class FOV {
         public:
-                FOV( QString name=i18n( "No FOV" ), float size=0.0, int shape=0, QString color="#FFFFFF" );
+                FOV();
+                FOV( QString name );  //in this case, read params from fov.dat
+                FOV( QString name, float size, int shape=0, QString color="#FFFFFF" );
                 ~FOV() {}
 

--- kdeedu/kstars/kstars/kstarsactions.cpp  #1.98:1.99
@@ -760,6 +760,11 @@ void KStars::slotColorScheme() {
 void KStars::slotTargetSymbol() {
         QString symbolName( sender()->name() );
-        Options::setFOVName( symbolName );
-        data()->fovSymbol.setName( symbolName );
+        FOV f( symbolName ); //read data from fov.dat
+        
+        Options::setFOVName( f.name() );
+        Options::setFOVSize( f.size() );
+        Options::setFOVShape( f.shape() );
+        Options::setFOVColor( f.color() );
+        data()->fovSymbol.setName( Options::fOVName() );
         data()->fovSymbol.setSize( Options::fOVSize() );
         data()->fovSymbol.setShape( Options::fOVShape() );




More information about the Kstars-devel mailing list