• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

scriptbuilder.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           scriptbuilder.cpp  -  description
00003                              -------------------
00004     begin                : Thu Apr 17 2003
00005     copyright            : (C) 2003 by Jason Harris
00006     email                : kstars@30doradus.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 //needed in slotSave() for chmod() syscall
00019 #include <sys/stat.h>
00020 
00021 #include <kdebug.h>
00022 #include <kpushbutton.h>
00023 #include <kcolorbutton.h>
00024 #include <klocale.h>
00025 #include <kcombobox.h>
00026 #include <kicontheme.h>
00027 #include <kiconloader.h>
00028 #include <kio/netaccess.h>
00029 #include <klistbox.h>
00030 #include <klistview.h>
00031 #include <kprocess.h>
00032 #include <ktextedit.h>
00033 #include <ktempfile.h>
00034 #include <kdatewidget.h>
00035 #include <kmessagebox.h>
00036 #include <kfiledialog.h>
00037 #include <kstdguiitem.h>
00038 #include <kstandarddirs.h>
00039 #include <kurl.h>
00040 #include <kurlrequester.h>
00041 #include <knuminput.h>
00042 
00043 #include <qcheckbox.h>
00044 #include <qspinbox.h>
00045 #include <qwidgetstack.h>
00046 #include <qwidget.h>
00047 #include <qptrlist.h>
00048 #include <qlayout.h>
00049 #include <qdatetimeedit.h>
00050 #include <qradiobutton.h>
00051 #include <qbuttongroup.h>
00052 
00053 #include "scriptfunction.h"
00054 #include "scriptbuilderui.h"
00055 #include "scriptnamedialog.h"
00056 #include "optionstreeview.h"
00057 
00058 #include "arglooktoward.h"
00059 #include "argsetradec.h"
00060 #include "argsetaltaz.h"
00061 #include "argsetlocaltime.h"
00062 #include "argwaitfor.h"
00063 #include "argwaitforkey.h"
00064 #include "argsettrack.h"
00065 #include "argchangeviewoption.h"
00066 #include "argsetgeolocation.h"
00067 #include "argtimescale.h"
00068 #include "argzoom.h"
00069 #include "argexportimage.h"
00070 #include "argprintimage.h"
00071 #include "argsetcolor.h"
00072 #include "argloadcolorscheme.h"
00073 #include "argstartindi.h"
00074 #include "argshutdownindi.h"
00075 #include "argswitchindi.h"
00076 #include "argsetportindi.h"
00077 #include "argsettargetcoordindi.h"
00078 #include "argsettargetnameindi.h"
00079 #include "argsetactionindi.h"
00080 #include "argsetfocusspeedindi.h"
00081 #include "argstartfocusindi.h"
00082 #include "argsetfocustimeoutindi.h"
00083 #include "argsetgeolocationindi.h"
00084 #include "argstartexposureindi.h"
00085 #include "argsetutcindi.h"
00086 #include "argsetscopeactionindi.h"
00087 #include "argsetframetypeindi.h"
00088 #include "argsetccdtempindi.h"
00089 #include "argsetfilternumindi.h"
00090 
00091 #include "scriptbuilder.h"
00092 #include "kstars.h"
00093 #include "kstarsdata.h"
00094 #include "skymap.h"
00095 #include "kstarsdatetime.h"
00096 #include "dmsbox.h"
00097 #include "finddialog.h"
00098 #include "locationdialog.h"
00099 #include "skyobjectname.h"
00100 #include "timestepbox.h"
00101 #include "libkdeedu/extdate/extdatewidget.h"
00102 
00103 ScriptBuilder::ScriptBuilder( QWidget *parent, const char *name )
00104  : KDialogBase( KDialogBase::Plain, i18n( "Script Builder" ), Close, Close, parent, name ), 
00105         UnsavedChanges(false), currentFileURL(), currentDir( QDir::homeDirPath() ), 
00106         currentScriptName(), currentAuthor() {
00107 
00108     QFrame *page = plainPage();
00109 
00110     ks = (KStars*)parent;
00111     QVBoxLayout *vlay = new QVBoxLayout( page, 0, 0 );
00112     sb = new ScriptBuilderUI( page );
00113     vlay->addWidget( sb );
00114 
00115     KStarsFunctionList.setAutoDelete( TRUE );
00116     INDIFunctionList.setAutoDelete( TRUE);
00117     ScriptList.setAutoDelete( TRUE );
00118 
00119     //Initialize function templates and descriptions
00120     KStarsFunctionList.append( new ScriptFunction( "lookTowards", i18n( "Point the display at the specified location. %1 can be the name of an object, a cardinal point on the compass, or 'zenith'." ),
00121             false, "QString", "dir" ) );
00122     KStarsFunctionList.append( new ScriptFunction( "setRaDec", i18n( "Point the display at the specified RA/Dec coordinates.  %1 is expressed in Hours; %2 is expressed in Degrees." ),
00123             false, "double", "ra", "double", "dec" ) );
00124     KStarsFunctionList.append( new ScriptFunction( "setAltAz", i18n( "Point the display at the specified Alt/Az coordinates.  %1 and %2 are expressed in Degrees." ),
00125             false, "double", "alt", "double", "az" ) );
00126     KStarsFunctionList.append( new ScriptFunction( "zoomIn", i18n( "Increase the display Zoom Level." ), false ) );
00127     KStarsFunctionList.append( new ScriptFunction( "zoomOut", i18n( "Decrease the display Zoom Level." ), false ) );
00128     KStarsFunctionList.append( new ScriptFunction( "defaultZoom", i18n( "Set the display Zoom Level to its default value." ), false ) );
00129     KStarsFunctionList.append( new ScriptFunction( "zoom", i18n( "Set the display Zoom Level manually." ), false, "double", "z" ) );
00130     KStarsFunctionList.append( new ScriptFunction( "setLocalTime", i18n( "Set the system clock to the specified Local Time." ),
00131             false, "int", "year", "int", "month", "int", "day", "int", "hour", "int", "minute", "int", "second" ) );
00132     KStarsFunctionList.append( new ScriptFunction( "waitFor", i18n( "Pause script execution for %1 seconds." ), false, "double", "sec" ) );
00133     KStarsFunctionList.append( new ScriptFunction( "waitForKey", i18n( "Halt script execution until the key %1 is pressed.  Only single-key strokes are possible; use 'space' for the spacebar." ),
00134             false, "QString", "key" ) );
00135     KStarsFunctionList.append( new ScriptFunction( "setTracking", i18n( "Set whether the display is tracking the current location." ), false, "bool", "track" ) );
00136     KStarsFunctionList.append( new ScriptFunction( "changeViewOption", i18n( "Change view option named %1 to value %2." ), false, "QString", "opName", "QString", "opValue" ) );
00137     KStarsFunctionList.append( new ScriptFunction( "setGeoLocation", i18n( "Set the geographic location to the city specified by %1, %2 and %3." ),
00138             false, "QString", "cityName", "QString", "provinceName", "QString", "countryName" ) );
00139     KStarsFunctionList.append( new ScriptFunction( "setColor", i18n( "Set the color named %1 to the value %2." ), false, "QString", "colorName", "QString", "value" ) );
00140     KStarsFunctionList.append( new ScriptFunction( "loadColorScheme", i18n( "Load the color scheme named %1." ), false, "QString", "name" ) );
00141     KStarsFunctionList.append( new ScriptFunction( "exportImage", i18n( "Export the sky image to the file %1, with width %2 and height %3." ), false, "QString", "fileName", "int", "width", "int", "height" ) );
00142     KStarsFunctionList.append( new ScriptFunction( "printImage", i18n( "Print the sky image to a printer or file.  If %1 is true, it will show the print dialog.  If %2 is true, it will use the Star Chart color scheme for printing." ), false, "bool", "usePrintDialog", "bool", "useChartColors" ) );
00143     KStarsFunctionList.append( new ScriptFunction( "stop", i18n( "Halt the simulation clock." ), true ) );
00144     KStarsFunctionList.append( new ScriptFunction( "start", i18n( "Start the simulation clock." ), true ) );
00145     KStarsFunctionList.append( new ScriptFunction( "setClockScale", i18n( "Set the timescale of the simulation clock to %1.  1.0 means real-time; 2.0 means twice real-time; etc." ), true, "double", "scale" ) );
00146     
00147     // INDI fuctions
00148     ScriptFunction *startINDIFunc(NULL), *shutdownINDIFunc(NULL), *switchINDIFunc(NULL), *setINDIPortFunc(NULL), *setINDIScopeActionFunc(NULL), *setINDITargetCoordFunc(NULL), *setINDITargetNameFunc(NULL), *setINDIGeoLocationFunc(NULL), *setINDIUTCFunc(NULL), *setINDIActionFunc(NULL), *waitForINDIActionFunc(NULL), *setINDIFocusSpeedFunc(NULL), *startINDIFocusFunc(NULL), *setINDIFocusTimeoutFunc(NULL), *setINDICCDTempFunc(NULL), *setINDIFilterNumFunc(NULL), *setINDIFrameTypeFunc(NULL), *startINDIExposureFunc(NULL); 
00149     
00150     startINDIFunc = new ScriptFunction( "startINDI", i18n("Establish an INDI device either in local mode or server mode."), false, "QString", "deviceName", "bool", "useLocal");
00151     INDIFunctionList.append ( startINDIFunc );
00152     
00153     shutdownINDIFunc = new ScriptFunction( "shutdownINDI", i18n("Shutdown an INDI device."), false, "QString", "deviceName");
00154     INDIFunctionList.append ( shutdownINDIFunc);
00155     
00156     switchINDIFunc = new ScriptFunction( "switchINDI", i18n("Connect or Disconnect an INDI device."), false, "QString", "deviceName", "bool", "turnOn");
00157     switchINDIFunc->setINDIProperty("CONNECTION");
00158     INDIFunctionList.append ( switchINDIFunc);
00159     
00160     setINDIPortFunc = new ScriptFunction( "setINDIPort", i18n("Set INDI's device connection port."), false, "QString", "deviceName", "QString", "port");
00161     setINDIPortFunc->setINDIProperty("DEVICE_PORT");
00162     INDIFunctionList.append ( setINDIPortFunc);
00163     
00164     setINDIScopeActionFunc = new ScriptFunction( "setINDIScopeAction", i18n("Set the telescope action. Available actions are SLEW, TRACK, SYNC, PARK, and ABORT."), false, "QString", "deviceName", "QString", "action");
00165     setINDIScopeActionFunc->setINDIProperty("CHECK");
00166     INDIFunctionList.append( setINDIScopeActionFunc);
00167     
00168     setINDITargetCoordFunc = new ScriptFunction ( "setINDITargetCoord", i18n( "Set the telescope target coordinates to the RA/Dec coordinates.  RA is expressed in Hours; DEC is expressed in Degrees." ), false, "QString", "deviceName", "double", "RA", "double", "DEC" );
00169     setINDITargetCoordFunc->setINDIProperty("EQUATORIAL_EOD_COORD");
00170     INDIFunctionList.append ( setINDITargetCoordFunc );
00171     
00172     setINDITargetNameFunc = new ScriptFunction( "setINDITargetName", i18n("Set the telescope target coorinates to the RA/Dec coordinates of the selected object."), false, "QString", "deviceName", "QString", "objectName");
00173     setINDITargetNameFunc->setINDIProperty("EQUATORIAL_EOD_COORD");
00174     INDIFunctionList.append( setINDITargetNameFunc);
00175     
00176     setINDIGeoLocationFunc = new ScriptFunction ( "setINDIGeoLocation", i18n("Set the telescope longitude and latitude. The longitude is E of N."), false, "QString", "deviceName", "double", "long", "double", "lat");
00177     setINDIGeoLocationFunc->setINDIProperty("GEOGRAPHIC_COORD");
00178     INDIFunctionList.append( setINDIGeoLocationFunc);
00179     
00180     setINDIUTCFunc = new ScriptFunction ( "setINDIUTC", i18n("Set the device UTC time in ISO 8601 format YYYY/MM/DDTHH:MM:SS."), false, "QString", "deviceName", "QString", "UTCDateTime");
00181     setINDIUTCFunc->setINDIProperty("TIME");
00182     INDIFunctionList.append( setINDIUTCFunc);
00183     
00184     setINDIActionFunc = new ScriptFunction( "setINDIAction", i18n("Activate an INDI action. The action is the name of any INDI switch property element supported by the device."), false, "QString", "deviceName", "QString", "actionName");
00185     INDIFunctionList.append( setINDIActionFunc);
00186     
00187     waitForINDIActionFunc = new ScriptFunction ("waitForINDIAction", i18n("Pause script execution until action returns with OK status. The action can be the name of any INDI property supported by the device."), false, "QString", "deviceName", "QString", "actionName");
00188     INDIFunctionList.append( waitForINDIActionFunc );
00189     
00190     setINDIFocusSpeedFunc = new ScriptFunction ("setINDIFocusSpeed", i18n("Set the telescope focuser speed. Set speed to 0 to halt the focuser. 1-3 correspond to slow, medium, and fast speeds respectively."), false, "QString", "deviceName", "unsigned int", "speed");
00191     setINDIFocusSpeedFunc->setINDIProperty("FOCUS_SPEED");
00192     INDIFunctionList.append( setINDIFocusSpeedFunc );
00193     
00194     startINDIFocusFunc = new ScriptFunction ("startINDIFocus", i18n("Start moving the focuser in the direction Dir, and for the duration specified by setINDIFocusTimeout."), false, "QString", "deviceName", "QString", "Dir");
00195     startINDIFocusFunc->setINDIProperty("FOCUS_MOTION");
00196     INDIFunctionList.append( startINDIFocusFunc);
00197     
00198     setINDIFocusTimeoutFunc = new ScriptFunction ( "setINDIFocusTimeout", i18n("Set the telescope focuser timer in seconds. This is the duration of any focusing procedure performed by calling startINDIFocus."), false, "QString", "deviceName", "int", "timeout");
00199     setINDIFocusTimeoutFunc->setINDIProperty("FOCUS_TIMER");
00200     INDIFunctionList.append( setINDIFocusTimeoutFunc);
00201     
00202     setINDICCDTempFunc = new ScriptFunction( "setINDICCDTemp", i18n("Set the target CCD chip temperature."), false, "QString", "deviceName", "int", "temp");
00203     setINDICCDTempFunc->setINDIProperty("CCD_TEMPERATURE");
00204     INDIFunctionList.append( setINDICCDTempFunc);
00205 
00206         setINDIFilterNumFunc = new ScriptFunction( "setINDIFilterNum", i18n("Set the target filter position."), false, "QString", "deviceName", "int", "filter_num");
00207     setINDIFilterNumFunc->setINDIProperty("FILTER_SLOT");
00208     INDIFunctionList.append ( setINDIFilterNumFunc);
00209     
00210     setINDIFrameTypeFunc = new ScriptFunction( "setINDIFrameType", i18n("Set the CCD camera frame type. Available options are FRAME_LIGHT, FRAME_BIAS, FRAME_DARK, and FRAME_FLAT."), false, "QString", "deviceName", "QString", "type");
00211     setINDIFrameTypeFunc->setINDIProperty("FRAME_TYPE");
00212     INDIFunctionList.append( setINDIFrameTypeFunc);
00213     
00214     startINDIExposureFunc = new ScriptFunction ( "startINDIExposure", i18n("Start Camera/CCD exposure. The duration is in seconds."), false, "QString", "deviceName", "int", "timeout");
00215     startINDIExposureFunc->setINDIProperty("CCD_EXPOSE_DURATION");
00216     INDIFunctionList.append( startINDIExposureFunc);
00217     
00218     
00219     // Modified by JM
00220     // We're using KListView instead of listbox to arrange the functions in two
00221     // main categories: KStars and INDI. INDI is further subdivided.
00222     
00223     sb->FunctionListView->addColumn(i18n("Functions"));
00224     sb->FunctionListView->setSorting(-1);
00225     
00226     QListViewItem *INDI_tree = new QListViewItem( sb->FunctionListView, "INDI");
00227         QListViewItem *INDI_filter = new QListViewItem( INDI_tree, "Filter");
00228     QListViewItem *INDI_focuser = new QListViewItem( INDI_tree, "Focuser");
00229     QListViewItem *INDI_ccd = new QListViewItem( INDI_tree, "Camera/CCD");
00230     QListViewItem *INDI_telescope = new QListViewItem( INDI_tree, "Telescope");
00231         QListViewItem *INDI_general = new QListViewItem( INDI_tree, "General");
00232         
00233     QListViewItem *kstars_tree = new QListViewItem( sb->FunctionListView, "KStars");
00234         
00235     
00236     for ( ScriptFunction *sf = KStarsFunctionList.last(); sf; sf = KStarsFunctionList.prev() )
00237         new QListViewItem (kstars_tree, sf->prototype());
00238     
00239           // General
00240           new QListViewItem(INDI_general, waitForINDIActionFunc->prototype());
00241           new QListViewItem(INDI_general, setINDIActionFunc->prototype());
00242       new QListViewItem(INDI_general, setINDIPortFunc->prototype());
00243       new QListViewItem(INDI_general, switchINDIFunc->prototype());
00244       new QListViewItem(INDI_general, shutdownINDIFunc->prototype());
00245       new QListViewItem(INDI_general, startINDIFunc->prototype());
00246 
00247       // Telescope
00248       new QListViewItem(INDI_telescope, setINDIUTCFunc->prototype());
00249       new QListViewItem(INDI_telescope, setINDIGeoLocationFunc->prototype());
00250       new QListViewItem(INDI_telescope, setINDITargetNameFunc->prototype());
00251       new QListViewItem(INDI_telescope, setINDITargetCoordFunc->prototype());
00252       new QListViewItem(INDI_telescope, setINDIScopeActionFunc->prototype());
00253 
00254       // CCD
00255       new QListViewItem(INDI_ccd, startINDIExposureFunc->prototype());
00256       new QListViewItem(INDI_ccd, setINDIFrameTypeFunc->prototype());
00257       new QListViewItem(INDI_ccd, setINDICCDTempFunc->prototype());
00258 
00259       // Focuser
00260       new QListViewItem(INDI_focuser, startINDIFocusFunc->prototype());
00261       new QListViewItem(INDI_focuser, setINDIFocusTimeoutFunc->prototype());
00262           new QListViewItem(INDI_focuser, setINDIFocusSpeedFunc->prototype());
00263 
00264       // Filter
00265           new QListViewItem(INDI_filter, setINDIFilterNumFunc->prototype());
00266 
00267     //Add icons to Push Buttons
00268     KIconLoader *icons = KGlobal::iconLoader();
00269     sb->NewButton->setIconSet( icons->loadIcon( "filenew", KIcon::Toolbar ) );
00270     sb->OpenButton->setIconSet( icons->loadIcon( "fileopen", KIcon::Toolbar ) );
00271     sb->SaveButton->setIconSet( icons->loadIconSet( "filesave", KIcon::Toolbar ) );
00272     sb->SaveAsButton->setIconSet( icons->loadIconSet( "filesaveas", KIcon::Toolbar ) );
00273     sb->RunButton->setIconSet( icons->loadIconSet( "launch", KIcon::Toolbar ) );
00274     sb->CopyButton->setIconSet( icons->loadIconSet( "reload", KIcon::Toolbar ) );
00275     sb->AddButton->setIconSet( icons->loadIconSet( "back", KIcon::Toolbar ) );
00276     sb->RemoveButton->setIconSet( icons->loadIconSet( "forward", KIcon::Toolbar ) );
00277     sb->UpButton->setIconSet( icons->loadIconSet( "up", KIcon::Toolbar ) );
00278     sb->DownButton->setIconSet( icons->loadIconSet( "down", KIcon::Toolbar ) );
00279 
00280     //Prepare the widget stack
00281     argBlank = new QWidget( sb->ArgStack );
00282     argLookToward = new ArgLookToward( sb->ArgStack );
00283     argSetRaDec = new ArgSetRaDec( sb->ArgStack );
00284     argSetAltAz = new ArgSetAltAz( sb->ArgStack );
00285     argSetLocalTime = new ArgSetLocalTime( sb->ArgStack );
00286     argWaitFor = new ArgWaitFor( sb->ArgStack );
00287     argWaitForKey = new ArgWaitForKey( sb->ArgStack );
00288     argSetTracking = new ArgSetTrack( sb->ArgStack );
00289     argChangeViewOption = new ArgChangeViewOption( sb->ArgStack );
00290     argSetGeoLocation = new ArgSetGeoLocation( sb->ArgStack );
00291     argTimeScale = new ArgTimeScale( sb->ArgStack );
00292     argZoom = new ArgZoom( sb->ArgStack );
00293     argExportImage = new ArgExportImage( sb->ArgStack );
00294     argPrintImage = new ArgPrintImage( sb->ArgStack );
00295     argSetColor = new ArgSetColor( sb->ArgStack );
00296     argLoadColorScheme = new ArgLoadColorScheme( sb->ArgStack );
00297     argStartINDI = new ArgStartINDI (sb->ArgStack);
00298     argShutdownINDI = new ArgShutdownINDI (sb->ArgStack);
00299     argSwitchINDI   = new ArgSwitchINDI (sb->ArgStack);
00300     argSetPortINDI  = new ArgSetPortINDI (sb->ArgStack);
00301     argSetTargetCoordINDI = new ArgSetTargetCoordINDI (sb->ArgStack);
00302     argSetTargetNameINDI  = new ArgSetTargetNameINDI (sb->ArgStack);
00303     argSetActionINDI      = new ArgSetActionINDI (sb->ArgStack);
00304     argWaitForActionINDI  = new ArgSetActionINDI (sb->ArgStack);
00305     argSetFocusSpeedINDI  = new ArgSetFocusSpeedINDI (sb->ArgStack);
00306     argStartFocusINDI     = new ArgStartFocusINDI(sb->ArgStack);
00307     argSetFocusTimeoutINDI = new ArgSetFocusTimeoutINDI( sb->ArgStack);
00308     argSetGeoLocationINDI  = new ArgSetGeoLocationINDI( sb->ArgStack);
00309     argStartExposureINDI   = new ArgStartExposureINDI( sb->ArgStack);
00310     argSetUTCINDI          = new ArgSetUTCINDI( sb->ArgStack);
00311     argSetScopeActionINDI  = new ArgSetScopeActionINDI( sb->ArgStack);
00312     argSetFrameTypeINDI    = new ArgSetFrameTypeINDI (sb->ArgStack);
00313     argSetCCDTempINDI      = new ArgSetCCDTempINDI(sb->ArgStack);
00314     argSetFilterNumINDI    = new ArgSetFilterNumINDI(sb->ArgStack);
00315     
00316     argStartFocusINDI->directionCombo->insertItem("IN");
00317     argStartFocusINDI->directionCombo->insertItem("OUT");
00318     
00319     argSetScopeActionINDI->actionCombo->insertItem("SLEW");
00320     argSetScopeActionINDI->actionCombo->insertItem("TRACK");
00321     argSetScopeActionINDI->actionCombo->insertItem("SYNC");
00322     argSetScopeActionINDI->actionCombo->insertItem("PARK");
00323     argSetScopeActionINDI->actionCombo->insertItem("ABORT");
00324     
00325     argSetFrameTypeINDI->typeCombo->insertItem("FRAME_LIGHT");
00326     argSetFrameTypeINDI->typeCombo->insertItem("FRAME_BIAS");
00327     argSetFrameTypeINDI->typeCombo->insertItem("FRAME_DARK");
00328     argSetFrameTypeINDI->typeCombo->insertItem("FRAME_FLAT");
00329     
00330     sb->ArgStack->addWidget( argBlank );
00331     sb->ArgStack->addWidget( argLookToward );
00332     sb->ArgStack->addWidget( argSetRaDec );
00333     sb->ArgStack->addWidget( argSetAltAz );
00334     sb->ArgStack->addWidget( argSetLocalTime );
00335     sb->ArgStack->addWidget( argWaitFor );
00336     sb->ArgStack->addWidget( argWaitForKey );
00337     sb->ArgStack->addWidget( argSetTracking );
00338     sb->ArgStack->addWidget( argChangeViewOption );
00339     sb->ArgStack->addWidget( argSetGeoLocation );
00340     sb->ArgStack->addWidget( argTimeScale );
00341     sb->ArgStack->addWidget( argZoom );
00342     sb->ArgStack->addWidget( argExportImage );
00343     sb->ArgStack->addWidget( argPrintImage );
00344     sb->ArgStack->addWidget( argSetColor );
00345     sb->ArgStack->addWidget( argLoadColorScheme );
00346     
00347     sb->ArgStack->addWidget( argStartINDI);
00348     sb->ArgStack->addWidget( argShutdownINDI);
00349     sb->ArgStack->addWidget( argSwitchINDI);
00350     sb->ArgStack->addWidget( argSetPortINDI);
00351     sb->ArgStack->addWidget( argSetTargetCoordINDI);
00352     sb->ArgStack->addWidget( argSetTargetNameINDI);
00353     sb->ArgStack->addWidget( argSetActionINDI);
00354     sb->ArgStack->addWidget( argWaitForActionINDI );
00355     sb->ArgStack->addWidget( argSetFocusSpeedINDI );
00356     sb->ArgStack->addWidget( argStartFocusINDI);
00357     sb->ArgStack->addWidget( argSetFocusTimeoutINDI);
00358     sb->ArgStack->addWidget( argSetGeoLocationINDI);
00359     sb->ArgStack->addWidget( argStartExposureINDI);
00360     sb->ArgStack->addWidget( argSetUTCINDI);
00361     sb->ArgStack->addWidget( argSetScopeActionINDI);
00362     sb->ArgStack->addWidget( argSetFrameTypeINDI);
00363     sb->ArgStack->addWidget( argSetCCDTempINDI);
00364     sb->ArgStack->addWidget( argSetFilterNumINDI);
00365     
00366     sb->ArgStack->raiseWidget( 0 );
00367 
00368     snd = new ScriptNameDialog( ks );
00369     otv = new OptionsTreeView( ks );
00370 
00371     initViewOptions();
00372 
00373     //connect widgets in ScriptBuilderUI
00374     connect( sb->FunctionListView, SIGNAL( doubleClicked(QListViewItem *, const QPoint &, int )), this, SLOT( slotAddFunction() ) );
00375     connect( sb->FunctionListView, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( slotShowDoc() ) );
00376     connect( sb->UpButton, SIGNAL( clicked() ), this, SLOT( slotMoveFunctionUp() ) );
00377     connect( sb->ScriptListBox, SIGNAL( currentChanged(QListBoxItem*) ), this, SLOT( slotArgWidget() ) );
00378     connect( sb->DownButton, SIGNAL( clicked() ), this, SLOT( slotMoveFunctionDown() ) );
00379     connect( sb->CopyButton, SIGNAL( clicked() ), this, SLOT( slotCopyFunction() ) );
00380     connect( sb->RemoveButton, SIGNAL( clicked() ), this, SLOT( slotRemoveFunction() ) );
00381     connect( sb->NewButton, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
00382     connect( sb->OpenButton, SIGNAL( clicked() ), this, SLOT( slotOpen() ) );
00383     connect( sb->SaveButton, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
00384     connect( sb->SaveAsButton, SIGNAL( clicked() ), this, SLOT( slotSaveAs() ) );
00385     connect( sb->AddButton, SIGNAL( clicked() ), this, SLOT( slotAddFunction() ) );
00386     connect( sb->RunButton, SIGNAL( clicked() ), this, SLOT( slotRunScript() ) );
00387 
00388     //Connections for Arg Widgets
00389     connect( argSetGeoLocation->FindCityButton, SIGNAL( clicked() ), this, SLOT( slotFindCity() ) );
00390     connect( argLookToward->FindButton, SIGNAL( clicked() ), this, SLOT( slotFindObject() ) );
00391     connect( argChangeViewOption->TreeButton, SIGNAL( clicked() ), this, SLOT( slotShowOptions() ) );
00392 
00393     connect( argLookToward->FocusEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotLookToward() ) );
00394     connect( argSetRaDec->RaBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotRa() ) );
00395     connect( argSetRaDec->DecBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotDec() ) );
00396     connect( argSetAltAz->AltBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotAlt() ) );
00397     connect( argSetAltAz->AzBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotAz() ) );
00398     connect( argSetLocalTime->DateBox, SIGNAL( changed(ExtDate) ), this, SLOT( slotChangeDate() ) );
00399     connect( argSetLocalTime->TimeBox, SIGNAL( valueChanged(const QTime&) ), this, SLOT( slotChangeTime() ) );
00400     connect( argWaitFor->DelayBox, SIGNAL( valueChanged(int) ), this, SLOT( slotWaitFor() ) );
00401     connect( argWaitForKey->WaitKeyEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotWaitForKey() ) );
00402     connect( argSetTracking->CheckTrack, SIGNAL( stateChanged(int) ), this, SLOT( slotTracking() ) );
00403     connect( argChangeViewOption->OptionName, SIGNAL( activated(const QString &) ), this, SLOT( slotViewOption() ) );
00404     connect( argChangeViewOption->OptionValue, SIGNAL( textChanged(const QString &) ), this, SLOT( slotViewOption() ) );
00405     connect( argSetGeoLocation->CityName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeCity() ) );
00406     connect( argSetGeoLocation->ProvinceName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeProvince() ) );
00407     connect( argSetGeoLocation->CountryName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeCountry() ) );
00408     connect( argTimeScale->TimeScale, SIGNAL( scaleChanged(float) ), this, SLOT( slotTimeScale() ) );
00409     connect( argZoom->ZoomBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotZoom() ) );
00410     connect( argExportImage->ExportFileName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotExportImage() ) );
00411     connect( argExportImage->ExportWidth, SIGNAL( valueChanged(int) ), this, SLOT( slotExportImage() ) );
00412     connect( argExportImage->ExportHeight, SIGNAL( valueChanged(int) ), this, SLOT( slotExportImage() ) );
00413     connect( argPrintImage->UsePrintDialog, SIGNAL( toggled(bool) ), this, SLOT( slotPrintImage() ) );
00414     connect( argPrintImage->UseChartColors, SIGNAL( toggled(bool) ), this, SLOT( slotPrintImage() ) );
00415     connect( argSetColor->ColorName, SIGNAL( activated(const QString &) ), this, SLOT( slotChangeColorName() ) );
00416     connect( argSetColor->ColorValue, SIGNAL( changed(const QColor &) ), this, SLOT( slotChangeColor() ) );
00417     connect( argLoadColorScheme->SchemeList, SIGNAL( clicked( QListBoxItem* ) ), this, SLOT( slotLoadColorScheme( QListBoxItem* ) ) );
00418     connect( snd->ScriptName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEnableScriptNameOK() ) );
00419     
00420     connect( sb->AppendINDIWait, SIGNAL ( toggled(bool) ), this, SLOT(slotINDIWaitCheck(bool)));
00421     
00422     // Connections for INDI's Arg widgets
00423     
00424     // INDI Start Device
00425     connect (argStartINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIStartDeviceName()));
00426     connect (argStartINDI->INDIMode, SIGNAL ( clicked( int)), this, SLOT (slotINDIStartDeviceMode())); 
00427     
00428     // INDI Shutdown Device
00429     connect (argShutdownINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIShutdown()));
00430     
00431     // INDI Swtich Device
00432     connect (argSwitchINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISwitchDeviceName()));
00433     connect (argSwitchINDI->INDIConnection, SIGNAL ( clicked( int)), this, SLOT (slotINDISwitchDeviceConnection())); 
00434     
00435     // INDI Set Device Port
00436     connect (argSetPortINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetPortDeviceName()));
00437     connect (argSetPortINDI->devicePort, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetPortDevicePort()));
00438     
00439     // INDI Set Target Coord 
00440     connect (argSetTargetCoordINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetTargetCoordDeviceName()));
00441     connect( argSetTargetCoordINDI->RaBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetTargetCoordDeviceRA() ) );
00442     connect( argSetTargetCoordINDI->DecBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetTargetCoordDeviceDEC() ) );
00443     
00444     // INDI Set Target Name
00445     connect( argSetTargetNameINDI->FindButton, SIGNAL( clicked() ), this, SLOT( slotINDIFindObject() ) );
00446     connect (argSetTargetNameINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetTargetNameDeviceName()));
00447     connect (argSetTargetNameINDI->objectName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetTargetNameObjectName()));
00448     
00449     // INDI Set Action
00450     connect (argSetActionINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetActionDeviceName()));
00451     connect (argSetActionINDI->actionName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetActionName()));
00452     
00453     // INDI Wait For Action
00454     connect (argWaitForActionINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIWaitForActionDeviceName()));
00455     connect (argWaitForActionINDI->actionName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIWaitForActionName()));
00456     
00457     // INDI Set Focus Speed
00458     connect (argSetFocusSpeedINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFocusSpeedDeviceName()));
00459     connect (argSetFocusSpeedINDI->speedIN, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFocusSpeed()));
00460     
00461     // INDI Start Focus
00462     connect (argStartFocusINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIStartFocusDeviceName()));
00463     connect (argStartFocusINDI->directionCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDIStartFocusDirection()));
00464     
00465     // INDI Set Focus Timeout
00466     connect (argSetFocusTimeoutINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFocusTimeoutDeviceName()));
00467     connect (argSetFocusTimeoutINDI->timeOut, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFocusTimeout()));
00468     
00469     // INDI Set Geo Location
00470     connect (argSetGeoLocationINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetGeoLocationDeviceName()));
00471     connect( argSetGeoLocationINDI->longBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetGeoLocationDeviceLong() ) );
00472     connect( argSetGeoLocationINDI->latBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetGeoLocationDeviceLat() ) );
00473     
00474     // INDI Start Exposure
00475     connect (argStartExposureINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIStartExposureDeviceName()));
00476     connect (argStartExposureINDI->timeOut, SIGNAL( valueChanged(int) ), this, SLOT(slotINDIStartExposureTimeout()));
00477     
00478     // INDI Set UTC
00479     connect (argSetUTCINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetUTCDeviceName()));
00480     connect (argSetUTCINDI->UTC, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetUTC()));
00481     
00482     // INDI Set Scope Action
00483     connect (argSetScopeActionINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetScopeActionDeviceName()));
00484     connect (argSetScopeActionINDI->actionCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDISetScopeAction()));
00485     
00486     // INDI Set Frame type
00487     connect (argSetFrameTypeINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFrameTypeDeviceName()));
00488     connect (argSetFrameTypeINDI->typeCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDISetFrameType()));
00489     
00490     // INDI Set CCD Temp
00491     connect (argSetCCDTempINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetCCDTempDeviceName()));
00492     connect (argSetCCDTempINDI->temp, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetCCDTemp()));
00493 
00494     // INDI Set Filter Num
00495     connect (argSetFilterNumINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFilterNumDeviceName()));
00496     connect (argSetFilterNumINDI->filter_num, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFilterNum()));
00497 
00498     
00499     //disbale some buttons
00500     sb->CopyButton->setEnabled( false );
00501     sb->AddButton->setEnabled( false );
00502     sb->RemoveButton->setEnabled( false );
00503     sb->UpButton->setEnabled( false );
00504     sb->DownButton->setEnabled( false );
00505     sb->SaveButton->setEnabled( false );
00506     sb->SaveAsButton->setEnabled( false );
00507     sb->RunButton->setEnabled( false );
00508 }
00509 
00510 ScriptBuilder::~ScriptBuilder()
00511 {
00512 }
00513 
00514 void ScriptBuilder::initViewOptions() {
00515     otv->OptionsList->setRootIsDecorated( true );
00516 
00517     //InfoBoxes
00518     opsGUI = new QListViewItem( otv->OptionsList, i18n( "InfoBoxes" ) );
00519     new QListViewItem( opsGUI, "ShowInfoBoxes", i18n( "Toggle display of all InfoBoxes" ), i18n( "bool" ) );
00520     new QListViewItem( opsGUI, "ShowTimeBox", i18n( "Toggle display of Time InfoBox" ), i18n( "bool" ) );
00521     new QListViewItem( opsGUI, "ShowGeoBox", i18n( "Toggle display of Geographic InfoBox" ), i18n( "bool" ) );
00522     new QListViewItem( opsGUI, "ShowFocusBox", i18n( "Toggle display of Focus InfoBox" ), i18n( "bool" ) );
00523     new QListViewItem( opsGUI, "ShadeTimeBox", i18n( "(un)Shade Time InfoBox" ), i18n( "bool" ) );
00524     new QListViewItem( opsGUI, "ShadeGeoBox", i18n( "(un)Shade Geographic InfoBox" ), i18n( "bool" ) );
00525     new QListViewItem( opsGUI, "ShadeFocusBox", i18n( "(un)Shade Focus InfoBox" ), i18n( "bool" ) );
00526     argChangeViewOption->OptionName->insertItem( "ShowInfoBoxes" );
00527     argChangeViewOption->OptionName->insertItem( "ShowTimeBox" );
00528     argChangeViewOption->OptionName->insertItem( "ShowGeoBox" );
00529     argChangeViewOption->OptionName->insertItem( "ShowFocusBox" );
00530     argChangeViewOption->OptionName->insertItem( "ShadeTimeBox" );
00531     argChangeViewOption->OptionName->insertItem( "ShadeGeoBox" );
00532     argChangeViewOption->OptionName->insertItem( "ShadeFocusBox" );
00533 
00534     //Toolbars
00535     opsToolbar = new QListViewItem( otv->OptionsList, i18n( "Toolbars" ) );
00536     new QListViewItem( opsToolbar, "ShowMainToolBar", i18n( "Toggle display of main toolbar" ), i18n( "bool" ) );
00537     new QListViewItem( opsToolbar, "ShowViewToolBar", i18n( "Toggle display of view toolbar" ), i18n( "bool" ) );
00538     argChangeViewOption->OptionName->insertItem( "ShowMainToolBar" );
00539     argChangeViewOption->OptionName->insertItem( "ShowViewToolBar" );
00540 
00541     //Show Objects
00542     opsShowObj = new QListViewItem( otv->OptionsList, i18n( "Show Objects" ) );
00543     new QListViewItem( opsShowObj, "ShowStars", i18n( "Toggle display of Stars" ), i18n( "bool" ) );
00544     new QListViewItem( opsShowObj, "ShowDeepSky", i18n( "Toggle display of all deep-sky objects" ), i18n( "bool" ) );
00545     new QListViewItem( opsShowObj, "ShowMessier", i18n( "Toggle display of Messier object symbols" ), i18n( "bool" ) );
00546     new QListViewItem( opsShowObj, "ShowMessierImages", i18n( "Toggle display of Messier object images" ), i18n( "bool" ) );
00547     new QListViewItem( opsShowObj, "ShowNGC", i18n( "Toggle display of NGC objects" ), i18n( "bool" ) );
00548     new QListViewItem( opsShowObj, "ShowIC", i18n( "Toggle display of IC objects" ), i18n( "bool" ) );
00549     new QListViewItem( opsShowObj, "ShowPlanets", i18n( "Toggle display of all solar system bodies" ), i18n( "bool" ) );
00550     new QListViewItem( opsShowObj, "ShowSun", i18n( "Toggle display of Sun" ), i18n( "bool" ) );
00551     new QListViewItem( opsShowObj, "ShowMoon", i18n( "Toggle display of Moon" ), i18n( "bool" ) );
00552     new QListViewItem( opsShowObj, "ShowMercury", i18n( "Toggle display of Mercury" ), i18n( "bool" ) );
00553     new QListViewItem( opsShowObj, "ShowVenus", i18n( "Toggle display of Venus" ), i18n( "bool" ) );
00554     new QListViewItem( opsShowObj, "ShowMars", i18n( "Toggle display of Mars" ), i18n( "bool" ) );
00555     new QListViewItem( opsShowObj, "ShowJupiter", i18n( "Toggle display of Jupiter" ), i18n( "bool" ) );
00556     new QListViewItem( opsShowObj, "ShowSaturn", i18n( "Toggle display of Saturn" ), i18n( "bool" ) );
00557     new QListViewItem( opsShowObj, "ShowUranus", i18n( "Toggle display of Uranus" ), i18n( "bool" ) );
00558     new QListViewItem( opsShowObj, "ShowNeptune", i18n( "Toggle display of Neptune" ), i18n( "bool" ) );
00559     new QListViewItem( opsShowObj, "ShowPluto", i18n( "Toggle display of Pluto" ), i18n( "bool" ) );
00560     new QListViewItem( opsShowObj, "ShowAsteroids", i18n( "Toggle display of Asteroids" ), i18n( "bool" ) );
00561     new QListViewItem( opsShowObj, "ShowComets", i18n( "Toggle display of Comets" ), i18n( "bool" ) );
00562     argChangeViewOption->OptionName->insertItem( "ShowSAO" );
00563     argChangeViewOption->OptionName->insertItem( "ShowDeepSky" );
00564     argChangeViewOption->OptionName->insertItem( "ShowMess" );
00565     argChangeViewOption->OptionName->insertItem( "ShowMessImages" );
00566     argChangeViewOption->OptionName->insertItem( "ShowNGC" );
00567     argChangeViewOption->OptionName->insertItem( "ShowIC" );
00568     argChangeViewOption->OptionName->insertItem( "ShowPlanets" );
00569     argChangeViewOption->OptionName->insertItem( "ShowSun" );
00570     argChangeViewOption->OptionName->insertItem( "ShowMoon" );
00571     argChangeViewOption->OptionName->insertItem( "ShowMercury" );
00572     argChangeViewOption->OptionName->insertItem( "ShowVenus" );
00573     argChangeViewOption->OptionName->insertItem( "ShowMars" );
00574     argChangeViewOption->OptionName->insertItem( "ShowJupiter" );
00575     argChangeViewOption->OptionName->insertItem( "ShowSaturn" );
00576     argChangeViewOption->OptionName->insertItem( "ShowUranus" );
00577     argChangeViewOption->OptionName->insertItem( "ShowNeptune" );
00578     argChangeViewOption->OptionName->insertItem( "ShowPluto" );
00579     argChangeViewOption->OptionName->insertItem( "ShowAsteroids" );
00580     argChangeViewOption->OptionName->insertItem( "ShowComets" );
00581 
00582     opsShowOther = new QListViewItem( otv->OptionsList, i18n( "Show Other" ) );
00583     new QListViewItem( opsShowOther, "ShowCLines", i18n( "Toggle display of constellation lines" ), i18n( "bool" ) );
00584     new QListViewItem( opsShowOther, "ShowCBounds", i18n( "Toggle display of constellation boundaries" ), i18n( "bool" ) );
00585     new QListViewItem( opsShowOther, "ShowCNames", i18n( "Toggle display of constellation names" ), i18n( "bool" ) );
00586     new QListViewItem( opsShowOther, "ShowMilkyWay", i18n( "Toggle display of Milky Way" ), i18n( "bool" ) );
00587     new QListViewItem( opsShowOther, "ShowGrid", i18n( "Toggle display of the coordinate grid" ), i18n( "bool" ) );
00588     new QListViewItem( opsShowOther, "ShowEquator", i18n( "Toggle display of the celestial equator" ), i18n( "bool" ) );
00589     new QListViewItem( opsShowOther, "ShowEcliptic", i18n( "Toggle display of the ecliptic" ), i18n( "bool" ) );
00590     new QListViewItem( opsShowOther, "ShowHorizon", i18n( "Toggle display of the horizon line" ), i18n( "bool" ) );
00591     new QListViewItem( opsShowOther, "ShowGround", i18n( "Toggle display of the opaque ground" ), i18n( "bool" ) );
00592     new QListViewItem( opsShowOther, "ShowStarNames", i18n( "Toggle display of star name labels" ), i18n( "bool" ) );
00593     new QListViewItem( opsShowOther, "ShowStarMagnitudes", i18n( "Toggle display of star magnitude labels" ), i18n( "bool" ) );
00594     new QListViewItem( opsShowOther, "ShowAsteroidNames", i18n( "Toggle display of asteroid name labels" ), i18n( "bool" ) );
00595     new QListViewItem( opsShowOther, "ShowCometNames", i18n( "Toggle display of comet name labels" ), i18n( "bool" ) );
00596     new QListViewItem( opsShowOther, "ShowPlanetNames", i18n( "Toggle display of planet name labels" ), i18n( "bool" ) );
00597     new QListViewItem( opsShowOther, "ShowPlanetImages", i18n( "Toggle display of planet images" ), i18n( "bool" ) );
00598     argChangeViewOption->OptionName->insertItem( "ShowCLines" );
00599     argChangeViewOption->OptionName->insertItem( "ShowCBounds" );
00600     argChangeViewOption->OptionName->insertItem( "ShowCNames" );
00601     argChangeViewOption->OptionName->insertItem( "ShowMilkyWay" );
00602     argChangeViewOption->OptionName->insertItem( "ShowGrid" );
00603     argChangeViewOption->OptionName->insertItem( "ShowEquator" );
00604     argChangeViewOption->OptionName->insertItem( "ShowEcliptic" );
00605     argChangeViewOption->OptionName->insertItem( "ShowHorizon" );
00606     argChangeViewOption->OptionName->insertItem( "ShowGround" );
00607     argChangeViewOption->OptionName->insertItem( "ShowStarNames" );
00608     argChangeViewOption->OptionName->insertItem( "ShowStarMagnitudes" );
00609     argChangeViewOption->OptionName->insertItem( "ShowAsteroidNames" );
00610     argChangeViewOption->OptionName->insertItem( "ShowCometNames" );
00611     argChangeViewOption->OptionName->insertItem( "ShowPlanetNames" );
00612     argChangeViewOption->OptionName->insertItem( "ShowPlanetImages" );
00613 
00614     opsCName = new QListViewItem( otv->OptionsList, i18n( "Constellation Names" ) );
00615     new QListViewItem( opsCName, "UseLatinConstellNames", i18n( "Show Latin constellation names" ), i18n( "bool" ) );
00616     new QListViewItem( opsCName, "UseLocalConstellNames", i18n( "Show constellation names in local language" ), i18n( "bool" ) );
00617     new QListViewItem( opsCName, "UseAbbrevConstellNames", i18n( "Show IAU-standard constellation abbreviations" ), i18n( "bool" ) );
00618     argChangeViewOption->OptionName->insertItem( "UseLatinConstellNames" );
00619     argChangeViewOption->OptionName->insertItem( "UseLocalConstellNames" );
00620     argChangeViewOption->OptionName->insertItem( "UseAbbrevConstellNames" );
00621 
00622     opsHide = new QListViewItem( otv->OptionsList, i18n( "Hide Items" ) );
00623     new QListViewItem( opsHide, "HideOnSlew", i18n( "Toggle whether objects hidden while slewing display" ), i18n( "bool" ) );
00624     new QListViewItem( opsHide, "SlewTimeScale", i18n( "Timestep threshold (in seconds) for hiding objects" ), i18n( "double" ) );
00625     new QListViewItem( opsHide, "HideStars", i18n( "Hide faint stars while slewing?" ), i18n( "bool" ) );
00626     new QListViewItem( opsHide, "HidePlanets", i18n( "Hide solar system bodies while slewing?" ), i18n( "bool" ) );
00627     new QListViewItem( opsHide, "HideMessier", i18n( "Hide Messier objects while slewing?" ), i18n( "bool" ) );
00628     new QListViewItem( opsHide, "HideNGC", i18n( "Hide NGC objects while slewing?" ), i18n( "bool" ) );
00629     new QListViewItem( opsHide, "HideIC", i18n( "Hide IC objects while slewing?" ), i18n( "bool" ) );
00630     new QListViewItem( opsHide, "HideMilkyWay", i18n( "Hide Milky Way while slewing?" ), i18n( "bool" ) );
00631     new QListViewItem( opsHide, "HideCNames", i18n( "Hide constellation names while slewing?" ), i18n( "bool" ) );
00632     new QListViewItem( opsHide, "HideCLines", i18n( "Hide constellation lines while slewing?" ), i18n( "bool" ) );
00633     new QListViewItem( opsHide, "HideCBounds", i18n( "Hide constellation boundaries while slewing?" ), i18n( "bool" ) );
00634     new QListViewItem( opsHide, "HideGrid", i18n( "Hide coordinate grid while slewing?" ), i18n( "bool" ) );
00635     argChangeViewOption->OptionName->insertItem( "HideOnSlew" );
00636     argChangeViewOption->OptionName->insertItem( "SlewTimeScale" );
00637     argChangeViewOption->OptionName->insertItem( "HideStars" );
00638     argChangeViewOption->OptionName->insertItem( "HidePlanets" );
00639     argChangeViewOption->OptionName->insertItem( "HideMessier" );
00640     argChangeViewOption->OptionName->insertItem( "HideNGC" );
00641     argChangeViewOption->OptionName->insertItem( "HideIC" );
00642     argChangeViewOption->OptionName->insertItem( "HideMilkyWay" );
00643     argChangeViewOption->OptionName->insertItem( "HideCNames" );
00644     argChangeViewOption->OptionName->insertItem( "HideCLines" );
00645     argChangeViewOption->OptionName->insertItem( "HideCBounds" );
00646     argChangeViewOption->OptionName->insertItem( "HideGrid" );
00647 
00648     opsSkymap = new QListViewItem( otv->OptionsList, i18n( "Skymap Options" ) );
00649     new QListViewItem( opsSkymap, "UseAltAz", i18n( "Use Horizontal coordinates? (otherwise, use Equatorial)" ), i18n( "bool" ) );
00650     new QListViewItem( opsSkymap, "ZoomFactor", i18n( "Set the Zoom Factor" ), i18n( "double" ) );
00651     new QListViewItem( opsSkymap, "FOV Size", i18n( "Select angular size for the FOV symbol (in arcmin)" ), i18n( "double" ) );
00652     new QListViewItem( opsSkymap, "FOV Shape", i18n( "Select shape for the FOV symbol (0=Square, 1=Circle, 2=Crosshairs, 4=Bullseye)" ), i18n( "int" ) );
00653     new QListViewItem( opsSkymap, "FOV Color", i18n( "Select color for the FOV symbol" ), i18n( "string" ) );
00654     new QListViewItem( opsSkymap, "AnimateSlewing", i18n( "Use animated slewing? (otherwise, \"snap\" to new focus)" ), i18n( "bool" ) );
00655     new QListViewItem( opsSkymap, "UseRefraction", i18n( "Correct for atmospheric refraction?" ), i18n( "bool" ) );
00656     new QListViewItem( opsSkymap, "UseAutoLabel", i18n( "Automatically attach name label to centered object?" ), i18n( "bool" ) );
00657     new QListViewItem( opsSkymap, "UseHoverLabel", i18n( "Attach temporary name label when hovering mouse over an object?" ), i18n( "bool" ) );
00658     new QListViewItem( opsSkymap, "UseAutoTrail", i18n( "Automatically add trail to centered solar system body?" ), i18n( "bool" ) );
00659     new QListViewItem( opsSkymap, "FadePlanetTrails", i18n( "Planet trails fade to sky color? (otherwise color is constant)" ), i18n( "bool" ) );
00660     argChangeViewOption->OptionName->insertItem( "UseAltAz" );
00661     argChangeViewOption->OptionName->insertItem( "ZoomFactor" );
00662     argChangeViewOption->OptionName->insertItem( "FOVName" );
00663     argChangeViewOption->OptionName->insertItem( "FOVSize" );
00664     argChangeViewOption->OptionName->insertItem( "FOVShape" );
00665     argChangeViewOption->OptionName->insertItem( "FOVColor" );
00666     argChangeViewOption->OptionName->insertItem( "UseRefraction" );
00667     argChangeViewOption->OptionName->insertItem( "UseAutoLabel" );
00668     argChangeViewOption->OptionName->insertItem( "UseHoverLabel" );
00669     argChangeViewOption->OptionName->insertItem( "UseAutoTrail" );
00670     argChangeViewOption->OptionName->insertItem( "AnimateSlewing" );
00671     argChangeViewOption->OptionName->insertItem( "FadePlanetTrails" );
00672 
00673     opsLimit = new QListViewItem( otv->OptionsList, i18n( "Limits" ) );
00674     new QListViewItem( opsLimit, "magLimitDrawStar", i18n( "magnitude of faintest star drawn on map when zoomed in" ), i18n( "double" ) );
00675     new QListViewItem( opsLimit, "magLimitDrawStarZoomOut", i18n( "magnitude of faintest star drawn on map when zoomed out" ), i18n( "double" ) );
00676     new QListViewItem( opsLimit, "magLimitDrawDeepSky", i18n( "magnitude of faintest nonstellar object drawn on map when zoomed in" ), i18n( "double" ) );
00677     new QListViewItem( opsLimit, "magLimitDrawDeepSkyZoomOut", i18n( "magnitude of faintest nonstellar object drawn on map when zoomed out" ), i18n( "double" ) );
00678     new QListViewItem( opsLimit, "magLimitDrawStarInfo", i18n( "magnitude of faintest star labeled on map" ), i18n( "double" ) );
00679     new QListViewItem( opsLimit, "magLimitHideStar", i18n( "magnitude of brightest star hidden while slewing" ), i18n( "double" ) );
00680     new QListViewItem( opsLimit, "magLimitAsteroid", i18n( "magnitude of faintest asteroid drawn on map" ), i18n( "double" ) );
00681     new QListViewItem( opsLimit, "magLimitAsteroidName", i18n( "magnitude of faintest asteroid labeled on map" ), i18n( "double" ) );
00682     new QListViewItem( opsLimit, "maxRadCometName", i18n( "comets nearer to the Sun than this (in AU) are labeled on map" ), i18n( "double" ) );
00683     argChangeViewOption->OptionName->insertItem( "magLimitDrawStar" );
00684     argChangeViewOption->OptionName->insertItem( "magLimitDrawStarZoomOut" );
00685     argChangeViewOption->OptionName->insertItem( "magLimitDrawDeepSky" );
00686     argChangeViewOption->OptionName->insertItem( "magLimitDrawDeepSkyZoomOut" );
00687     argChangeViewOption->OptionName->insertItem( "magLimitDrawStarInfo" );
00688     argChangeViewOption->OptionName->insertItem( "magLimitHideStar" );
00689     argChangeViewOption->OptionName->insertItem( "magLimitAsteroid" );
00690     argChangeViewOption->OptionName->insertItem( "magLimitAsteroidName" );
00691     argChangeViewOption->OptionName->insertItem( "maxRadCometName" );
00692 
00693     //init the list of color names and values
00694     for ( unsigned int i=0; i < ks->data()->colorScheme()->numberOfColors(); ++i ) {
00695         argSetColor->ColorName->insertItem( ks->data()->colorScheme()->nameAt(i) );
00696     }
00697     
00698     //init list of color scheme names
00699     argLoadColorScheme->SchemeList->insertItem( i18n( "use default color scheme", "Default Colors" ) );
00700     argLoadColorScheme->SchemeList->insertItem( i18n( "use 'star chart' color scheme", "Star Chart" ) );
00701     argLoadColorScheme->SchemeList->insertItem( i18n( "use 'night vision' color scheme", "Night Vision" ) );
00702     argLoadColorScheme->SchemeList->insertItem( i18n( "use 'moonless night' color scheme", "Moonless Night" ) );
00703     
00704     QFile file;
00705     QString line;
00706     file.setName( locate( "appdata", "colors.dat" ) ); //determine filename in local user KDE directory tree.
00707     if ( file.open( IO_ReadOnly ) ) {
00708         QTextStream stream( &file );
00709 
00710     while ( !stream.eof() ) {
00711             line = stream.readLine();
00712             argLoadColorScheme->SchemeList->insertItem( line.left( line.find( ':' ) ) );
00713         }
00714         file.close();
00715     }
00716 }
00717 
00718 //Slots defined in ScriptBuilderUI
00719 void ScriptBuilder::slotNew() {
00720     saveWarning();
00721     if ( !UnsavedChanges ) {
00722         ScriptList.clear();
00723         sb->ScriptListBox->clear();
00724         sb->ArgStack->raiseWidget( argBlank );
00725 
00726         sb->CopyButton->setEnabled( false );
00727         sb->RemoveButton->setEnabled( false );
00728         sb->RunButton->setEnabled( false );
00729 
00730         currentFileURL = "";
00731         currentScriptName = "";
00732     }
00733 }
00734 
00735 void ScriptBuilder::slotOpen() {
00736     saveWarning();
00737 
00738     QString fname;
00739     KTempFile tmpfile;
00740     tmpfile.setAutoDelete(true);
00741 
00742     if ( !UnsavedChanges ) {
00743         currentFileURL = KFileDialog::getOpenURL( currentDir, "*.kstars|KStars Scripts (*.kstars)" );
00744 
00745         if ( currentFileURL.isValid() ) {
00746             currentDir = currentFileURL.directory();
00747 
00748             ScriptList.clear();
00749             sb->ScriptListBox->clear();
00750             sb->ArgStack->raiseWidget( argBlank );
00751 
00752             if ( currentFileURL.isLocalFile() ) {
00753                 fname = currentFileURL.path();
00754             } else {
00755                 fname = tmpfile.name();
00756                 if ( ! KIO::NetAccess::download( currentFileURL, fname, (QWidget*) 0 ) )
00757                     KMessageBox::sorry( 0, i18n( "Could not download remote file." ), i18n( "Download Error" ) );
00758             }
00759 
00760             QFile f( fname );
00761             if ( !f.open( IO_ReadOnly) ) {
00762                 QString message = i18n( "Could not open file %1." ).arg( f.name() );
00763                 KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
00764                 currentFileURL = "";
00765                 return;
00766             }
00767 
00768             QTextStream istream(&f);
00769             readScript( istream );
00770 
00771             f.close();
00772         } else if ( ! currentFileURL.url().isEmpty() ) {
00773             QString message = i18n( "Invalid URL: %1" ).arg( currentFileURL.url() );
00774             KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
00775             currentFileURL = "";
00776         }
00777     }
00778 }
00779 
00780 void ScriptBuilder::slotSave() {
00781     QString fname;
00782     KTempFile tmpfile;
00783     tmpfile.setAutoDelete(true);
00784 
00785     if ( currentScriptName.isEmpty() ) {
00786         //Get Script Name and Author info
00787         if ( snd->exec() == QDialog::Accepted ) {
00788             currentScriptName = snd->ScriptName->text();
00789             currentAuthor = snd->AuthorName->text();
00790         } else {
00791             return;
00792         }
00793     }
00794 
00795     if ( currentFileURL.isEmpty() )
00796         currentFileURL = KFileDialog::getSaveURL( currentDir, "*.kstars|KStars Scripts (*.kstars)" );
00797 
00798     if ( currentFileURL.isValid() ) {
00799         currentDir = currentFileURL.directory();
00800 
00801         if ( currentFileURL.isLocalFile() ) {
00802             fname = currentFileURL.path();
00803             
00804             //Warn user if file exists
00805             if (QFile::exists(currentFileURL.path())) {
00806                 int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
00807                         i18n( "A file named \"%1\" already exists. "
00808                                 "Overwrite it?" ).arg(currentFileURL.fileName()),
00809                         i18n( "Overwrite File?" ),
00810                         i18n( "&Overwrite" ) );
00811         
00812                 if(r==KMessageBox::Cancel) return;
00813             }
00814         } else {
00815             fname = tmpfile.name();
00816         }
00817         
00818         if ( fname.right( 7 ).lower() != ".kstars" ) fname += ".kstars";
00819 
00820         QFile f( fname );
00821         if ( !f.open( IO_WriteOnly) ) {
00822             QString message = i18n( "Could not open file %1." ).arg( f.name() );
00823             KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
00824             currentFileURL = "";
00825             return;
00826         }
00827 
00828         QTextStream ostream(&f);
00829         writeScript( ostream );
00830         f.close();
00831 
00832         //set rwx for owner, rx for group, rx for other
00833         chmod( fname.ascii(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
00834 
00835         if ( tmpfile.name() == fname ) { //need to upload to remote location
00836             if ( ! KIO::NetAccess::upload( tmpfile.name(), currentFileURL, (QWidget*) 0 ) ) {
00837                 QString message = i18n( "Could not upload image to remote location: %1" ).arg( currentFileURL.prettyURL() );
00838                 KMessageBox::sorry( 0, message, i18n( "Could not upload file" ) );
00839             }
00840         }
00841 
00842         setUnsavedChanges( false );
00843 
00844     } else {
00845         QString message = i18n( "Invalid URL: %1" ).arg( currentFileURL.url() );
00846         KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
00847         currentFileURL = "";
00848     }
00849 }
00850 
00851 void ScriptBuilder::slotSaveAs() {
00852     currentFileURL = "";
00853     currentScriptName = "";
00854     slotSave();
00855 }
00856 
00857 void ScriptBuilder::saveWarning() {
00858     if ( UnsavedChanges ) {
00859         QString caption = i18n( "Save Changes to Script?" );
00860         QString message = i18n( "The current script has unsaved changes.  Would you like to save before closing it?" );
00861         int ans = KMessageBox::warningYesNoCancel( 0, message, caption, KStdGuiItem::save(), KStdGuiItem::discard() );
00862         if ( ans == KMessageBox::Yes ) {
00863             slotSave();
00864             setUnsavedChanges( false );
00865         } else if ( ans == KMessageBox::No ) {
00866             setUnsavedChanges( false );
00867         }
00868 
00869         //Do nothing if 'cancel' selected
00870     }
00871 }
00872 
00873 void ScriptBuilder::slotRunScript() {
00874     //hide window while script runs
00875 // If this is uncommented, the program hangs before the script is executed.  Why?
00876 //  hide();
00877 
00878     //Save current script to a temporary file, then execute that file.
00879     //For some reason, I can't use KTempFile here!  If I do, then the temporary script
00880     //is not executable.  Bizarre...
00881     //KTempFile tmpfile;
00882     //QString fname = tmpfile.name();
00883     QString fname = locateLocal( "tmp", "kstars-tempscript" );
00884 
00885     QFile f( fname );
00886     if ( f.exists() ) f.remove();
00887     if ( !f.open( IO_WriteOnly) ) {
00888         QString message = i18n( "Could not open file %1." ).arg( f.name() );
00889         KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
00890         currentFileURL = "";
00891         return;
00892     }
00893 
00894     QTextStream ostream(&f);
00895     writeScript( ostream );
00896     f.close();
00897 
00898     //set rwx for owner, rx for group, rx for other
00899     chmod( f.name().ascii(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
00900 
00901     KProcess p;
00902     p << f.name();
00903     if ( ! p.start( KProcess::DontCare ) )
00904         kdDebug() << "Process did not start." << endl;
00905 
00906     while ( p.isRunning() ) kapp->processEvents( 50 ); //otherwise tempfile may get deleted before script completes.
00907 
00908     //delete temp file
00909     if ( f.exists() ) f.remove();
00910 
00911     //uncomment if 'hide()' is uncommented...
00912 //  show();
00913 }
00914 
00915 void ScriptBuilder::writeScript( QTextStream &ostream ) {
00916     QString mainpre  = "dcop $KSTARS $MAIN  ";
00917     QString clockpre = "dcop $KSTARS $CLOCK ";
00918 
00919     //Write script header
00920     ostream << "#!/bin/bash" << endl;
00921     ostream << "#KStars DCOP script: " << currentScriptName << endl;
00922     ostream << "#by " << currentAuthor << endl;
00923     ostream << "#last modified: " << KStarsDateTime::currentDateTime().toString() << endl;
00924     ostream << "#" << endl;
00925     ostream << "KSTARS=`dcopfind -a 'kstars*'`" << endl;
00926     ostream << "MAIN=KStarsInterface" << endl;
00927     ostream << "CLOCK=clock#1" << endl;
00928 
00929     for ( ScriptFunction *sf = ScriptList.first(); sf; sf = ScriptList.next() )
00930     {
00931             if (!sf->valid()) continue;
00932         if ( sf->isClockFunction() ) {
00933             ostream << clockpre << sf->scriptLine() << endl;
00934         } else {
00935             ostream << mainpre  << sf->scriptLine() << endl;
00936             if (sb->AppendINDIWait->isChecked() && !sf->INDIProperty().isEmpty())
00937             {
00938               // Special case for telescope action, we need to know the parent property
00939               if (sf->INDIProperty() == "CHECK")
00940               {
00941                 if (sf->argVal(1) == "SLEW" || sf->argVal(1) == "TRACK" || sf->argVal(1) == "SYNC")
00942                   sf->setINDIProperty("ON_COORD_SET");
00943                 else if (sf->argVal(1) == "ABORT")
00944                   sf->setINDIProperty("ABORT_MOTION");
00945                 else
00946                   sf->setINDIProperty("PARK");
00947               }
00948               
00949               if ( sf->argVal(0).contains(" ")) 
00950                 ostream << mainpre << "waitForINDIAction " << "\"" << sf->argVal(0) << "\" " << sf->INDIProperty() << endl;
00951               else
00952                 ostream << mainpre << "waitForINDIAction " << sf->argVal(0) << " " << sf->INDIProperty() << endl;
00953             }
00954         }
00955     }
00956 
00957     //Write script footer
00958     ostream << "##" << endl;
00959 }
00960 
00961 void ScriptBuilder::readScript( QTextStream &istream ) {
00962     QString line;
00963 
00964     while ( ! istream.eof() ) {
00965         line = istream.readLine();
00966 
00967         //look for name of script
00968         if ( line.contains( "#KStars DCOP script: " ) )
00969             currentScriptName = line.mid( 21 ).stripWhiteSpace();
00970 
00971         //look for author of scriptbuilder
00972         if ( line.contains( "#by " ) )
00973             currentAuthor = line.mid( 4 ).stripWhiteSpace();
00974 
00975         //Actual script functions
00976         if ( line.left(4) == "dcop" ) {
00977 
00978         //is ClockFunction?
00979             bool clockfcn( false );
00980             if ( line.contains( "$CLOCK" ) ) clockfcn = true;
00981 
00982             //remove leading dcop prefix
00983             line = line.mid( 20 );
00984 
00985             //construct a stringlist that is fcn name and its arg name/value pairs
00986             QStringList fn = QStringList::split( " ", line );
00987             if ( parseFunction( fn ) )
00988             {
00989               sb->ScriptListBox->insertItem( ScriptList.current()->name() );
00990               // Initially, any read script is valid!
00991               ScriptList.current()->setValid(true);
00992             }
00993             else kdWarning() << i18n( "Could not parse script.  Line was: %1" ).arg( line ) << endl;
00994 
00995         } // end if left(4) == "dcop"
00996     } // end while !eof()
00997 
00998     //Select first item in sb->ScriptListBox
00999     if ( sb->ScriptListBox->count() ) {
01000         sb->ScriptListBox->setCurrentItem( 0 );
01001         slotArgWidget();
01002     }
01003 }
01004 
01005 bool ScriptBuilder::parseFunction( QStringList &fn )
01006 {
01007         // clean up the string list first if needed
01008         // We need to perform this in case we havea quoted string "NGC 3000" because this will counted
01009         // as two arguments, and it should be counted as one.
01010         bool foundQuote(false), quoteProcessed(false);
01011     QString cur, arg;
01012     QStringList::iterator it;
01013     
01014     for (it = fn.begin(); it != fn.end(); ++it)
01015     {
01016       cur = (*it);
01017       
01018       if ( cur.startsWith("\""))
01019       {
01020         arg += cur.right(cur.length() - 1);
01021         arg += " ";
01022         foundQuote = true;
01023         quoteProcessed = true;
01024       }
01025       else if (cur.endsWith("\""))
01026       {
01027         arg += cur.left(cur.length() -1);
01028         arg += "'";
01029         foundQuote = false;
01030       }
01031       else if (foundQuote)
01032       {
01033         arg += cur;
01034         arg += " ";
01035       }
01036       else
01037       {
01038         arg += cur;
01039         arg += "'";
01040       }
01041     }
01042         
01043     if (quoteProcessed)
01044       fn = QStringList::split( "'", arg );
01045     
01046     //loop over known functions to find a name match
01047     for ( ScriptFunction *sf = KStarsFunctionList.first(); sf; sf = KStarsFunctionList.next() )
01048     {
01049         if ( fn[0] == sf->name() ) {
01050 
01051             if ( fn[0] == "setGeoLocation" ) {
01052                 QString city( fn[1] ), prov( "" ), cntry( fn[2] );
01053                 if ( fn.count() == 4 ) { prov = fn[2]; cntry = fn[3]; }
01054                 if ( fn.count() == 3 || fn.count() == 4 ) {
01055                     ScriptList.append( new ScriptFunction( sf ) );
01056                     ScriptList.current()->setArg( 0, city );
01057                     ScriptList.current()->setArg( 1, prov );
01058                     ScriptList.current()->setArg( 2, cntry );
01059                 } else return false;
01060 
01061             } else if ( fn.count() != sf->numArgs() + 1 ) return false;
01062 
01063             ScriptList.append( new ScriptFunction( sf ) );
01064 
01065             for ( unsigned int i=0; i<sf->numArgs(); ++i )
01066                 ScriptList.current()->setArg( i, fn[i+1] );
01067 
01068             return true;
01069         }
01070         
01071         for ( ScriptFunction *sf = INDIFunctionList.first(); sf; sf = INDIFunctionList.next() )
01072         {
01073           if ( fn[0] == sf->name() )
01074           {
01075 
01076             if ( fn.count() != sf->numArgs() + 1 ) return false;
01077 
01078             ScriptList.append( new ScriptFunction( sf ) );
01079 
01080             for ( unsigned int i=0; i<sf->numArgs(); ++i )
01081               ScriptList.current()->setArg( i, fn[i+1] );
01082 
01083             return true;
01084           }
01085         }
01086     }
01087 
01088     //if we get here, no function-name match was found
01089     return false;
01090 }
01091 
01092 void ScriptBuilder::setUnsavedChanges( bool b ) {
01093     UnsavedChanges = b;
01094     sb->SaveButton->setEnabled( b );
01095     sb->SaveAsButton->setEnabled( b );
01096 }
01097 
01098 void ScriptBuilder::slotEnableScriptNameOK() {
01099     snd->OKButton->setEnabled( ! snd->ScriptName->text().isEmpty() );
01100 }
01101 
01102 void ScriptBuilder::slotCopyFunction() {
01103     if ( ! UnsavedChanges ) setUnsavedChanges( true );
01104 
01105     int Pos = sb->ScriptListBox->currentItem() + 1;
01106     ScriptList.insert( Pos, new ScriptFunction( ScriptList.at( Pos-1 ) ) );
01107     //copy ArgVals
01108     for ( unsigned int i=0; i < ScriptList.at( Pos-1 )->numArgs(); ++i )
01109         ScriptList.at(Pos)->setArg(i, ScriptList.at( Pos-1 )->argVal(i) );
01110 
01111     sb->ScriptListBox->insertItem( ScriptList.current()->name(), Pos );
01112     sb->ScriptListBox->setSelected( Pos, true );
01113 }
01114 
01115 void ScriptBuilder::slotRemoveFunction() {
01116     setUnsavedChanges( true );
01117 
01118     int Pos = sb->ScriptListBox->currentItem();
01119     ScriptList.remove( Pos );
01120     sb->ScriptListBox->removeItem( Pos );
01121     if ( sb->ScriptListBox->count() == 0 ) {
01122         sb->ArgStack->raiseWidget( argBlank );
01123         sb->CopyButton->setEnabled( false );
01124         sb->RemoveButton->setEnabled( false );
01125     } else {
01126         sb->ScriptListBox->setSelected( Pos, true );
01127     }
01128 }
01129 
01130 void ScriptBuilder::slotAddFunction() {
01131   
01132         ScriptFunction *sc = NULL;
01133     QListViewItem *currentItem = sb->FunctionListView->currentItem();
01134     
01135     if ( currentItem == NULL || currentItem->depth() == 0)
01136       return;
01137     
01138     for (sc = KStarsFunctionList.first(); sc; sc = KStarsFunctionList.next())
01139       if (sc->prototype() == currentItem->text(0))
01140         break;
01141     
01142      if (sc == NULL)
01143      {
01144        for (sc = INDIFunctionList.first(); sc; sc = INDIFunctionList.next())
01145          if (sc->prototype() == currentItem->text(0))
01146            break;
01147        
01148      }
01149      
01150      if (sc == NULL) return;
01151       
01152       setUnsavedChanges( true );
01153 
01154       int Pos = sb->ScriptListBox->currentItem() + 1;
01155 
01156       ScriptList.insert( Pos, new ScriptFunction(sc) );
01157       sb->ScriptListBox->insertItem( ScriptList.current()->name(), Pos );
01158       sb->ScriptListBox->setSelected( Pos, true );
01159 }
01160 
01161 void ScriptBuilder::slotMoveFunctionUp() {
01162     if ( sb->ScriptListBox->currentItem() > 0 ) {
01163         setUnsavedChanges( true );
01164 
01165         QString t = sb->ScriptListBox->currentText();
01166         unsigned int n = sb->ScriptListBox->currentItem();
01167 
01168         ScriptFunction *tmp = ScriptList.take( n );
01169         ScriptList.insert( n-1, tmp );
01170 
01171         sb->ScriptListBox->removeItem( n );
01172         sb->ScriptListBox->insertItem( t, n-1 );
01173         sb->ScriptListBox->setSelected( n-1, true );
01174     }
01175 }
01176 
01177 void ScriptBuilder::slotMoveFunctionDown() {
01178     if ( sb->ScriptListBox->currentItem() > -1 &&
01179                 sb->ScriptListBox->currentItem() < ((int) sb->ScriptListBox->count())-1 ) {
01180         setUnsavedChanges( true );
01181 
01182         QString t = sb->ScriptListBox->currentText();
01183         unsigned int n = sb->ScriptListBox->currentItem();
01184 
01185         ScriptFunction *tmp = ScriptList.take( n );
01186         ScriptList.insert( n+1, tmp );
01187 
01188         sb->ScriptListBox->removeItem( n );
01189         sb->ScriptListBox->insertItem( t, n+1 );
01190         sb->ScriptListBox->setSelected( n+1, true );
01191     }
01192 }
01193 
01194 void ScriptBuilder::slotArgWidget() {
01195     //First, setEnabled on buttons that act on the selected script function
01196     if ( sb->ScriptListBox->currentItem() == -1 ) { //no selection
01197         sb->CopyButton->setEnabled( false );
01198         sb->RemoveButton->setEnabled( false );
01199         sb->UpButton->setEnabled( false );
01200         sb->DownButton->setEnabled( false );
01201     } else if ( sb->ScriptListBox->count() == 1 ) { //only one item, so disable up/down buttons
01202         sb->CopyButton->setEnabled( true );
01203         sb->RemoveButton->setEnabled( true );
01204         sb->UpButton->setEnabled( false );
01205         sb->DownButton->setEnabled( false );
01206     } else if ( sb->ScriptListBox->currentItem() == 0 ) { //first item selected
01207         sb->CopyButton->setEnabled( true );
01208         sb->RemoveButton->setEnabled( true );
01209         sb->UpButton->setEnabled( false );
01210         sb->DownButton->setEnabled( true );
01211     } else if ( sb->ScriptListBox->currentItem() == ((int) sb->ScriptListBox->count())-1 ) { //last item selected
01212         sb->CopyButton->setEnabled( true );
01213         sb->RemoveButton->setEnabled( true );
01214         sb->UpButton->setEnabled( true );
01215         sb->DownButton->setEnabled( false );
01216     } else { //other item selected
01217         sb->CopyButton->setEnabled( true );
01218         sb->RemoveButton->setEnabled( true );
01219         sb->UpButton->setEnabled( true );
01220         sb->DownButton->setEnabled( true );
01221     }
01222 
01223     //sb->RunButton enabled when script not empty.
01224     if ( sb->ScriptListBox->count() ) {
01225         sb->RunButton->setEnabled( true );
01226     } else {
01227         sb->RunButton->setEnabled( false );
01228         setUnsavedChanges( false );
01229     }
01230 
01231     //Display the function's arguments widget
01232     if ( sb->ScriptListBox->currentItem() > -1 &&
01233                 sb->ScriptListBox->currentItem() < ((int) sb->ScriptListBox->count()) ) {
01234         QString t = sb->ScriptListBox->currentText();
01235         unsigned int n = sb->ScriptListBox->currentItem();
01236         ScriptFunction *sf = ScriptList.at( n );
01237 
01238         if ( sf->name() == "lookTowards" ) {
01239             sb->ArgStack->raiseWidget( argLookToward );
01240             QString s = sf->argVal(0);
01241             argLookToward->FocusEdit->setCurrentText( s );
01242 
01243         } else if ( sf->name() == "setRaDec" ) {
01244             bool ok(false);
01245             double r(0.0),d(0.0);
01246             dms ra(0.0);
01247 
01248             sb->ArgStack->raiseWidget( argSetRaDec );
01249 
01250             ok = !sf->argVal(0).isEmpty();
01251             if (ok) r = sf->argVal(0).toDouble(&ok);
01252             else argSetRaDec->RaBox->clear();
01253             if (ok) { ra.setH(r); argSetRaDec->RaBox->showInHours( ra ); }
01254 
01255             ok = !sf->argVal(1).isEmpty();
01256             if (ok) d = sf->argVal(1).toDouble(&ok);
01257             else argSetRaDec->DecBox->clear();
01258             if (ok) argSetRaDec->DecBox->showInDegrees( dms(d) );
01259 
01260         } else if ( sf->name() == "setAltAz" ) {
01261             bool ok(false);
01262             double x(0.0),y(0.0);
01263 
01264             sb->ArgStack->raiseWidget( argSetAltAz );
01265 
01266             ok = !sf->argVal(0).isEmpty();
01267             if (ok) y = sf->argVal(0).toDouble(&ok);
01268             else argSetAltAz->AzBox->clear();
01269             if (ok) argSetAltAz->AltBox->showInDegrees( dms(y) );
01270             else argSetAltAz->AltBox->clear();
01271 
01272             ok = !sf->argVal(1).isEmpty();
01273             x = sf->argVal(1).toDouble(&ok);
01274             if (ok) argSetAltAz->AzBox->showInDegrees( dms(x) );
01275 
01276         } else if ( sf->name() == "zoomIn" ) {
01277             sb->ArgStack->raiseWidget( argBlank );
01278             //no Args
01279 
01280         } else if ( sf->name() == "zoomOut" ) {
01281             sb->ArgStack->raiseWidget( argBlank );
01282             //no Args
01283 
01284         } else if ( sf->name() == "defaultZoom" ) {
01285             sb->ArgStack->raiseWidget( argBlank );
01286             //no Args
01287 
01288         } else if ( sf->name() == "zoom" ) {
01289             sb->ArgStack->raiseWidget( argZoom );
01290             bool ok(false);
01291             /*double z = */sf->argVal(0).toDouble(&ok);
01292             if (ok) argZoom->ZoomBox->setText( sf->argVal(0) );
01293             else argZoom->ZoomBox->setText( "2000." );
01294 
01295         } else if ( sf->name() == "exportImage" ) {
01296             sb->ArgStack->raiseWidget( argExportImage );
01297             argExportImage->ExportFileName->setURL( sf->argVal(0) );
01298             bool ok(false);
01299             int w, h;
01300             w = sf->argVal(1).toInt( &ok );
01301             if (ok) h = sf->argVal(2).toInt( &ok );
01302             if (ok) { 
01303                 argExportImage->ExportWidth->setValue( w ); 
01304                 argExportImage->ExportHeight->setValue( h );
01305             } else { 
01306                 argExportImage->ExportWidth->setValue( ks->map()->width() ); 
01307                 argExportImage->ExportHeight->setValue( ks->map()->height() );
01308             }
01309 
01310         } else if ( sf->name() == "printImage" ) {
01311             if ( sf->argVal(0) == i18n( "true" ) ) argPrintImage->UsePrintDialog->setChecked( true );
01312             else argPrintImage->UsePrintDialog->setChecked( false );
01313             if ( sf->argVal(1) == i18n( "true" ) ) argPrintImage->UseChartColors->setChecked( true );
01314             else argPrintImage->UseChartColors->setChecked( false );
01315 
01316         } else if ( sf->name() == "setLocalTime" ) {
01317             sb->ArgStack->raiseWidget( argSetLocalTime );
01318             bool ok(false);
01319             int year, month, day, hour, min, sec;
01320 
01321             year = sf->argVal(0).toInt(&ok);
01322             if (ok) month = sf->argVal(1).toInt(&ok);
01323             if (ok) day   = sf->argVal(2).toInt(&ok);
01324             if (ok) argSetLocalTime->DateBox->setDate( ExtDate( year, month, day ) );
01325             else argSetLocalTime->DateBox->setDate( ExtDate::currentDate() );
01326 
01327             hour = sf->argVal(3).toInt(&ok);
01328             if ( sf->argVal(3).isEmpty() ) ok = false;
01329             if (ok) min = sf->argVal(4).toInt(&ok);
01330             if (ok) sec = sf->argVal(5).toInt(&ok);
01331             if (ok) argSetLocalTime->TimeBox->setTime( QTime( hour, min, sec ) );
01332             else argSetLocalTime->TimeBox->setTime( QTime( QTime::currentTime() ) );
01333 
01334         } else if ( sf->name() == "waitFor" ) {
01335             sb->ArgStack->raiseWidget( argWaitFor );
01336             bool ok(false);
01337             int sec = sf->argVal(0).toInt(&ok);
01338             if (ok) argWaitFor->DelayBox->setValue( sec );
01339             else argWaitFor->DelayBox->setValue( 0 );
01340 
01341         } else if ( sf->name() == "waitForKey" ) {
01342             sb->ArgStack->raiseWidget( argWaitForKey );
01343             if ( sf->argVal(0).length()==1 || sf->argVal(0).lower() == "space" )
01344                 argWaitForKey->WaitKeyEdit->setText( sf->argVal(0) );
01345             else argWaitForKey->WaitKeyEdit->setText( "" );
01346 
01347         } else if ( sf->name() == "setTracking" ) {
01348             sb->ArgStack->raiseWidget( argSetTracking );
01349             if ( sf->argVal(0) == i18n( "true" ) ) argSetTracking->CheckTrack->setChecked( true  );
01350             else argSetTracking->CheckTrack->setChecked( false );
01351 
01352         } else if ( sf->name() == "changeViewOption" ) {
01353             sb->ArgStack->raiseWidget( argChangeViewOption );
01354             //find argVal(0) in the combobox...if it isn't there, it will select nothing
01355             argChangeViewOption->OptionName->setCurrentItem( sf->argVal(0) );
01356             argChangeViewOption->OptionValue->setText( sf->argVal(1) );
01357 
01358         } else if ( sf->name() == "setGeoLocation" ) {
01359             sb->ArgStack->raiseWidget( argSetGeoLocation );
01360             argSetGeoLocation->CityName->setText( sf->argVal(0) );
01361             argSetGeoLocation->ProvinceName->setText( sf->argVal(1) );
01362             argSetGeoLocation->CountryName->setText( sf->argVal(2) );
01363 
01364         } else if ( sf->name() == "setColor" ) {
01365             sb->ArgStack->raiseWidget( argSetColor );
01366             if ( sf->argVal(0).isEmpty() ) sf->setArg( 0, "SkyColor" );  //initialize default value
01367             argSetColor->ColorName->setCurrentItem( ks->data()->colorScheme()->nameFromKey( sf->argVal(0) ) );
01368             argSetColor->ColorValue->setColor( QColor( sf->argVal(1).remove('\\') ) );
01369 
01370         } else if ( sf->name() == "loadColorScheme" ) {
01371             sb->ArgStack->raiseWidget( argLoadColorScheme );
01372             argLoadColorScheme->SchemeList->setCurrentItem( argLoadColorScheme->SchemeList->findItem( sf->argVal(0).remove('\"'), 0 ) );
01373 
01374         } else if ( sf->name() == "stop" ) {
01375             sb->ArgStack->raiseWidget( argBlank );
01376             //no Args
01377 
01378         } else if ( sf->name() == "start" ) {
01379             sb->ArgStack->raiseWidget( argBlank );
01380             //no Args
01381 
01382         } else if ( sf->name() == "setClockScale" ) {
01383             sb->ArgStack->raiseWidget( argTimeScale );
01384             bool ok(false);
01385             double ts = sf->argVal(0).toDouble(&ok);
01386             if (ok) argTimeScale->TimeScale->tsbox()->changeScale( float(ts) );
01387             else argTimeScale->TimeScale->tsbox()->changeScale( 0.0 );
01388 
01389         }
01390         else if (sf->name() == "startINDI") {
01391           sb->ArgStack->raiseWidget( argStartINDI);
01392           
01393           argStartINDI->deviceName->setText(sf->argVal(0));
01394           if (sf->argVal(1) == "true")
01395             argStartINDI->LocalButton->setChecked(true);
01396           else if (! sf->argVal(1).isEmpty())
01397             argStartINDI->LocalButton->setChecked(false);
01398         }
01399         else if (sf->name() == "shutdownINDI") {
01400           sb->ArgStack->raiseWidget( argShutdownINDI);
01401           
01402           //if (sf->valid()) kdDebug() << "begin: shutdown is valid" << endl;
01403         if (sb->ReuseINDIDeviceName->isChecked())
01404           {
01405             if (!sf->argVal(0).isEmpty())
01406               argShutdownINDI->deviceName->setText(sf->argVal(0));
01407             else if (argShutdownINDI->deviceName->text().isEmpty() || sf->argVal(0).isEmpty())
01408             argShutdownINDI->deviceName->setText(lastINDIDeviceName);
01409            else
01410              slotINDIShutdown();
01411           }
01412           else argShutdownINDI->deviceName->setText(sf->argVal(0));
01413           
01414           //if (sf->valid()) kdDebug() << "end: shutdown is valid" << endl;
01415         }
01416         else if (sf->name() == "switchINDI") {
01417           sb->ArgStack->raiseWidget( argSwitchINDI);
01418           
01419           if (sf->argVal(1) == "true" || sf->argVal(1).isEmpty())
01420             argSwitchINDI->OnButton->setChecked(true);
01421           else
01422             argSwitchINDI->OffButton->setChecked(true);
01423           
01424           argSwitchINDI->deviceName->clear();
01425           
01426           if (sb->ReuseINDIDeviceName->isChecked())
01427           {
01428             if (!sf->argVal(0).isEmpty())
01429               argSwitchINDI->deviceName->setText(sf->argVal(0));
01430             else 
01431               argSwitchINDI->deviceName->setText(lastINDIDeviceName);
01432           }
01433           else argSwitchINDI->deviceName->setText(sf->argVal(0));
01434           
01435         }
01436         else if (sf->name() == "setINDIPort") {
01437           sb->ArgStack->raiseWidget( argSetPortINDI);
01438           
01439           argSetPortINDI->devicePort->setText(sf->argVal(1));
01440           
01441           argSetPortINDI->deviceName->clear();
01442           
01443           if (sb->ReuseINDIDeviceName->isChecked())
01444           {
01445             if (!sf->argVal(0).isEmpty())
01446               argSetPortINDI->deviceName->setText(sf->argVal(0));
01447             else 
01448               argSetPortINDI->deviceName->setText(lastINDIDeviceName);
01449           }
01450           else argSetPortINDI->deviceName->setText(sf->argVal(0));
01451           
01452         }
01453         else if (sf->name() == "setINDITargetCoord") {
01454           bool ok(false);
01455           double r(0.0),d(0.0);
01456           dms ra(0.0);
01457           
01458           sb->ArgStack->raiseWidget( argSetTargetCoordINDI);
01459           
01460           ok = !sf->argVal(1).isEmpty();
01461           if (ok) r = sf->argVal(1).toDouble(&ok);
01462           else argSetTargetCoordINDI->RaBox->clear();
01463           if (ok) { ra.setH(r); argSetTargetCoordINDI->RaBox->showInHours( ra ); }
01464 
01465           ok = !sf->argVal(2).isEmpty();
01466           if (ok) d = sf->argVal(2).toDouble(&ok);
01467           else argSetTargetCoordINDI->DecBox->clear();
01468           if (ok) argSetTargetCoordINDI->DecBox->showInDegrees( dms(d) );
01469           
01470           argSetTargetCoordINDI->deviceName->clear();
01471           
01472           if (sb->ReuseINDIDeviceName->isChecked())
01473           {
01474             if (!sf->argVal(0).isEmpty())
01475               argSetTargetCoordINDI->deviceName->setText(sf->argVal(0));
01476             else 
01477               argSetTargetCoordINDI->deviceName->setText(lastINDIDeviceName);
01478           }
01479           else argSetTargetCoordINDI->deviceName->setText(sf->argVal(0));
01480           
01481         }
01482         else if (sf->name() == "setINDITargetName") {
01483           sb->ArgStack->raiseWidget( argSetTargetNameINDI);
01484           
01485           argSetTargetNameINDI->objectName->setText(sf->argVal(1));
01486           
01487           argSetTargetNameINDI->deviceName->clear();
01488           
01489           if (sb->ReuseINDIDeviceName->isChecked())
01490           {
01491             if (!sf->argVal(0).isEmpty())
01492               argSetTargetNameINDI->deviceName->setText(sf->argVal(0));
01493             else
01494               argSetTargetNameINDI->deviceName->setText(lastINDIDeviceName);
01495           }
01496           else argSetTargetNameINDI->deviceName->setText(sf->argVal(0));
01497           
01498         }
01499         else if (sf->name() == "setINDIAction") {
01500           sb->ArgStack->raiseWidget( argSetActionINDI);
01501           
01502           argSetActionINDI->actionName->setText(sf->argVal(1));
01503           
01504           argSetActionINDI->deviceName->clear();
01505           
01506           if (sb->ReuseINDIDeviceName->isChecked())
01507           {
01508             if (!sf->argVal(0).isEmpty())
01509               argSetActionINDI->deviceName->setText(sf->argVal(0));
01510             else
01511               argSetActionINDI->deviceName->setText(lastINDIDeviceName);
01512           }
01513           else argSetActionINDI->deviceName->setText(sf->argVal(0));
01514           
01515         }
01516         else if (sf->name() == "waitForINDIAction") {
01517           sb->ArgStack->raiseWidget( argWaitForActionINDI);
01518           
01519           argWaitForActionINDI->actionName->setText(sf->argVal(1));
01520           
01521           argWaitForActionINDI->deviceName->clear();
01522           
01523           if (sb->ReuseINDIDeviceName->isChecked())
01524           {
01525             if (!sf->argVal(0).isEmpty())
01526               argWaitForActionINDI->deviceName->setText(sf->argVal(0));
01527             else
01528               argWaitForActionINDI->deviceName->setText(lastINDIDeviceName);
01529           }
01530           else argWaitForActionINDI->deviceName->setText(sf->argVal(0));
01531           
01532         }
01533         else if (sf->name() == "setINDIFocusSpeed") {
01534           int t(0);
01535           bool ok(false);
01536           
01537           sb->ArgStack->raiseWidget( argSetFocusSpeedINDI);
01538 
01539           t = sf->argVal(1).toInt(&ok);
01540           if (ok) argSetFocusSpeedINDI->speedIN->setValue(t);
01541           else argSetFocusSpeedINDI->speedIN->setValue(0);
01542           
01543           argSetFocusSpeedINDI->deviceName->clear();
01544           
01545           if (sb->ReuseINDIDeviceName->isChecked())
01546           {
01547             if (!sf->argVal(0).isEmpty())
01548               argSetFocusSpeedINDI->deviceName->setText(sf->argVal(0));
01549             else
01550               argSetFocusSpeedINDI->deviceName->setText(lastINDIDeviceName);
01551           }
01552           else argSetFocusSpeedINDI->deviceName->setText(sf->argVal(0));
01553           
01554         }
01555         else if (sf->name() == "startINDIFocus") {
01556           sb->ArgStack->raiseWidget( argStartFocusINDI);
01557           bool itemSet(false);
01558           
01559           for (int i=0; i < argStartFocusINDI->directionCombo->count(); i++)
01560           {
01561             if (argStartFocusINDI->directionCombo->text(i) == sf->argVal(1))
01562             {
01563               argStartFocusINDI->directionCombo->setCurrentItem(i);
01564               itemSet = true;
01565               break;
01566             }
01567           }
01568           
01569           if (!itemSet) argStartFocusINDI->directionCombo->setCurrentItem(0);
01570           
01571           argStartFocusINDI->deviceName->clear();
01572           
01573           if (sb->ReuseINDIDeviceName->isChecked())
01574           {
01575             if (!sf->argVal(0).isEmpty())
01576               argStartFocusINDI->deviceName->setText(sf->argVal(0));
01577             else
01578               argStartFocusINDI->deviceName->setText(lastINDIDeviceName);
01579           }
01580           else argStartFocusINDI->deviceName->setText(sf->argVal(0));
01581           
01582         }
01583         else if (sf->name() == "setINDIFocusTimeout") {
01584           int t(0);
01585           bool ok(false);
01586           
01587           sb->ArgStack->raiseWidget( argSetFocusTimeoutINDI);
01588           
01589           t = sf->argVal(1).toInt(&ok);
01590           if (ok) argSetFocusTimeoutINDI->timeOut->setValue(t);
01591           else argSetFocusTimeoutINDI->timeOut->setValue(0);
01592           
01593           argSetFocusTimeoutINDI->deviceName->clear();
01594           
01595           if (sb->ReuseINDIDeviceName->isChecked())
01596           {
01597             if (!sf->argVal(0).isEmpty())
01598               argSetFocusTimeoutINDI->deviceName->setText(sf->argVal(0));
01599             else
01600               argSetFocusTimeoutINDI->deviceName->setText(lastINDIDeviceName);
01601           }
01602           else argSetFocusTimeoutINDI->deviceName->setText(sf->argVal(0));
01603              
01604           }
01605           else if (sf->name() == "setINDIGeoLocation") {
01606             bool ok(false);
01607             double lo(0.0),la(0.0);
01608           
01609             sb->ArgStack->raiseWidget( argSetGeoLocationINDI);
01610           
01611             ok = !sf->argVal(1).isEmpty();
01612             if (ok) lo = sf->argVal(1).toDouble(&ok);
01613             else argSetGeoLocationINDI->longBox->clear();
01614             if (ok) { argSetGeoLocationINDI->longBox->showInDegrees( dms(lo) ); }
01615 
01616             ok = !sf->argVal(2).isEmpty();
01617             if (ok) la = sf->argVal(2).toDouble(&ok);
01618             else argSetGeoLocationINDI->latBox->clear();
01619             if (ok) argSetGeoLocationINDI->latBox->showInDegrees( dms(la) );
01620             
01621             argSetGeoLocationINDI->deviceName->clear();
01622             
01623             if (sb->ReuseINDIDeviceName->isChecked())
01624             {
01625               if (!sf->argVal(0).isEmpty())
01626             argSetGeoLocationINDI->deviceName->setText(sf->argVal(0));
01627               else
01628             argSetGeoLocationINDI->deviceName->setText(lastINDIDeviceName);
01629             }
01630             else argSetGeoLocationINDI->deviceName->setText(sf->argVal(0));
01631             
01632           }
01633           else if (sf->name() == "startINDIExposure") {
01634             int t(0);
01635             bool ok(false);
01636           
01637             sb->ArgStack->raiseWidget( argStartExposureINDI);
01638           
01639             t = sf->argVal(1).toInt(&ok);
01640             if (ok) argStartExposureINDI->timeOut->setValue(t);
01641             else argStartExposureINDI->timeOut->setValue(0);
01642             
01643             argStartExposureINDI->deviceName->clear();
01644             
01645             if (sb->ReuseINDIDeviceName->isChecked())
01646             {
01647               if (!sf->argVal(0).isEmpty())
01648             argStartExposureINDI->deviceName->setText(sf->argVal(0));
01649               else
01650             argStartExposureINDI->deviceName->setText(lastINDIDeviceName);
01651             }
01652             else argStartExposureINDI->deviceName->setText(sf->argVal(0));
01653              
01654           }
01655           else if (sf->name() == "setINDIUTC") {
01656             sb->ArgStack->raiseWidget( argSetUTCINDI);
01657           
01658             argSetUTCINDI->UTC->setText(sf->argVal(1));
01659             
01660             argSetUTCINDI->deviceName->clear();
01661             
01662             if (sb->ReuseINDIDeviceName->isChecked())
01663             {
01664               if (!sf->argVal(0).isEmpty())
01665             argSetUTCINDI->deviceName->setText(sf->argVal(0));
01666               else 
01667             argSetUTCINDI->deviceName->setText(lastINDIDeviceName);
01668             }
01669             else argSetUTCINDI->deviceName->setText(sf->argVal(0));
01670           
01671           }
01672           else if (sf->name() == "setINDIScopeAction") {
01673             sb->ArgStack->raiseWidget( argSetScopeActionINDI);
01674             bool itemSet(false);
01675           
01676             for (int i=0; i < argSetScopeActionINDI->actionCombo->count(); i++)
01677             {
01678               if (argSetScopeActionINDI->actionCombo->text(i) == sf->argVal(1))
01679               {
01680             argSetScopeActionINDI->actionCombo->setCurrentItem(i);
01681             itemSet = true;
01682             break;
01683               }
01684             }
01685           
01686             if (!itemSet) argSetScopeActionINDI->actionCombo->setCurrentItem(0);
01687           
01688             argSetScopeActionINDI->deviceName->clear();
01689             
01690             if (sb->ReuseINDIDeviceName->isChecked())
01691             {
01692               if (!sf->argVal(0).isEmpty())
01693             argSetScopeActionINDI->deviceName->setText(sf->argVal(0));
01694               else 
01695             argSetScopeActionINDI->deviceName->setText(lastINDIDeviceName);
01696             }
01697             else argSetScopeActionINDI->deviceName->setText(sf->argVal(0));
01698           
01699           }
01700           else if (sf->name() == "setINDIFrameType") {
01701             sb->ArgStack->raiseWidget( argSetFrameTypeINDI);
01702             bool itemSet(false);
01703           
01704             for (int i=0; i < argSetFrameTypeINDI->typeCombo->count(); i++)
01705             {
01706               if (argSetFrameTypeINDI->typeCombo->text(i) == sf->argVal(1))
01707               {
01708             argSetFrameTypeINDI->typeCombo->setCurrentItem(i);
01709             itemSet = true;
01710             break;
01711               }
01712             }
01713           
01714             if (!itemSet) argSetFrameTypeINDI->typeCombo->setCurrentItem(0);
01715           
01716             argSetFrameTypeINDI->deviceName->clear();
01717             
01718             if (sb->ReuseINDIDeviceName->isChecked())
01719             {
01720               if (!sf->argVal(0).isEmpty())
01721             argSetFrameTypeINDI->deviceName->setText(sf->argVal(0));
01722               else
01723             argSetFrameTypeINDI->deviceName->setText(lastINDIDeviceName);
01724             }
01725             else argSetFrameTypeINDI->deviceName->setText(sf->argVal(0));
01726           
01727           }
01728           else if (sf->name() == "setINDICCDTemp") {
01729             int t(0);
01730             bool ok(false);
01731           
01732             sb->ArgStack->raiseWidget( argSetCCDTempINDI);
01733           
01734             t = sf->argVal(1).toInt(&ok);
01735             if (ok) argSetCCDTempINDI->temp->setValue(t);
01736             else argSetCCDTempINDI->temp->setValue(0);
01737           
01738             argSetCCDTempINDI->deviceName->clear();
01739             
01740             if (sb->ReuseINDIDeviceName->isChecked())
01741             {
01742               if (!sf->argVal(0).isEmpty())
01743             argSetCCDTempINDI->deviceName->setText(sf->argVal(0));
01744               else
01745             argSetCCDTempINDI->deviceName->setText(lastINDIDeviceName);
01746             }
01747             else argSetCCDTempINDI->deviceName->setText(sf->argVal(0));
01748              
01749           }
01750           else if (sf->name() == "setINDIFilterNum") {
01751             int t(0);
01752             bool ok(false);
01753           
01754             sb->ArgStack->raiseWidget( argSetFilterNumINDI);
01755           
01756             t = sf->argVal(1).toInt(&ok);
01757             if (ok) argSetFilterNumINDI->filter_num->setValue(t);
01758             else argSetFilterNumINDI->filter_num->setValue(0);
01759           
01760             argSetFilterNumINDI->deviceName->clear();
01761             
01762             if (sb->ReuseINDIDeviceName->isChecked())
01763             {
01764               if (!sf->argVal(0).isEmpty())
01765             argSetFilterNumINDI->deviceName->setText(sf->argVal(0));
01766               else
01767             argSetFilterNumINDI->deviceName->setText(lastINDIDeviceName);
01768             }
01769             else argSetFilterNumINDI->deviceName->setText(sf->argVal(0));
01770              
01771           }
01772     }
01773 }
01774 
01775 void ScriptBuilder::slotShowDoc() {
01776   ScriptFunction *sc = NULL;
01777   QListViewItem *currentItem = sb->FunctionListView->currentItem();
01778     
01779   if ( currentItem == NULL || currentItem->depth() == 0)
01780     return;
01781     
01782   for (sc = KStarsFunctionList.first(); sc; sc = KStarsFunctionList.next())
01783     if (sc->prototype() == currentItem->text(0))
01784       break;
01785   
01786   if (sc == NULL)
01787   {
01788   for (sc = INDIFunctionList.first(); sc; sc = INDIFunctionList.next())
01789     if (sc->prototype() == currentItem->text(0))
01790       break;
01791   }
01792     
01793   if (sc == NULL)
01794   {
01795     sb->AddButton->setEnabled( false );
01796     kdWarning() << i18n( "Function index out of bounds." ) << endl;
01797     return;
01798   }
01799       
01800     sb->AddButton->setEnabled( true );
01801     sb->FuncDoc->setText( sc->description() );
01802 }
01803 
01804 //Slots for Arg Widgets
01805 void ScriptBuilder::slotFindCity() {
01806     LocationDialog ld( ks );
01807 
01808     if ( ld.exec() == QDialog::Accepted ) {
01809         if ( ld.selectedCity() ) {
01810             // set new location names
01811             argSetGeoLocation->CityName->setText( ld.selectedCityName() );
01812             argSetGeoLocation->ProvinceName->setText( ld.selectedProvinceName() );
01813             argSetGeoLocation->CountryName->setText( ld.selectedCountryName() );
01814 
01815             ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01816             if ( sf->name() == "setGeoLocation" ) {
01817                 setUnsavedChanges( true );
01818 
01819                 sf->setArg( 0, ld.selectedCityName() );
01820                 sf->setArg( 1, ld.selectedProvinceName() );
01821                 sf->setArg( 2, ld.selectedCountryName() );
01822             } else {
01823                 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
01824             }
01825         }
01826     }
01827 }
01828 
01829 void ScriptBuilder::slotFindObject() {
01830     FindDialog fd( ks );
01831 
01832     if ( fd.exec() == QDialog::Accepted && fd.currentItem() ) {
01833         setUnsavedChanges( true );
01834 
01835         argLookToward->FocusEdit->setCurrentText( fd.currentItem()->objName()->text() );
01836     }
01837 }
01838 
01839 void ScriptBuilder::slotINDIFindObject() {
01840   FindDialog fd( ks );
01841 
01842   if ( fd.exec() == QDialog::Accepted && fd.currentItem() ) {
01843     setUnsavedChanges( true );
01844 
01845     argSetTargetNameINDI->objectName->setText( fd.currentItem()->objName()->text() );
01846   }
01847 }
01848 
01849 void ScriptBuilder::slotINDIWaitCheck(bool /*toggleState*/)
01850 {
01851   
01852    setUnsavedChanges(true);  
01853   
01854 }
01855 
01856 void ScriptBuilder::slotShowOptions() {
01857     //Show tree-view of view options
01858     if ( otv->exec() == QDialog::Accepted ) {
01859         argChangeViewOption->OptionName->setCurrentItem( otv->OptionsList->currentItem()->text(0) );
01860     }
01861 }
01862 
01863 void ScriptBuilder::slotLookToward() {
01864     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01865 
01866     if ( sf->name() == "lookTowards" ) {
01867         setUnsavedChanges( true );
01868 
01869         sf->setArg( 0, argLookToward->FocusEdit->currentText() );
01870         sf->setValid(true);
01871     } else {
01872         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "lookTowards" ) << endl;
01873     }
01874 }
01875 
01876 void ScriptBuilder::slotRa() {
01877     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01878 
01879     if ( sf->name() == "setRaDec" ) {
01880         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
01881         if ( argSetRaDec->RaBox->text().isEmpty() ) return;
01882 
01883         bool ok(false);
01884         dms ra = argSetRaDec->RaBox->createDms(false, &ok);
01885         if ( ok ) {
01886             setUnsavedChanges( true );
01887 
01888             sf->setArg( 0, QString( "%1" ).arg( ra.Hours() ) );
01889             if ( ! sf->argVal(1).isEmpty() ) sf->setValid( true );
01890 
01891         } else {
01892             sf->setArg( 0, "" );
01893             sf->setValid( false );
01894         }
01895     } else {
01896         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setRaDec" ) << endl;
01897     }
01898 }
01899 
01900 void ScriptBuilder::slotDec() {
01901     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01902 
01903     if ( sf->name() == "setRaDec" ) {
01904         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
01905         if ( argSetRaDec->DecBox->text().isEmpty() ) return;
01906 
01907         bool ok(false);
01908         dms dec = argSetRaDec->DecBox->createDms(true, &ok);
01909         if ( ok ) {
01910             setUnsavedChanges( true );
01911 
01912             sf->setArg( 1, QString( "%1" ).arg( dec.Degrees() ) );
01913             if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
01914 
01915         } else {
01916             sf->setArg( 1, "" );
01917             sf->setValid( false );
01918         }
01919     } else {
01920         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setRaDec" ) << endl;
01921     }
01922 }
01923 
01924 void ScriptBuilder::slotAz() {
01925     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01926 
01927     if ( sf->name() == "setAltAz" ) {
01928         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
01929         if ( argSetAltAz->AzBox->text().isEmpty() ) return;
01930 
01931         bool ok(false);
01932         dms az = argSetAltAz->AzBox->createDms(true, &ok);
01933         if ( ok ) {
01934             setUnsavedChanges( true );
01935             sf->setArg( 1, QString( "%1" ).arg( az.Degrees() ) );
01936             if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
01937         } else {
01938             sf->setArg( 1, "" );
01939             sf->setValid( false );
01940         }
01941     } else {
01942         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setAltAz" ) << endl;
01943     }
01944 }
01945 
01946 void ScriptBuilder::slotAlt() {
01947     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01948 
01949     if ( sf->name() == "setAltAz" ) {
01950         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
01951         if ( argSetAltAz->AltBox->text().isEmpty() ) return;
01952 
01953         bool ok(false);
01954         dms alt = argSetAltAz->AltBox->createDms(true, &ok);
01955         if ( ok ) {
01956             setUnsavedChanges( true );
01957 
01958             sf->setArg( 0, QString( "%1" ).arg( alt.Degrees() ) );
01959             if ( ! sf->argVal(1).isEmpty() ) sf->setValid( true );
01960         } else {
01961             sf->setArg( 0, "" );
01962             sf->setValid( false );
01963         }
01964     } else {
01965         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setAltAz" ) << endl;
01966     }
01967 }
01968 
01969 void ScriptBuilder::slotChangeDate() {
01970     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01971 
01972     if ( sf->name() == "setLocalTime" ) {
01973         setUnsavedChanges( true );
01974 
01975         ExtDate date = argSetLocalTime->DateBox->date();
01976 
01977         sf->setArg( 0, QString( "%1" ).arg( date.year()   ) );
01978         sf->setArg( 1, QString( "%1" ).arg( date.month()  ) );
01979         sf->setArg( 2, QString( "%1" ).arg( date.day()    ) );
01980         if ( ! sf->argVal(3).isEmpty() ) sf->setValid( true );
01981     } else {
01982         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setLocalTime" ) << endl;
01983     }
01984 }
01985 
01986 void ScriptBuilder::slotChangeTime() {
01987     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
01988 
01989     if ( sf->name() == "setLocalTime" ) {
01990         setUnsavedChanges( true );
01991 
01992         QTime time = argSetLocalTime->TimeBox->time();
01993 
01994         sf->setArg( 3, QString( "%1" ).arg( time.hour()   ) );
01995         sf->setArg( 4, QString( "%1" ).arg( time.minute() ) );
01996         sf->setArg( 5, QString( "%1" ).arg( time.second() ) );
01997         if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
01998     } else {
01999         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setLocalTime" ) << endl;
02000     }
02001 }
02002 
02003 void ScriptBuilder::slotWaitFor() {
02004     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02005 
02006     if ( sf->name() == "waitFor" ) {
02007         bool ok(false);
02008         int delay = argWaitFor->DelayBox->text().toInt( &ok );
02009 
02010         if ( ok ) {
02011             setUnsavedChanges( true );
02012 
02013             sf->setArg( 0, QString( "%1" ).arg( delay ) );
02014             sf->setValid( true );
02015         } else {
02016             sf->setValid( false );
02017         }
02018     } else {
02019         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitFor" ) << endl;
02020     }
02021 }
02022 
02023 void ScriptBuilder::slotWaitForKey() {
02024     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02025 
02026     if ( sf->name() == "waitForKey" ) {
02027         QString sKey = argWaitForKey->WaitKeyEdit->text().stripWhiteSpace();
02028 
02029         //DCOP script can only use single keystrokes; make sure entry is either one character,
02030         //or the word 'space'
02031         if ( sKey.length() == 1 || sKey == "space" ) {
02032             setUnsavedChanges( true );
02033 
02034             sf->setArg( 0, sKey );
02035             sf->setValid( true );
02036         } else {
02037             sf->setValid( false );
02038         }
02039     } else {
02040         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitForKey" ) << endl;
02041     }
02042 }
02043 
02044 void ScriptBuilder::slotTracking() {
02045     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02046 
02047     if ( sf->name() == "setTracking" ) {
02048         setUnsavedChanges( true );
02049 
02050         sf->setArg( 0, ( argSetTracking->CheckTrack->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
02051         sf->setValid( true );
02052     } else {
02053         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setTracking" ) << endl;
02054     }
02055 }
02056 
02057 void ScriptBuilder::slotViewOption() {
02058     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02059 
02060     if ( sf->name() == "changeViewOption" ) {
02061         if ( argChangeViewOption->OptionName->currentItem() >= 0
02062                 && argChangeViewOption->OptionValue->text().length() ) {
02063             setUnsavedChanges( true );
02064 
02065             sf->setArg( 0, argChangeViewOption->OptionName->currentText() );
02066             sf->setArg( 1, argChangeViewOption->OptionValue->text() );
02067             sf->setValid( true );
02068         } else {
02069             sf->setValid( false );
02070         }
02071     } else {
02072         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "changeViewOption" ) << endl;
02073     }
02074 }
02075 
02076 void ScriptBuilder::slotChangeCity() {
02077     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02078 
02079     if ( sf->name() == "setGeoLocation" ) {
02080         QString city =     argSetGeoLocation->CityName->text();
02081 
02082         if ( city.length() ) {
02083             setUnsavedChanges( true );
02084 
02085             sf->setArg( 0, city );
02086             if ( sf->argVal(2).length() ) sf->setValid( true );
02087         } else {
02088             sf->setArg( 0, "" );
02089             sf->setValid( false );
02090         }
02091     } else {
02092         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
02093     }
02094 }
02095 
02096 void ScriptBuilder::slotChangeProvince() {
02097     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02098 
02099     if ( sf->name() == "setGeoLocation" ) {
02100         QString province = argSetGeoLocation->ProvinceName->text();
02101 
02102         if ( province.length() ) {
02103             setUnsavedChanges( true );
02104 
02105             sf->setArg( 1, province );
02106             if ( sf->argVal(0).length() && sf->argVal(2).length() ) sf->setValid( true );
02107         } else {
02108             sf->setArg( 1, "" );
02109             //might not be invalid
02110         }
02111     } else {
02112         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
02113     }
02114 }
02115 
02116 void ScriptBuilder::slotChangeCountry() {
02117     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02118 
02119     if ( sf->name() == "setGeoLocation" ) {
02120         QString country =  argSetGeoLocation->CountryName->text();
02121 
02122         if ( country.length() ) {
02123             setUnsavedChanges( true );
02124 
02125             sf->setArg( 2, country );
02126             if ( sf->argVal(0).length() ) sf->setValid( true );
02127         } else {
02128             sf->setArg( 2, "" );
02129             sf->setValid( false );
02130         }
02131     } else {
02132         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
02133     }
02134 }
02135 
02136 void ScriptBuilder::slotTimeScale() {
02137     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02138 
02139     if ( sf->name() == "setClockScale" ) {
02140         setUnsavedChanges( true );
02141 
02142         sf->setArg( 0, QString( "%1" ).arg( argTimeScale->TimeScale->tsbox()->timeScale() ) );
02143         sf->setValid( true );
02144     } else {
02145         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setClockScale" ) << endl;
02146     }
02147 }
02148 
02149 void ScriptBuilder::slotZoom() {
02150     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02151 
02152     if ( sf->name() == "zoom" ) {
02153         setUnsavedChanges( true );
02154 
02155         bool ok(false);
02156         argZoom->ZoomBox->text().toDouble(&ok);
02157         if ( ok ) {
02158             sf->setArg( 0, argZoom->ZoomBox->text() );
02159             sf->setValid( true );
02160         }
02161     } else {
02162         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "zoom" ) << endl;
02163     }
02164 }
02165 
02166 void ScriptBuilder::slotExportImage() {
02167     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02168 
02169     if ( sf->name() == "exportImage" ) {
02170         setUnsavedChanges( true );
02171         
02172         sf->setArg( 0, argExportImage->ExportFileName->url() );
02173         sf->setArg( 1, QString("%1").arg( argExportImage->ExportWidth->value() ) );
02174         sf->setArg( 2, QString("%1").arg( argExportImage->ExportHeight->value() ) );
02175         sf->setValid( true );
02176     } else {
02177         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "exportImage" ) << endl;
02178     }
02179 }
02180 
02181 void ScriptBuilder::slotPrintImage() {
02182     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02183 
02184     if ( sf->name() == "printImage" ) {
02185         setUnsavedChanges( true );
02186         
02187         sf->setArg( 0, ( argPrintImage->UsePrintDialog->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
02188         sf->setArg( 1, ( argPrintImage->UseChartColors->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
02189         sf->setValid( true );
02190     } else {
02191         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "exportImage" ) << endl;
02192     }
02193 }
02194 
02195 void ScriptBuilder::slotChangeColorName() {
02196     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02197 
02198     if ( sf->name() == "setColor" ) {
02199         setUnsavedChanges( true );
02200         
02201         argSetColor->ColorValue->setColor( ks->data()->colorScheme()->colorAt( argSetColor->ColorName->currentItem() ) );
02202         sf->setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentItem() ) );
02203         QString cname( argSetColor->ColorValue->color().name() );
02204         if ( cname.at(0) == '#' ) cname = "\\" + cname; //prepend a "\" so bash doesn't think we have a comment
02205         sf->setArg( 1, cname );
02206         sf->setValid( true );
02207     } else {
02208         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setColor" ) << endl;
02209     }
02210 }
02211 
02212 void ScriptBuilder::slotChangeColor() {
02213     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02214 
02215     if ( sf->name() == "setColor" ) {
02216         setUnsavedChanges( true );
02217         
02218         sf->setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentItem() ) );
02219         QString cname( argSetColor->ColorValue->color().name() );
02220         if ( cname.at(0) == '#' ) cname = "\\" + cname; //prepend a "\" so bash doesn't think we have a comment
02221         sf->setArg( 1, cname );
02222         sf->setValid( true );
02223     } else {
02224         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setColor" ) << endl;
02225     }
02226 }
02227 
02228 void ScriptBuilder::slotLoadColorScheme(QListBoxItem */*i*/) {
02229     ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02230 
02231     if ( sf->name() == "loadColorScheme" ) {
02232         setUnsavedChanges( true );
02233         
02234         sf->setArg( 0, "\"" + argLoadColorScheme->SchemeList->currentText() + "\"" );
02235         sf->setValid( true );
02236     } else {
02237         kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "loadColorScheme" ) << endl;
02238     }
02239 }
02240 
02241 void ScriptBuilder::slotClose() {
02242     saveWarning();
02243 
02244     if ( !UnsavedChanges ) {
02245         emit closeClicked();
02246         reject();
02247     }
02248 }
02249 
02250 void ScriptBuilder::slotINDIStartDeviceName()
02251 {
02252   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02253 
02254   if ( sf->name() == "startINDI" )
02255   {
02256     setUnsavedChanges( true );
02257     
02258     lastINDIDeviceName = argStartINDI->deviceName->text();
02259     
02260     sf->setArg(0, lastINDIDeviceName);
02261     sf->setArg(1, argStartINDI->LocalButton->isChecked() ? "true" : "false");
02262     sf->setValid(true);
02263   }
02264   else
02265   {
02266     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDI" ) << endl;
02267   }
02268   
02269 }
02270 
02271 void ScriptBuilder::slotINDIStartDeviceMode()
02272 {
02273   
02274   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02275 
02276   if ( sf->name() == "startINDI" )
02277   {
02278     setUnsavedChanges( true );
02279     
02280     sf->setArg(1, argStartINDI->LocalButton->isChecked() ? "true" : "false");
02281     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
02282   }
02283   else
02284   {
02285     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDI" ) << endl;
02286   }
02287   
02288 }
02289 
02290 void ScriptBuilder::slotINDIShutdown()
02291 {
02292   
02293   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02294 
02295   if ( sf->name() == "shutdownINDI" )
02296   {
02297     if (argShutdownINDI->deviceName->text().isEmpty())
02298     {
02299       sf->setValid(false);
02300       return;
02301     }
02302     
02303     if (sf->argVal(0) != argShutdownINDI->deviceName->text())
02304         setUnsavedChanges( true );
02305     
02306     sf->setArg(0, argShutdownINDI->deviceName->text());
02307     sf->setValid(true);
02308   }
02309   else
02310   {
02311     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "shutdownINDI" ) << endl;
02312   }
02313   
02314 }
02315 
02316 void ScriptBuilder::slotINDISwitchDeviceName()
02317 {
02318   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02319 
02320   if ( sf->name() == "switchINDI" )
02321   {
02322     if (argSwitchINDI->deviceName->text().isEmpty())
02323     {
02324       sf->setValid(false);
02325       return;
02326     }
02327     
02328     if (sf->argVal(0) != argSwitchINDI->deviceName->text())
02329         setUnsavedChanges( true );
02330     
02331     sf->setArg(0, argSwitchINDI->deviceName->text());
02332     sf->setArg(1, argSwitchINDI->OnButton->isChecked() ? "true" : "false");
02333     sf->setValid(true);
02334   }
02335   else
02336   {
02337     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "switchdownINDI" ) << endl;
02338   }
02339   
02340 }
02341 
02342 void ScriptBuilder::slotINDISwitchDeviceConnection()
02343 {
02344   
02345   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02346 
02347   if ( sf->name() == "switchINDI" )
02348   {
02349     
02350     if (sf->argVal(1) != (argSwitchINDI->OnButton->isChecked() ? "true" : "false"))
02351     setUnsavedChanges( true );
02352     
02353     sf->setArg(1, argSwitchINDI->OnButton->isChecked() ? "true" : "false");
02354     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
02355     else sf->setValid(false);
02356   }
02357   else
02358   {
02359     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "switchINDI" ) << endl;
02360   }
02361   
02362 }
02363 
02364 void ScriptBuilder::slotINDISetPortDeviceName()
02365 {
02366   
02367   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02368 
02369   if ( sf->name() == "setINDIPort" )
02370   {
02371     if (argSetPortINDI->deviceName->text().isEmpty())
02372     {
02373       sf->setValid(false);
02374       return;
02375     }
02376     
02377     if (sf->argVal(0) != argSetPortINDI->deviceName->text())
02378         setUnsavedChanges( true );
02379     
02380     sf->setArg(0, argSetPortINDI->deviceName->text());
02381     if (! sf->argVal(1).isEmpty()) sf->setValid(true);
02382     else sf->setValid(false);
02383     
02384   }
02385   else
02386   {
02387     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIPort" ) << endl;
02388   }
02389   
02390   
02391 }
02392 
02393 void ScriptBuilder::slotINDISetPortDevicePort()
02394 {
02395   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02396 
02397   if ( sf->name() == "setINDIPort" )
02398   {
02399     
02400     if (argSetPortINDI->devicePort->text().isEmpty())
02401     {
02402       sf->setValid(false);
02403       return;
02404     }
02405     
02406     if (sf->argVal(1) != argSetPortINDI->devicePort->text())
02407         setUnsavedChanges( true );
02408     
02409     sf->setArg(1, argSetPortINDI->devicePort->text());
02410     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
02411     else sf->setValid(false);
02412   }
02413   else
02414   {
02415     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIPort" ) << endl;
02416   }
02417   
02418 }
02419 
02420 void ScriptBuilder::slotINDISetTargetCoordDeviceName()
02421 {
02422   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02423 
02424   if ( sf->name() == "setINDITargetCoord" )
02425   {
02426     if (argSetTargetCoordINDI->deviceName->text().isEmpty())
02427     {
02428       sf->setValid(false);
02429       return;
02430     }
02431     
02432     if (sf->argVal(0) != argSetTargetCoordINDI->deviceName->text())
02433         setUnsavedChanges( true );
02434     
02435     sf->setArg(0, argSetTargetCoordINDI->deviceName->text());
02436     if ((! sf->argVal(1).isEmpty()) && (! sf->argVal(2).isEmpty())) sf->setValid(true);
02437     else sf->setValid(false);
02438   }
02439   else
02440   {
02441     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetCoord" ) << endl;
02442   }
02443   
02444 }
02445 
02446 void ScriptBuilder::slotINDISetTargetCoordDeviceRA()
02447 {
02448   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02449 
02450   if ( sf->name() == "setINDITargetCoord" ) {
02451         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
02452     if ( argSetTargetCoordINDI->RaBox->text().isEmpty() )
02453     {
02454       sf->setValid(false);
02455       return;
02456     }
02457 
02458     bool ok(false);
02459     dms ra = argSetTargetCoordINDI->RaBox->createDms(false, &ok);
02460     if ( ok ) {
02461       
02462       if (sf->argVal(1) != QString( "%1" ).arg( ra.Hours() ))
02463         setUnsavedChanges( true );
02464 
02465       sf->setArg( 1, QString( "%1" ).arg( ra.Hours() ) );
02466       if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(2).isEmpty() )) sf->setValid( true );
02467       else sf->setValid(false);
02468 
02469     } else {
02470       sf->setArg( 1, "" );
02471       sf->setValid( false );
02472     }
02473   } else {
02474     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetCoord" ) << endl;
02475   }
02476   
02477 }
02478 
02479 void ScriptBuilder::slotINDISetTargetCoordDeviceDEC()
02480 {
02481   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02482 
02483   if ( sf->name() == "setINDITargetCoord" ) {
02484         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
02485     if ( argSetTargetCoordINDI->DecBox->text().isEmpty() )
02486     {
02487       sf->setValid(false);
02488       return;
02489     }
02490 
02491     bool ok(false);
02492     dms dec = argSetTargetCoordINDI->DecBox->createDms(true, &ok);
02493     if ( ok ) {
02494       
02495       if (sf->argVal(2) != QString( "%1" ).arg( dec.Degrees() ))
02496         setUnsavedChanges( true );
02497 
02498       sf->setArg( 2, QString( "%1" ).arg( dec.Degrees() ) );
02499       if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(1).isEmpty() )) sf->setValid( true );
02500       else sf->setValid(false);
02501       
02502     } else {
02503       sf->setArg( 2, "" );
02504       sf->setValid( false );
02505     }
02506   } else {
02507     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetCoord" ) << endl;
02508   }
02509   
02510 }
02511 
02512 void ScriptBuilder::slotINDISetTargetNameDeviceName()
02513 {
02514   
02515   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02516 
02517   if ( sf->name() == "setINDITargetName" )
02518   {
02519     if (argSetTargetNameINDI->deviceName->text().isEmpty())
02520     {
02521       sf->setValid(false);
02522       return;
02523     }
02524     
02525     if (sf->argVal(0) != argSetTargetNameINDI->deviceName->text())
02526         setUnsavedChanges( true );
02527     
02528     sf->setArg(0, argSetTargetNameINDI->deviceName->text());
02529     if ((! sf->argVal(1).isEmpty())) sf->setValid(true);
02530     else sf->setValid(false);
02531   }
02532   else
02533   {
02534     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetName" ) << endl;
02535   }
02536   
02537 }
02538 
02539 void ScriptBuilder::slotINDISetTargetNameObjectName()
02540 {
02541   
02542   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02543 
02544   if ( sf->name() == "setINDITargetName" )
02545   {
02546     if (argSetTargetNameINDI->objectName->text().isEmpty())
02547     {
02548       sf->setValid(false);
02549       return;
02550     }
02551     
02552     if (sf->argVal(1) != argSetTargetNameINDI->objectName->text())
02553         setUnsavedChanges( true );
02554     
02555     sf->setArg(1, argSetTargetNameINDI->objectName->text());
02556     if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
02557     else sf->setValid(false);
02558   }
02559   else
02560   {
02561     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetName" ) << endl;
02562   }
02563   
02564 }
02565 
02566 void ScriptBuilder::slotINDISetActionDeviceName()
02567 {
02568   
02569   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02570 
02571   if ( sf->name() == "setINDIAction" )
02572   {
02573     if (argSetActionINDI->deviceName->text().isEmpty())
02574     {
02575       sf->setValid(false);
02576       return;
02577     }
02578     
02579     if (sf->argVal(0) != argSetActionINDI->deviceName->text())
02580         setUnsavedChanges( true );
02581     
02582     sf->setArg(0, argSetActionINDI->deviceName->text());
02583     if ((! sf->argVal(1).isEmpty())) sf->setValid(true);
02584     else sf->setValid(false);
02585   }
02586   else
02587   {
02588     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIAction") << endl;
02589   }
02590   
02591 }
02592     
02593 void ScriptBuilder::slotINDISetActionName()
02594 {
02595   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02596 
02597   if ( sf->name() == "setINDIAction" )
02598   {
02599     if (argSetActionINDI->actionName->text().isEmpty())
02600     {
02601       sf->setValid(false);
02602       return;
02603     }
02604     
02605     if (sf->argVal(1) != argSetActionINDI->actionName->text())
02606         setUnsavedChanges( true );
02607     
02608     sf->setArg(1, argSetActionINDI->actionName->text());
02609     if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
02610     else sf->setValid(false);
02611   }
02612   else
02613   {
02614     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIAction") << endl;
02615   }
02616 
02617 }
02618 
02619 void ScriptBuilder::slotINDIWaitForActionDeviceName()
02620 {
02621   
02622   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02623 
02624   if ( sf->name() == "waitForINDIAction" )
02625   {
02626     if (argWaitForActionINDI->deviceName->text().isEmpty())
02627     {
02628       return;
02629       sf->setValid(false);
02630     }
02631     
02632     if (sf->argVal(0) != argWaitForActionINDI->deviceName->text())
02633         setUnsavedChanges( true );
02634     
02635     sf->setArg(0, argWaitForActionINDI->deviceName->text());
02636     if ((! sf->argVal(1).isEmpty())) sf->setValid(true);
02637     else sf->setValid(false);
02638   }
02639   else
02640   {
02641     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitForINDIAction") << endl;
02642   }
02643   
02644 }
02645     
02646 void ScriptBuilder::slotINDIWaitForActionName()
02647 {
02648   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02649 
02650   if ( sf->name() == "waitForINDIAction" )
02651   {
02652     if (argWaitForActionINDI->actionName->text().isEmpty())
02653     {
02654       sf->setValid(false);
02655       return;
02656     }
02657     
02658     if (sf->argVal(1) != argWaitForActionINDI->actionName->text())
02659         setUnsavedChanges( true );
02660     
02661     sf->setArg(1, argWaitForActionINDI->actionName->text());
02662     if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
02663     else sf->setValid(false);
02664   }
02665   else
02666   {
02667     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitForINDIAction") << endl;
02668   }
02669   
02670 }
02671 
02672 void ScriptBuilder::slotINDISetFocusSpeedDeviceName()
02673 {
02674   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02675 
02676   if ( sf->name() == "setINDIFocusSpeed" )
02677   {
02678     if (argSetFocusSpeedINDI->deviceName->text().isEmpty())
02679     {
02680       sf->setValid(false);
02681       return;
02682     }
02683     
02684     if (sf->argVal(0) != argSetFocusSpeedINDI->deviceName->text())
02685         setUnsavedChanges( true );
02686     
02687     sf->setArg(0, argSetFocusSpeedINDI->deviceName->text());
02688     sf->setArg(1, QString("%1").arg(argSetFocusSpeedINDI->speedIN->value()));
02689     sf->setValid(true);
02690   }
02691   else
02692   {
02693     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusSpeed") << endl;
02694   }
02695   
02696 }
02697 
02698 void ScriptBuilder::slotINDISetFocusSpeed()
02699 {
02700   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02701 
02702   if ( sf->name() == "setINDIFocusSpeed" )
02703   {
02704     
02705     if (sf->argVal(1).toInt() != argSetFocusSpeedINDI->speedIN->value())
02706         setUnsavedChanges( true );
02707     
02708     sf->setArg(1, QString("%1").arg(argSetFocusSpeedINDI->speedIN->value()));
02709     if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
02710     else sf->setValid(false);
02711   }
02712   else
02713   {
02714     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusSpeed") << endl;
02715   }
02716   
02717 }
02718 
02719 void ScriptBuilder::slotINDIStartFocusDeviceName()
02720 {
02721   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02722 
02723   if ( sf->name() == "startINDIFocus" )
02724   {
02725     if (argStartFocusINDI->deviceName->text().isEmpty())
02726     {
02727       sf->setValid(false);
02728       return;
02729     }
02730     
02731     if (sf->argVal(0) != argStartFocusINDI->deviceName->text())
02732         setUnsavedChanges( true );
02733     
02734     sf->setArg(0, argStartFocusINDI->deviceName->text());
02735     sf->setArg(1, argStartFocusINDI->directionCombo->currentText());
02736     sf->setValid(true);
02737   }
02738   else
02739   {
02740     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "StartINDIFocus") << endl;
02741   }
02742   
02743 }
02744 
02745 
02746 void ScriptBuilder::slotINDIStartFocusDirection()
02747 {
02748   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02749 
02750   if ( sf->name() == "startINDIFocus" )
02751   {
02752     if (sf->argVal(1) != argStartFocusINDI->directionCombo->currentText())
02753         setUnsavedChanges( true );
02754     
02755     sf->setArg(1, argStartFocusINDI->directionCombo->currentText());
02756     if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
02757     else sf->setValid(false);
02758   }
02759   else
02760   {
02761     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDIFocus") << endl;
02762   }
02763   
02764 }
02765 
02766 void ScriptBuilder::slotINDISetFocusTimeoutDeviceName()
02767 {
02768   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02769 
02770   if ( sf->name() == "setINDIFocusTimeout" )
02771   {
02772     if (argSetFocusTimeoutINDI->deviceName->text().isEmpty())
02773     {
02774       sf->setValid(false);
02775       return;
02776     }
02777     
02778     if (sf->argVal(0) != argSetFocusTimeoutINDI->deviceName->text())
02779         setUnsavedChanges( true );
02780     
02781     sf->setArg(0, argSetFocusTimeoutINDI->deviceName->text());
02782     sf->setArg(1, QString("%1").arg(argSetFocusTimeoutINDI->timeOut->value()));
02783     sf->setValid(true);
02784   }
02785   else
02786   {
02787     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusTimeout") << endl;
02788   }
02789   
02790 }
02791 
02792 void ScriptBuilder::slotINDISetFocusTimeout()
02793 {
02794   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02795 
02796   if ( sf->name() == "setINDIFocusTimeout" )
02797   {
02798     if (sf->argVal(1).toInt() != argSetFocusTimeoutINDI->timeOut->value())
02799         setUnsavedChanges( true );
02800     
02801     sf->setArg(1, QString("%1").arg(argSetFocusTimeoutINDI->timeOut->value()));
02802     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
02803     else sf->setValid(false);
02804   }
02805   else
02806   {
02807     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusTimeout") << endl;
02808   }
02809   
02810 }
02811 
02812 void ScriptBuilder::slotINDISetGeoLocationDeviceName()
02813 {
02814   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02815 
02816   if ( sf->name() == "setINDIGeoLocation" )
02817   {
02818     if (argSetGeoLocationINDI->deviceName->text().isEmpty())
02819     {
02820       sf->setValid(false);
02821       return;
02822     }
02823     
02824     if (sf->argVal(0) != argSetGeoLocationINDI->deviceName->text())
02825         setUnsavedChanges( true );
02826     
02827     sf->setArg(0, argSetGeoLocationINDI->deviceName->text());
02828     if ((! sf->argVal(1).isEmpty()) && (! sf->argVal(2).isEmpty())) sf->setValid(true);
02829     else sf->setValid(false);
02830   }
02831   else
02832   {
02833     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIGeoLocation" ) << endl;
02834   }
02835   
02836 }
02837 
02838 void ScriptBuilder::slotINDISetGeoLocationDeviceLong()
02839 {
02840   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02841 
02842   if ( sf->name() == "setINDIGeoLocation" ) {
02843         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
02844     if ( argSetGeoLocationINDI->longBox->text().isEmpty())
02845     {
02846       sf->setValid(false);
02847       return;
02848     }
02849 
02850     bool ok(false);
02851     dms longitude = argSetGeoLocationINDI->longBox->createDms(true, &ok);
02852     if ( ok ) {
02853       
02854       if (sf->argVal(1) != QString( "%1" ).arg( longitude.Degrees()))
02855         setUnsavedChanges( true );
02856 
02857       sf->setArg( 1, QString( "%1" ).arg( longitude.Degrees() ) );
02858       if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(2).isEmpty() )) sf->setValid( true );
02859       else sf->setValid(false);
02860 
02861     } else {
02862       sf->setArg( 1, "" );
02863       sf->setValid( false );
02864     }
02865   } else {
02866     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIGeoLocation" ) << endl;
02867   }
02868   
02869 }
02870 
02871 void ScriptBuilder::slotINDISetGeoLocationDeviceLat()
02872 {
02873   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02874 
02875   if ( sf->name() == "setINDIGeoLocation" ) {
02876         //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
02877     if ( argSetGeoLocationINDI->latBox->text().isEmpty() )
02878     {
02879       sf->setValid(false);
02880       return;
02881     }
02882 
02883     bool ok(false);
02884     dms latitude = argSetGeoLocationINDI->latBox->createDms(true, &ok);
02885     if ( ok ) {
02886       
02887       if (sf->argVal(2) != QString( "%1" ).arg( latitude.Degrees()))
02888         setUnsavedChanges( true );
02889 
02890       sf->setArg( 2, QString( "%1" ).arg( latitude.Degrees() ) );
02891       if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(1).isEmpty() )) sf->setValid( true );
02892       else sf->setValid(false);
02893       
02894     } else {
02895       sf->setArg( 2, "" );
02896       sf->setValid( false );
02897     }
02898   } else {
02899     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIGeoLocation" ) << endl;
02900   }
02901   
02902 }
02903 
02904 void ScriptBuilder::slotINDIStartExposureDeviceName()
02905 {
02906   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02907 
02908   if ( sf->name() == "startINDIExposure" )
02909   {
02910     if (argStartExposureINDI->deviceName->text().isEmpty())
02911     {
02912       sf->setValid(false);
02913       return;
02914     }
02915     
02916     if (sf->argVal(0) != argStartExposureINDI->deviceName->text())
02917         setUnsavedChanges( true );
02918     
02919     sf->setArg(0, argStartExposureINDI->deviceName->text());
02920     sf->setArg(1, QString("%1").arg(argStartExposureINDI->timeOut->value()));
02921     sf->setValid(true);
02922   }
02923   else
02924   {
02925     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDIExposure") << endl;
02926   }
02927   
02928 }
02929 
02930 void ScriptBuilder::slotINDIStartExposureTimeout()
02931 {
02932   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02933 
02934   if ( sf->name() == "startINDIExposure" )
02935   {
02936     
02937     if (sf->argVal(1).toInt() != argStartExposureINDI->timeOut->value())
02938         setUnsavedChanges( true );
02939     
02940     sf->setArg(1, QString("%1").arg(argStartExposureINDI->timeOut->value()));
02941     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
02942     else sf->setValid(false);
02943   }
02944   else
02945   {
02946     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDIExposure") << endl;
02947   }
02948   
02949 }
02950 
02951 void ScriptBuilder::slotINDISetUTCDeviceName()
02952 {
02953   
02954   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02955 
02956   if ( sf->name() == "setINDIUTC" )
02957   {
02958     if (argSetUTCINDI->deviceName->text().isEmpty())
02959     {
02960       sf->setValid(false);
02961       return;
02962     }
02963     
02964     if (sf->argVal(0) != argSetUTCINDI->deviceName->text())
02965         setUnsavedChanges( true );
02966     
02967     sf->setArg(0, argSetUTCINDI->deviceName->text());
02968     if (! sf->argVal(1).isEmpty()) sf->setValid(true);
02969     else sf->setValid(false);
02970   }
02971   else
02972   {
02973     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIUTC" ) << endl;
02974   }
02975   
02976   
02977 }
02978 
02979 void ScriptBuilder::slotINDISetUTC()
02980 {
02981   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
02982 
02983   if ( sf->name() == "setINDIUTC" )
02984   {
02985     
02986     if (argSetUTCINDI->UTC->text().isEmpty())
02987     {
02988       sf->setValid(false);
02989       return;
02990     }
02991     
02992     if (sf->argVal(1) != argSetUTCINDI->UTC->text())
02993     setUnsavedChanges( true );
02994     
02995     sf->setArg(1, argSetUTCINDI->UTC->text());
02996     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
02997     else sf->setValid(false);
02998   }
02999   else
03000   {
03001     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIUTC" ) << endl;
03002   }
03003   
03004 }
03005 
03006 void ScriptBuilder::slotINDISetScopeActionDeviceName()
03007 {
03008   
03009   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03010 
03011   if ( sf->name() == "setINDIScopeAction" )
03012   {
03013     if (argSetScopeActionINDI->deviceName->text().isEmpty())
03014     {
03015       sf->setValid(false);
03016       return;
03017     }
03018     
03019     if (sf->argVal(0) != argSetScopeActionINDI->deviceName->text())
03020         setUnsavedChanges( true );
03021     
03022     sf->setArg(0, argSetScopeActionINDI->deviceName->text());
03023     sf->setArg(1, argSetScopeActionINDI->actionCombo->currentText());
03024     sf->setINDIProperty("CHECK");
03025     sf->setValid(true);
03026   }
03027   else
03028   {
03029     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIScopeAction" ) << endl;
03030   }
03031   
03032 }
03033 
03034 void ScriptBuilder::slotINDISetScopeAction()
03035 {
03036   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03037 
03038   if ( sf->name() == "setINDIScopeAction" )
03039   {
03040     
03041     if (sf->argVal(1) != argSetScopeActionINDI->actionCombo->currentText())
03042         setUnsavedChanges( true );
03043     
03044     sf->setArg(1, argSetScopeActionINDI->actionCombo->currentText());
03045     sf->setINDIProperty("CHECK");
03046     if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
03047     else sf->setValid(false);
03048   }
03049   else
03050   {
03051     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIScopeAction") << endl;
03052   }
03053   
03054 }
03055 
03056 void ScriptBuilder::slotINDISetFrameTypeDeviceName()
03057 {
03058   
03059   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03060 
03061   if ( sf->name() == "setINDIFrameType" )
03062   {
03063     if (argSetFrameTypeINDI->deviceName->text().isEmpty())
03064     {
03065       sf->setValid(false);
03066       return;
03067     }
03068     
03069     if (sf->argVal(0) != argSetFrameTypeINDI->deviceName->text())
03070         setUnsavedChanges( true );
03071     
03072     sf->setArg(0, argSetFrameTypeINDI->deviceName->text());
03073     sf->setArg(1, argSetFrameTypeINDI->typeCombo->currentText());
03074     sf->setValid(true);
03075   }
03076   else
03077   {
03078     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFrameType" ) << endl;
03079   }
03080   
03081 }
03082 
03083 void ScriptBuilder::slotINDISetFrameType()
03084 {
03085   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03086 
03087   if ( sf->name() == "setINDIFrameType" )
03088   {
03089     
03090     if (sf->argVal(1) != argSetFrameTypeINDI->typeCombo->currentText())
03091         setUnsavedChanges( true );
03092     
03093     sf->setArg(1, argSetFrameTypeINDI->typeCombo->currentText());
03094     if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
03095     else sf->setValid(false);
03096   }
03097   else
03098   {
03099     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFrameType") << endl;
03100   }
03101   
03102 }
03103 
03104 void ScriptBuilder::slotINDISetCCDTempDeviceName()
03105 {
03106   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03107 
03108   if ( sf->name() == "setINDICCDTemp" )
03109   {
03110     if (argSetCCDTempINDI->deviceName->text().isEmpty())
03111     {
03112       sf->setValid(false);
03113       return;
03114     }
03115     
03116     if (sf->argVal(0) != argSetCCDTempINDI->deviceName->text())
03117         setUnsavedChanges( true );
03118     
03119     sf->setArg(0, argSetCCDTempINDI->deviceName->text());
03120     sf->setArg(1, QString("%1").arg(argSetCCDTempINDI->temp->value()));
03121     sf->setValid(true);
03122   }
03123   else
03124   {
03125     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDICCDTemp") << endl;
03126   }
03127   
03128 }
03129 
03130 void ScriptBuilder::slotINDISetCCDTemp()
03131 {
03132   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03133 
03134   if ( sf->name() == "setINDICCDTemp" )
03135   {
03136     
03137     if (sf->argVal(1).toInt() != argSetCCDTempINDI->temp->value())
03138         setUnsavedChanges( true );
03139     
03140     sf->setArg(1, QString("%1").arg(argSetCCDTempINDI->temp->value()));
03141     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
03142     else sf->setValid(false);
03143   }
03144   else
03145   {
03146     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDICCDTemp") << endl;
03147   }
03148   
03149 }
03150 
03151 void ScriptBuilder::slotINDISetFilterNumDeviceName()
03152 {
03153 
03154   ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03155 
03156   if ( sf->name() == "setINDIFilterNum" )
03157   {
03158     if (argSetFilterNumINDI->deviceName->text().isEmpty())
03159     {
03160       sf->setValid(false);
03161       return;
03162     }
03163     
03164     if (sf->argVal(0) != argSetFilterNumINDI->deviceName->text())
03165         setUnsavedChanges( true );
03166     
03167     sf->setArg(0, argSetFilterNumINDI->deviceName->text());
03168     sf->setArg(1, QString("%1").arg(argSetFilterNumINDI->filter_num->value()));
03169     sf->setValid(true);
03170   }
03171   else
03172   {
03173     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFilterNum") << endl;
03174   }
03175 }
03176 
03177 void ScriptBuilder::slotINDISetFilterNum()
03178 {
03179 
03180  ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
03181 
03182   if ( sf->name() == "setINDIFilterNum" )
03183   {
03184     
03185     if (sf->argVal(1).toInt() != argSetFilterNumINDI->filter_num->value())
03186         setUnsavedChanges( true );
03187     
03188     sf->setArg(1, QString("%1").arg(argSetFilterNumINDI->filter_num->value()));
03189     if (! sf->argVal(0).isEmpty()) sf->setValid(true);
03190     else sf->setValid(false);
03191   }
03192   else
03193   {
03194     kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFilterNum") << endl;
03195   }
03196 
03197 
03198 }
03199     
03200 #include "scriptbuilder.moc"

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal