moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / tools / scriptbuilder.cpp
blobcc0ade434eb8f723a9d600c17f7363dd088b7b2a
1 /***************************************************************************
2 scriptbuilder.cpp - description
3 -------------------
4 begin : Thu Apr 17 2003
5 copyright : (C) 2003 by Jason Harris
6 email : kstars@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 //needed in slotSave() for chmod() syscall
19 #include <sys/stat.h>
21 #include <kdebug.h>
22 #include <kpushbutton.h>
23 #include <kcolorbutton.h>
24 #include <klocale.h>
25 #include <kcombobox.h>
26 #include <kicontheme.h>
27 #include <kiconloader.h>
28 #include <kio/netaccess.h>
29 #include <klistbox.h>
30 #include <klistview.h>
31 #include <kprocess.h>
32 #include <ktextedit.h>
33 #include <ktempfile.h>
34 #include <kdatewidget.h>
35 #include <kmessagebox.h>
36 #include <kfiledialog.h>
37 #include <kstdguiitem.h>
38 #include <kstandarddirs.h>
39 #include <kurl.h>
40 #include <kurlrequester.h>
41 #include <knuminput.h>
43 #include <qcheckbox.h>
44 #include <qspinbox.h>
45 #include <qwidgetstack.h>
46 #include <qwidget.h>
47 #include <qptrlist.h>
48 #include <qlayout.h>
49 #include <qdatetimeedit.h>
50 #include <qradiobutton.h>
51 #include <qbuttongroup.h>
53 #include "scriptfunction.h"
54 #include "scriptbuilderui.h"
55 #include "scriptnamedialog.h"
56 #include "optionstreeview.h"
58 #include "arglooktoward.h"
59 #include "argsetradec.h"
60 #include "argsetaltaz.h"
61 #include "argsetlocaltime.h"
62 #include "argwaitfor.h"
63 #include "argwaitforkey.h"
64 #include "argsettrack.h"
65 #include "argchangeviewoption.h"
66 #include "argsetgeolocation.h"
67 #include "argtimescale.h"
68 #include "argzoom.h"
69 #include "argexportimage.h"
70 #include "argprintimage.h"
71 #include "argsetcolor.h"
72 #include "argloadcolorscheme.h"
73 #include "argstartindi.h"
74 #include "argshutdownindi.h"
75 #include "argswitchindi.h"
76 #include "argsetportindi.h"
77 #include "argsettargetcoordindi.h"
78 #include "argsettargetnameindi.h"
79 #include "argsetactionindi.h"
80 #include "argsetfocusspeedindi.h"
81 #include "argstartfocusindi.h"
82 #include "argsetfocustimeoutindi.h"
83 #include "argsetgeolocationindi.h"
84 #include "argstartexposureindi.h"
85 #include "argsetutcindi.h"
86 #include "argsetscopeactionindi.h"
87 #include "argsetframetypeindi.h"
88 #include "argsetccdtempindi.h"
89 #include "argsetfilternumindi.h"
91 #include "scriptbuilder.h"
92 #include "kstars.h"
93 #include "kstarsdata.h"
94 #include "skymap.h"
95 #include "kstarsdatetime.h"
96 #include "dmsbox.h"
97 #include "finddialog.h"
98 #include "locationdialog.h"
99 #include "skyobjectname.h"
100 #include "timestepbox.h"
101 #include "libkdeedu/extdate/extdatewidget.h"
103 ScriptBuilder::ScriptBuilder( QWidget *parent, const char *name )
104 : KDialogBase( KDialogBase::Plain, i18n( "Script Builder" ), Close, Close, parent, name ),
105 UnsavedChanges(false), currentFileURL(), currentDir( QDir::homeDirPath() ),
106 currentScriptName(), currentAuthor() {
108 QFrame *page = plainPage();
110 ks = (KStars*)parent;
111 QVBoxLayout *vlay = new QVBoxLayout( page, 0, 0 );
112 sb = new ScriptBuilderUI( page );
113 vlay->addWidget( sb );
115 KStarsFunctionList.setAutoDelete( TRUE );
116 INDIFunctionList.setAutoDelete( TRUE);
117 ScriptList.setAutoDelete( TRUE );
119 //Initialize function templates and descriptions
120 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'." ),
121 false, "QString", "dir" ) );
122 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." ),
123 false, "double", "ra", "double", "dec" ) );
124 KStarsFunctionList.append( new ScriptFunction( "setAltAz", i18n( "Point the display at the specified Alt/Az coordinates. %1 and %2 are expressed in Degrees." ),
125 false, "double", "alt", "double", "az" ) );
126 KStarsFunctionList.append( new ScriptFunction( "zoomIn", i18n( "Increase the display Zoom Level." ), false ) );
127 KStarsFunctionList.append( new ScriptFunction( "zoomOut", i18n( "Decrease the display Zoom Level." ), false ) );
128 KStarsFunctionList.append( new ScriptFunction( "defaultZoom", i18n( "Set the display Zoom Level to its default value." ), false ) );
129 KStarsFunctionList.append( new ScriptFunction( "zoom", i18n( "Set the display Zoom Level manually." ), false, "double", "z" ) );
130 KStarsFunctionList.append( new ScriptFunction( "setLocalTime", i18n( "Set the system clock to the specified Local Time." ),
131 false, "int", "year", "int", "month", "int", "day", "int", "hour", "int", "minute", "int", "second" ) );
132 KStarsFunctionList.append( new ScriptFunction( "waitFor", i18n( "Pause script execution for %1 seconds." ), false, "double", "sec" ) );
133 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." ),
134 false, "QString", "key" ) );
135 KStarsFunctionList.append( new ScriptFunction( "setTracking", i18n( "Set whether the display is tracking the current location." ), false, "bool", "track" ) );
136 KStarsFunctionList.append( new ScriptFunction( "changeViewOption", i18n( "Change view option named %1 to value %2." ), false, "QString", "opName", "QString", "opValue" ) );
137 KStarsFunctionList.append( new ScriptFunction( "setGeoLocation", i18n( "Set the geographic location to the city specified by %1, %2 and %3." ),
138 false, "QString", "cityName", "QString", "provinceName", "QString", "countryName" ) );
139 KStarsFunctionList.append( new ScriptFunction( "setColor", i18n( "Set the color named %1 to the value %2." ), false, "QString", "colorName", "QString", "value" ) );
140 KStarsFunctionList.append( new ScriptFunction( "loadColorScheme", i18n( "Load the color scheme named %1." ), false, "QString", "name" ) );
141 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" ) );
142 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" ) );
143 KStarsFunctionList.append( new ScriptFunction( "stop", i18n( "Halt the simulation clock." ), true ) );
144 KStarsFunctionList.append( new ScriptFunction( "start", i18n( "Start the simulation clock." ), true ) );
145 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" ) );
147 // INDI fuctions
148 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);
150 startINDIFunc = new ScriptFunction( "startINDI", i18n("Establish an INDI device either in local mode or server mode."), false, "QString", "deviceName", "bool", "useLocal");
151 INDIFunctionList.append ( startINDIFunc );
153 shutdownINDIFunc = new ScriptFunction( "shutdownINDI", i18n("Shutdown an INDI device."), false, "QString", "deviceName");
154 INDIFunctionList.append ( shutdownINDIFunc);
156 switchINDIFunc = new ScriptFunction( "switchINDI", i18n("Connect or Disconnect an INDI device."), false, "QString", "deviceName", "bool", "turnOn");
157 switchINDIFunc->setINDIProperty("CONNECTION");
158 INDIFunctionList.append ( switchINDIFunc);
160 setINDIPortFunc = new ScriptFunction( "setINDIPort", i18n("Set INDI's device connection port."), false, "QString", "deviceName", "QString", "port");
161 setINDIPortFunc->setINDIProperty("DEVICE_PORT");
162 INDIFunctionList.append ( setINDIPortFunc);
164 setINDIScopeActionFunc = new ScriptFunction( "setINDIScopeAction", i18n("Set the telescope action. Available actions are SLEW, TRACK, SYNC, PARK, and ABORT."), false, "QString", "deviceName", "QString", "action");
165 setINDIScopeActionFunc->setINDIProperty("CHECK");
166 INDIFunctionList.append( setINDIScopeActionFunc);
168 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" );
169 setINDITargetCoordFunc->setINDIProperty("EQUATORIAL_EOD_COORD");
170 INDIFunctionList.append ( setINDITargetCoordFunc );
172 setINDITargetNameFunc = new ScriptFunction( "setINDITargetName", i18n("Set the telescope target coorinates to the RA/Dec coordinates of the selected object."), false, "QString", "deviceName", "QString", "objectName");
173 setINDITargetNameFunc->setINDIProperty("EQUATORIAL_EOD_COORD");
174 INDIFunctionList.append( setINDITargetNameFunc);
176 setINDIGeoLocationFunc = new ScriptFunction ( "setINDIGeoLocation", i18n("Set the telescope longitude and latitude. The longitude is E of N."), false, "QString", "deviceName", "double", "long", "double", "lat");
177 setINDIGeoLocationFunc->setINDIProperty("GEOGRAPHIC_COORD");
178 INDIFunctionList.append( setINDIGeoLocationFunc);
180 setINDIUTCFunc = new ScriptFunction ( "setINDIUTC", i18n("Set the device UTC time in ISO 8601 format YYYY/MM/DDTHH:MM:SS."), false, "QString", "deviceName", "QString", "UTCDateTime");
181 setINDIUTCFunc->setINDIProperty("TIME");
182 INDIFunctionList.append( setINDIUTCFunc);
184 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");
185 INDIFunctionList.append( setINDIActionFunc);
187 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");
188 INDIFunctionList.append( waitForINDIActionFunc );
190 setINDIFocusSpeedFunc = new ScriptFunction ("setINDIFocusSpeed", i18n("Set the telescope focuser speed."), false, "QString", "deviceName", "QString", "speed");
191 setINDIFocusSpeedFunc->setINDIProperty("FOCUS_SPEED");
192 INDIFunctionList.append( setINDIFocusSpeedFunc );
194 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");
195 startINDIFocusFunc->setINDIProperty("FOCUS_MOTION");
196 INDIFunctionList.append( startINDIFocusFunc);
198 setINDIFocusTimeoutFunc = new ScriptFunction ( "setINDIFocusTimeout", i18n("Set the telescope focuser timeout in seconds. This is the duration of any focusing procedure performed by calling startINDIFocus."), false, "QString", "deviceName", "int", "timeout");
199 setINDIFocusTimeoutFunc->setINDIProperty("FOCUS_TIMEOUT");
200 INDIFunctionList.append( setINDIFocusTimeoutFunc);
202 setINDICCDTempFunc = new ScriptFunction( "setINDICCDTemp", i18n("Set the target CCD chip temperature."), false, "QString", "deviceName", "int", "temp");
203 setINDICCDTempFunc->setINDIProperty("CCD_TEMPERATURE");
204 INDIFunctionList.append( setINDICCDTempFunc);
206 setINDIFilterNumFunc = new ScriptFunction( "setINDIFilterNum", i18n("Set the target filter position."), false, "QString", "deviceName", "int", "filter_num");
207 setINDIFilterNumFunc->setINDIProperty("FILTER_CONF");
208 INDIFunctionList.append ( setINDIFilterNumFunc);
210 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");
211 setINDIFrameTypeFunc->setINDIProperty("FRAME_TYPE");
212 INDIFunctionList.append( setINDIFrameTypeFunc);
214 startINDIExposureFunc = new ScriptFunction ( "startINDIExposure", i18n("Start Camera/CCD exposure. The duration is in seconds."), false, "QString", "deviceName", "int", "timeout");
215 startINDIExposureFunc->setINDIProperty("EXPOSE_DURATION");
216 INDIFunctionList.append( startINDIExposureFunc);
219 // Modified by JM
220 // We're using KListView instead of listbox to arrange the functions in two
221 // main categories: KStars and INDI. INDI is further subdivided.
223 sb->FunctionListView->addColumn(i18n("Functions"));
224 sb->FunctionListView->setSorting(-1);
226 QListViewItem *INDI_tree = new QListViewItem( sb->FunctionListView, "INDI");
227 QListViewItem *INDI_filter = new QListViewItem( INDI_tree, "Filter");
228 QListViewItem *INDI_focuser = new QListViewItem( INDI_tree, "Focuser");
229 QListViewItem *INDI_ccd = new QListViewItem( INDI_tree, "Camera/CCD");
230 QListViewItem *INDI_telescope = new QListViewItem( INDI_tree, "Telescope");
231 QListViewItem *INDI_general = new QListViewItem( INDI_tree, "General");
233 QListViewItem *kstars_tree = new QListViewItem( sb->FunctionListView, "KStars");
236 for ( ScriptFunction *sf = KStarsFunctionList.last(); sf; sf = KStarsFunctionList.prev() )
237 new QListViewItem (kstars_tree, sf->prototype());
239 // General
240 new QListViewItem(INDI_general, waitForINDIActionFunc->prototype());
241 new QListViewItem(INDI_general, setINDIActionFunc->prototype());
242 new QListViewItem(INDI_general, setINDIPortFunc->prototype());
243 new QListViewItem(INDI_general, switchINDIFunc->prototype());
244 new QListViewItem(INDI_general, shutdownINDIFunc->prototype());
245 new QListViewItem(INDI_general, startINDIFunc->prototype());
247 // Telescope
248 new QListViewItem(INDI_telescope, setINDIUTCFunc->prototype());
249 new QListViewItem(INDI_telescope, setINDIGeoLocationFunc->prototype());
250 new QListViewItem(INDI_telescope, setINDITargetNameFunc->prototype());
251 new QListViewItem(INDI_telescope, setINDITargetCoordFunc->prototype());
252 new QListViewItem(INDI_telescope, setINDIScopeActionFunc->prototype());
254 // CCD
255 new QListViewItem(INDI_ccd, startINDIExposureFunc->prototype());
256 new QListViewItem(INDI_ccd, setINDIFrameTypeFunc->prototype());
257 new QListViewItem(INDI_ccd, setINDICCDTempFunc->prototype());
259 // Focuser
260 new QListViewItem(INDI_focuser, startINDIFocusFunc->prototype());
261 new QListViewItem(INDI_focuser, setINDIFocusTimeoutFunc->prototype());
262 new QListViewItem(INDI_focuser, setINDIFocusSpeedFunc->prototype());
264 // Filter
265 new QListViewItem(INDI_filter, setINDIFilterNumFunc->prototype());
267 //Add icons to Push Buttons
268 KIconLoader *icons = KGlobal::iconLoader();
269 sb->NewButton->setIconSet( icons->loadIcon( "filenew", KIcon::Toolbar ) );
270 sb->OpenButton->setIconSet( icons->loadIcon( "fileopen", KIcon::Toolbar ) );
271 sb->SaveButton->setIconSet( icons->loadIconSet( "filesave", KIcon::Toolbar ) );
272 sb->SaveAsButton->setIconSet( icons->loadIconSet( "filesaveas", KIcon::Toolbar ) );
273 sb->RunButton->setIconSet( icons->loadIconSet( "launch", KIcon::Toolbar ) );
274 sb->CopyButton->setIconSet( icons->loadIconSet( "reload", KIcon::Toolbar ) );
275 sb->AddButton->setIconSet( icons->loadIconSet( "back", KIcon::Toolbar ) );
276 sb->RemoveButton->setIconSet( icons->loadIconSet( "forward", KIcon::Toolbar ) );
277 sb->UpButton->setIconSet( icons->loadIconSet( "up", KIcon::Toolbar ) );
278 sb->DownButton->setIconSet( icons->loadIconSet( "down", KIcon::Toolbar ) );
280 //Prepare the widget stack
281 argBlank = new QWidget( sb->ArgStack );
282 argLookToward = new ArgLookToward( sb->ArgStack );
283 argSetRaDec = new ArgSetRaDec( sb->ArgStack );
284 argSetAltAz = new ArgSetAltAz( sb->ArgStack );
285 argSetLocalTime = new ArgSetLocalTime( sb->ArgStack );
286 argWaitFor = new ArgWaitFor( sb->ArgStack );
287 argWaitForKey = new ArgWaitForKey( sb->ArgStack );
288 argSetTracking = new ArgSetTrack( sb->ArgStack );
289 argChangeViewOption = new ArgChangeViewOption( sb->ArgStack );
290 argSetGeoLocation = new ArgSetGeoLocation( sb->ArgStack );
291 argTimeScale = new ArgTimeScale( sb->ArgStack );
292 argZoom = new ArgZoom( sb->ArgStack );
293 argExportImage = new ArgExportImage( sb->ArgStack );
294 argPrintImage = new ArgPrintImage( sb->ArgStack );
295 argSetColor = new ArgSetColor( sb->ArgStack );
296 argLoadColorScheme = new ArgLoadColorScheme( sb->ArgStack );
297 argStartINDI = new ArgStartINDI (sb->ArgStack);
298 argShutdownINDI = new ArgShutdownINDI (sb->ArgStack);
299 argSwitchINDI = new ArgSwitchINDI (sb->ArgStack);
300 argSetPortINDI = new ArgSetPortINDI (sb->ArgStack);
301 argSetTargetCoordINDI = new ArgSetTargetCoordINDI (sb->ArgStack);
302 argSetTargetNameINDI = new ArgSetTargetNameINDI (sb->ArgStack);
303 argSetActionINDI = new ArgSetActionINDI (sb->ArgStack);
304 argWaitForActionINDI = new ArgSetActionINDI (sb->ArgStack);
305 argSetFocusSpeedINDI = new ArgSetFocusSpeedINDI (sb->ArgStack);
306 argStartFocusINDI = new ArgStartFocusINDI(sb->ArgStack);
307 argSetFocusTimeoutINDI = new ArgSetFocusTimeoutINDI( sb->ArgStack);
308 argSetGeoLocationINDI = new ArgSetGeoLocationINDI( sb->ArgStack);
309 argStartExposureINDI = new ArgStartExposureINDI( sb->ArgStack);
310 argSetUTCINDI = new ArgSetUTCINDI( sb->ArgStack);
311 argSetScopeActionINDI = new ArgSetScopeActionINDI( sb->ArgStack);
312 argSetFrameTypeINDI = new ArgSetFrameTypeINDI (sb->ArgStack);
313 argSetCCDTempINDI = new ArgSetCCDTempINDI(sb->ArgStack);
314 argSetFilterNumINDI = new ArgSetFilterNumINDI(sb->ArgStack);
316 argSetFocusSpeedINDI->speedCombo->insertItem("FOCUS_HALT");
317 argSetFocusSpeedINDI->speedCombo->insertItem("FOCUS_FAST");
318 argSetFocusSpeedINDI->speedCombo->insertItem("FOCUS_MEDIUM");
319 argSetFocusSpeedINDI->speedCombo->insertItem("FOCUS_SLOW");
321 argStartFocusINDI->directionCombo->insertItem("FOCUS_IN");
322 argStartFocusINDI->directionCombo->insertItem("FOCUS_OUT");
324 argSetScopeActionINDI->actionCombo->insertItem("SLEW");
325 argSetScopeActionINDI->actionCombo->insertItem("TRACK");
326 argSetScopeActionINDI->actionCombo->insertItem("SYNC");
327 argSetScopeActionINDI->actionCombo->insertItem("PARK");
328 argSetScopeActionINDI->actionCombo->insertItem("ABORT");
330 argSetFrameTypeINDI->typeCombo->insertItem("FRAME_LIGHT");
331 argSetFrameTypeINDI->typeCombo->insertItem("FRAME_BIAS");
332 argSetFrameTypeINDI->typeCombo->insertItem("FRAME_DARK");
333 argSetFrameTypeINDI->typeCombo->insertItem("FRAME_FLAT");
335 sb->ArgStack->addWidget( argBlank );
336 sb->ArgStack->addWidget( argLookToward );
337 sb->ArgStack->addWidget( argSetRaDec );
338 sb->ArgStack->addWidget( argSetAltAz );
339 sb->ArgStack->addWidget( argSetLocalTime );
340 sb->ArgStack->addWidget( argWaitFor );
341 sb->ArgStack->addWidget( argWaitForKey );
342 sb->ArgStack->addWidget( argSetTracking );
343 sb->ArgStack->addWidget( argChangeViewOption );
344 sb->ArgStack->addWidget( argSetGeoLocation );
345 sb->ArgStack->addWidget( argTimeScale );
346 sb->ArgStack->addWidget( argZoom );
347 sb->ArgStack->addWidget( argExportImage );
348 sb->ArgStack->addWidget( argPrintImage );
349 sb->ArgStack->addWidget( argSetColor );
350 sb->ArgStack->addWidget( argLoadColorScheme );
352 sb->ArgStack->addWidget( argStartINDI);
353 sb->ArgStack->addWidget( argShutdownINDI);
354 sb->ArgStack->addWidget( argSwitchINDI);
355 sb->ArgStack->addWidget( argSetPortINDI);
356 sb->ArgStack->addWidget( argSetTargetCoordINDI);
357 sb->ArgStack->addWidget( argSetTargetNameINDI);
358 sb->ArgStack->addWidget( argSetActionINDI);
359 sb->ArgStack->addWidget( argWaitForActionINDI );
360 sb->ArgStack->addWidget( argSetFocusSpeedINDI );
361 sb->ArgStack->addWidget( argStartFocusINDI);
362 sb->ArgStack->addWidget( argSetFocusTimeoutINDI);
363 sb->ArgStack->addWidget( argSetGeoLocationINDI);
364 sb->ArgStack->addWidget( argStartExposureINDI);
365 sb->ArgStack->addWidget( argSetUTCINDI);
366 sb->ArgStack->addWidget( argSetScopeActionINDI);
367 sb->ArgStack->addWidget( argSetFrameTypeINDI);
368 sb->ArgStack->addWidget( argSetCCDTempINDI);
369 sb->ArgStack->addWidget( argSetFilterNumINDI);
371 sb->ArgStack->raiseWidget( 0 );
373 snd = new ScriptNameDialog( ks );
374 otv = new OptionsTreeView( ks );
376 initViewOptions();
378 //connect widgets in ScriptBuilderUI
379 connect( sb->FunctionListView, SIGNAL( doubleClicked(QListViewItem *, const QPoint &, int )), this, SLOT( slotAddFunction() ) );
380 connect( sb->FunctionListView, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( slotShowDoc() ) );
381 connect( sb->UpButton, SIGNAL( clicked() ), this, SLOT( slotMoveFunctionUp() ) );
382 connect( sb->ScriptListBox, SIGNAL( currentChanged(QListBoxItem*) ), this, SLOT( slotArgWidget() ) );
383 connect( sb->DownButton, SIGNAL( clicked() ), this, SLOT( slotMoveFunctionDown() ) );
384 connect( sb->CopyButton, SIGNAL( clicked() ), this, SLOT( slotCopyFunction() ) );
385 connect( sb->RemoveButton, SIGNAL( clicked() ), this, SLOT( slotRemoveFunction() ) );
386 connect( sb->NewButton, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
387 connect( sb->OpenButton, SIGNAL( clicked() ), this, SLOT( slotOpen() ) );
388 connect( sb->SaveButton, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
389 connect( sb->SaveAsButton, SIGNAL( clicked() ), this, SLOT( slotSaveAs() ) );
390 connect( sb->AddButton, SIGNAL( clicked() ), this, SLOT( slotAddFunction() ) );
391 connect( sb->RunButton, SIGNAL( clicked() ), this, SLOT( slotRunScript() ) );
393 //Connections for Arg Widgets
394 connect( argSetGeoLocation->FindCityButton, SIGNAL( clicked() ), this, SLOT( slotFindCity() ) );
395 connect( argLookToward->FindButton, SIGNAL( clicked() ), this, SLOT( slotFindObject() ) );
396 connect( argChangeViewOption->TreeButton, SIGNAL( clicked() ), this, SLOT( slotShowOptions() ) );
398 connect( argLookToward->FocusEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotLookToward() ) );
399 connect( argSetRaDec->RaBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotRa() ) );
400 connect( argSetRaDec->DecBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotDec() ) );
401 connect( argSetAltAz->AltBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotAlt() ) );
402 connect( argSetAltAz->AzBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotAz() ) );
403 connect( argSetLocalTime->DateBox, SIGNAL( changed(ExtDate) ), this, SLOT( slotChangeDate() ) );
404 connect( argSetLocalTime->TimeBox, SIGNAL( valueChanged(const QTime&) ), this, SLOT( slotChangeTime() ) );
405 connect( argWaitFor->DelayBox, SIGNAL( valueChanged(int) ), this, SLOT( slotWaitFor() ) );
406 connect( argWaitForKey->WaitKeyEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotWaitForKey() ) );
407 connect( argSetTracking->CheckTrack, SIGNAL( stateChanged(int) ), this, SLOT( slotTracking() ) );
408 connect( argChangeViewOption->OptionName, SIGNAL( activated(const QString &) ), this, SLOT( slotViewOption() ) );
409 connect( argChangeViewOption->OptionValue, SIGNAL( textChanged(const QString &) ), this, SLOT( slotViewOption() ) );
410 connect( argSetGeoLocation->CityName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeCity() ) );
411 connect( argSetGeoLocation->ProvinceName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeProvince() ) );
412 connect( argSetGeoLocation->CountryName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeCountry() ) );
413 connect( argTimeScale->TimeScale, SIGNAL( scaleChanged(float) ), this, SLOT( slotTimeScale() ) );
414 connect( argZoom->ZoomBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotZoom() ) );
415 connect( argExportImage->ExportFileName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotExportImage() ) );
416 connect( argExportImage->ExportWidth, SIGNAL( valueChanged(int) ), this, SLOT( slotExportImage() ) );
417 connect( argExportImage->ExportHeight, SIGNAL( valueChanged(int) ), this, SLOT( slotExportImage() ) );
418 connect( argPrintImage->UsePrintDialog, SIGNAL( toggled(bool) ), this, SLOT( slotPrintImage() ) );
419 connect( argPrintImage->UseChartColors, SIGNAL( toggled(bool) ), this, SLOT( slotPrintImage() ) );
420 connect( argSetColor->ColorName, SIGNAL( activated(const QString &) ), this, SLOT( slotChangeColorName() ) );
421 connect( argSetColor->ColorValue, SIGNAL( changed(const QColor &) ), this, SLOT( slotChangeColor() ) );
422 connect( argLoadColorScheme->SchemeList, SIGNAL( clicked( QListBoxItem* ) ), this, SLOT( slotLoadColorScheme( QListBoxItem* ) ) );
423 connect( snd->ScriptName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEnableScriptNameOK() ) );
425 connect( sb->AppendINDIWait, SIGNAL ( toggled(bool) ), this, SLOT(slotINDIWaitCheck(bool)));
427 // Connections for INDI's Arg widgets
429 // INDI Start Device
430 connect (argStartINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIStartDeviceName()));
431 connect (argStartINDI->INDIMode, SIGNAL ( clicked( int)), this, SLOT (slotINDIStartDeviceMode()));
433 // INDI Shutdown Device
434 connect (argShutdownINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIShutdown()));
436 // INDI Swtich Device
437 connect (argSwitchINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISwitchDeviceName()));
438 connect (argSwitchINDI->INDIConnection, SIGNAL ( clicked( int)), this, SLOT (slotINDISwitchDeviceConnection()));
440 // INDI Set Device Port
441 connect (argSetPortINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetPortDeviceName()));
442 connect (argSetPortINDI->devicePort, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetPortDevicePort()));
444 // INDI Set Target Coord
445 connect (argSetTargetCoordINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetTargetCoordDeviceName()));
446 connect( argSetTargetCoordINDI->RaBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetTargetCoordDeviceRA() ) );
447 connect( argSetTargetCoordINDI->DecBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetTargetCoordDeviceDEC() ) );
449 // INDI Set Target Name
450 connect( argSetTargetNameINDI->FindButton, SIGNAL( clicked() ), this, SLOT( slotINDIFindObject() ) );
451 connect (argSetTargetNameINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetTargetNameDeviceName()));
452 connect (argSetTargetNameINDI->objectName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetTargetNameObjectName()));
454 // INDI Set Action
455 connect (argSetActionINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetActionDeviceName()));
456 connect (argSetActionINDI->actionName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetActionName()));
458 // INDI Wait For Action
459 connect (argWaitForActionINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIWaitForActionDeviceName()));
460 connect (argWaitForActionINDI->actionName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIWaitForActionName()));
462 // INDI Set Focus Speed
463 connect (argSetFocusSpeedINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFocusSpeedDeviceName()));
464 connect (argSetFocusSpeedINDI->speedCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDISetFocusSpeed()));
466 // INDI Start Focus
467 connect (argStartFocusINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIStartFocusDeviceName()));
468 connect (argStartFocusINDI->directionCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDIStartFocusDirection()));
470 // INDI Set Focus Timeout
471 connect (argSetFocusTimeoutINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFocusTimeoutDeviceName()));
472 connect (argSetFocusTimeoutINDI->timeOut, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFocusTimeout()));
474 // INDI Set Geo Location
475 connect (argSetGeoLocationINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetGeoLocationDeviceName()));
476 connect( argSetGeoLocationINDI->longBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetGeoLocationDeviceLong() ) );
477 connect( argSetGeoLocationINDI->latBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetGeoLocationDeviceLat() ) );
479 // INDI Start Exposure
480 connect (argStartExposureINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIStartExposureDeviceName()));
481 connect (argStartExposureINDI->timeOut, SIGNAL( valueChanged(int) ), this, SLOT(slotINDIStartExposureTimeout()));
483 // INDI Set UTC
484 connect (argSetUTCINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetUTCDeviceName()));
485 connect (argSetUTCINDI->UTC, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetUTC()));
487 // INDI Set Scope Action
488 connect (argSetScopeActionINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetScopeActionDeviceName()));
489 connect (argSetScopeActionINDI->actionCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDISetScopeAction()));
491 // INDI Set Frame type
492 connect (argSetFrameTypeINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFrameTypeDeviceName()));
493 connect (argSetFrameTypeINDI->typeCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDISetFrameType()));
495 // INDI Set CCD Temp
496 connect (argSetCCDTempINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetCCDTempDeviceName()));
497 connect (argSetCCDTempINDI->temp, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetCCDTemp()));
499 // INDI Set Filter Num
500 connect (argSetFilterNumINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetFilterNumDeviceName()));
501 connect (argSetFilterNumINDI->filter_num, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFilterNum()));
504 //disbale some buttons
505 sb->CopyButton->setEnabled( false );
506 sb->AddButton->setEnabled( false );
507 sb->RemoveButton->setEnabled( false );
508 sb->UpButton->setEnabled( false );
509 sb->DownButton->setEnabled( false );
510 sb->SaveButton->setEnabled( false );
511 sb->SaveAsButton->setEnabled( false );
512 sb->RunButton->setEnabled( false );
515 ScriptBuilder::~ScriptBuilder()
519 void ScriptBuilder::initViewOptions() {
520 otv->OptionsList->setRootIsDecorated( true );
522 //InfoBoxes
523 opsGUI = new QListViewItem( otv->OptionsList, i18n( "InfoBoxes" ) );
524 new QListViewItem( opsGUI, "ShowInfoBoxes", i18n( "Toggle display of all InfoBoxes" ), i18n( "bool" ) );
525 new QListViewItem( opsGUI, "ShowTimeBox", i18n( "Toggle display of Time InfoBox" ), i18n( "bool" ) );
526 new QListViewItem( opsGUI, "ShowGeoBox", i18n( "Toggle display of Geographic InfoBox" ), i18n( "bool" ) );
527 new QListViewItem( opsGUI, "ShowFocusBox", i18n( "Toggle display of Focus InfoBox" ), i18n( "bool" ) );
528 new QListViewItem( opsGUI, "ShadeTimeBox", i18n( "(un)Shade Time InfoBox" ), i18n( "bool" ) );
529 new QListViewItem( opsGUI, "ShadeGeoBox", i18n( "(un)Shade Geographic InfoBox" ), i18n( "bool" ) );
530 new QListViewItem( opsGUI, "ShadeFocusBox", i18n( "(un)Shade Focus InfoBox" ), i18n( "bool" ) );
531 argChangeViewOption->OptionName->insertItem( "ShowInfoBoxes" );
532 argChangeViewOption->OptionName->insertItem( "ShowTimeBox" );
533 argChangeViewOption->OptionName->insertItem( "ShowGeoBox" );
534 argChangeViewOption->OptionName->insertItem( "ShowFocusBox" );
535 argChangeViewOption->OptionName->insertItem( "ShadeTimeBox" );
536 argChangeViewOption->OptionName->insertItem( "ShadeGeoBox" );
537 argChangeViewOption->OptionName->insertItem( "ShadeFocusBox" );
539 //Toolbars
540 opsToolbar = new QListViewItem( otv->OptionsList, i18n( "Toolbars" ) );
541 new QListViewItem( opsToolbar, "ShowMainToolBar", i18n( "Toggle display of main toolbar" ), i18n( "bool" ) );
542 new QListViewItem( opsToolbar, "ShowViewToolBar", i18n( "Toggle display of view toolbar" ), i18n( "bool" ) );
543 argChangeViewOption->OptionName->insertItem( "ShowMainToolBar" );
544 argChangeViewOption->OptionName->insertItem( "ShowViewToolBar" );
546 //Show Objects
547 opsShowObj = new QListViewItem( otv->OptionsList, i18n( "Show Objects" ) );
548 new QListViewItem( opsShowObj, "ShowStars", i18n( "Toggle display of Stars" ), i18n( "bool" ) );
549 new QListViewItem( opsShowObj, "ShowDeepSky", i18n( "Toggle display of all deep-sky objects" ), i18n( "bool" ) );
550 new QListViewItem( opsShowObj, "ShowMessier", i18n( "Toggle display of Messier object symbols" ), i18n( "bool" ) );
551 new QListViewItem( opsShowObj, "ShowMessierImages", i18n( "Toggle display of Messier object images" ), i18n( "bool" ) );
552 new QListViewItem( opsShowObj, "ShowNGC", i18n( "Toggle display of NGC objects" ), i18n( "bool" ) );
553 new QListViewItem( opsShowObj, "ShowIC", i18n( "Toggle display of IC objects" ), i18n( "bool" ) );
554 new QListViewItem( opsShowObj, "ShowPlanets", i18n( "Toggle display of all solar system bodies" ), i18n( "bool" ) );
555 new QListViewItem( opsShowObj, "ShowSun", i18n( "Toggle display of Sun" ), i18n( "bool" ) );
556 new QListViewItem( opsShowObj, "ShowMoon", i18n( "Toggle display of Moon" ), i18n( "bool" ) );
557 new QListViewItem( opsShowObj, "ShowMercury", i18n( "Toggle display of Mercury" ), i18n( "bool" ) );
558 new QListViewItem( opsShowObj, "ShowVenus", i18n( "Toggle display of Venus" ), i18n( "bool" ) );
559 new QListViewItem( opsShowObj, "ShowMars", i18n( "Toggle display of Mars" ), i18n( "bool" ) );
560 new QListViewItem( opsShowObj, "ShowJupiter", i18n( "Toggle display of Jupiter" ), i18n( "bool" ) );
561 new QListViewItem( opsShowObj, "ShowSaturn", i18n( "Toggle display of Saturn" ), i18n( "bool" ) );
562 new QListViewItem( opsShowObj, "ShowUranus", i18n( "Toggle display of Uranus" ), i18n( "bool" ) );
563 new QListViewItem( opsShowObj, "ShowNeptune", i18n( "Toggle display of Neptune" ), i18n( "bool" ) );
564 new QListViewItem( opsShowObj, "ShowPluto", i18n( "Toggle display of Pluto" ), i18n( "bool" ) );
565 new QListViewItem( opsShowObj, "ShowAsteroids", i18n( "Toggle display of Asteroids" ), i18n( "bool" ) );
566 new QListViewItem( opsShowObj, "ShowComets", i18n( "Toggle display of Comets" ), i18n( "bool" ) );
567 argChangeViewOption->OptionName->insertItem( "ShowSAO" );
568 argChangeViewOption->OptionName->insertItem( "ShowDeepSky" );
569 argChangeViewOption->OptionName->insertItem( "ShowMess" );
570 argChangeViewOption->OptionName->insertItem( "ShowMessImages" );
571 argChangeViewOption->OptionName->insertItem( "ShowNGC" );
572 argChangeViewOption->OptionName->insertItem( "ShowIC" );
573 argChangeViewOption->OptionName->insertItem( "ShowPlanets" );
574 argChangeViewOption->OptionName->insertItem( "ShowSun" );
575 argChangeViewOption->OptionName->insertItem( "ShowMoon" );
576 argChangeViewOption->OptionName->insertItem( "ShowMercury" );
577 argChangeViewOption->OptionName->insertItem( "ShowVenus" );
578 argChangeViewOption->OptionName->insertItem( "ShowMars" );
579 argChangeViewOption->OptionName->insertItem( "ShowJupiter" );
580 argChangeViewOption->OptionName->insertItem( "ShowSaturn" );
581 argChangeViewOption->OptionName->insertItem( "ShowUranus" );
582 argChangeViewOption->OptionName->insertItem( "ShowNeptune" );
583 argChangeViewOption->OptionName->insertItem( "ShowPluto" );
584 argChangeViewOption->OptionName->insertItem( "ShowAsteroids" );
585 argChangeViewOption->OptionName->insertItem( "ShowComets" );
587 opsShowOther = new QListViewItem( otv->OptionsList, i18n( "Show Other" ) );
588 new QListViewItem( opsShowOther, "ShowCLines", i18n( "Toggle display of constellation lines" ), i18n( "bool" ) );
589 new QListViewItem( opsShowOther, "ShowCBounds", i18n( "Toggle display of constellation boundaries" ), i18n( "bool" ) );
590 new QListViewItem( opsShowOther, "ShowCNames", i18n( "Toggle display of constellation names" ), i18n( "bool" ) );
591 new QListViewItem( opsShowOther, "ShowMilkyWay", i18n( "Toggle display of Milky Way" ), i18n( "bool" ) );
592 new QListViewItem( opsShowOther, "ShowGrid", i18n( "Toggle display of the coordinate grid" ), i18n( "bool" ) );
593 new QListViewItem( opsShowOther, "ShowEquator", i18n( "Toggle display of the celestial equator" ), i18n( "bool" ) );
594 new QListViewItem( opsShowOther, "ShowEcliptic", i18n( "Toggle display of the ecliptic" ), i18n( "bool" ) );
595 new QListViewItem( opsShowOther, "ShowHorizon", i18n( "Toggle display of the horizon line" ), i18n( "bool" ) );
596 new QListViewItem( opsShowOther, "ShowGround", i18n( "Toggle display of the opaque ground" ), i18n( "bool" ) );
597 new QListViewItem( opsShowOther, "ShowStarNames", i18n( "Toggle display of star name labels" ), i18n( "bool" ) );
598 new QListViewItem( opsShowOther, "ShowStarMagnitudes", i18n( "Toggle display of star magnitude labels" ), i18n( "bool" ) );
599 new QListViewItem( opsShowOther, "ShowAsteroidNames", i18n( "Toggle display of asteroid name labels" ), i18n( "bool" ) );
600 new QListViewItem( opsShowOther, "ShowCometNames", i18n( "Toggle display of comet name labels" ), i18n( "bool" ) );
601 new QListViewItem( opsShowOther, "ShowPlanetNames", i18n( "Toggle display of planet name labels" ), i18n( "bool" ) );
602 new QListViewItem( opsShowOther, "ShowPlanetImages", i18n( "Toggle display of planet images" ), i18n( "bool" ) );
603 argChangeViewOption->OptionName->insertItem( "ShowCLines" );
604 argChangeViewOption->OptionName->insertItem( "ShowCBounds" );
605 argChangeViewOption->OptionName->insertItem( "ShowCNames" );
606 argChangeViewOption->OptionName->insertItem( "ShowMilkyWay" );
607 argChangeViewOption->OptionName->insertItem( "ShowGrid" );
608 argChangeViewOption->OptionName->insertItem( "ShowEquator" );
609 argChangeViewOption->OptionName->insertItem( "ShowEcliptic" );
610 argChangeViewOption->OptionName->insertItem( "ShowHorizon" );
611 argChangeViewOption->OptionName->insertItem( "ShowGround" );
612 argChangeViewOption->OptionName->insertItem( "ShowStarNames" );
613 argChangeViewOption->OptionName->insertItem( "ShowStarMagnitudes" );
614 argChangeViewOption->OptionName->insertItem( "ShowAsteroidNames" );
615 argChangeViewOption->OptionName->insertItem( "ShowCometNames" );
616 argChangeViewOption->OptionName->insertItem( "ShowPlanetNames" );
617 argChangeViewOption->OptionName->insertItem( "ShowPlanetImages" );
619 opsCName = new QListViewItem( otv->OptionsList, i18n( "Constellation Names" ) );
620 new QListViewItem( opsCName, "UseLatinConstellNames", i18n( "Show Latin constellation names" ), i18n( "bool" ) );
621 new QListViewItem( opsCName, "UseLocalConstellNames", i18n( "Show constellation names in local language" ), i18n( "bool" ) );
622 new QListViewItem( opsCName, "UseAbbrevConstellNames", i18n( "Show IAU-standard constellation abbreviations" ), i18n( "bool" ) );
623 argChangeViewOption->OptionName->insertItem( "UseLatinConstellNames" );
624 argChangeViewOption->OptionName->insertItem( "UseLocalConstellNames" );
625 argChangeViewOption->OptionName->insertItem( "UseAbbrevConstellNames" );
627 opsHide = new QListViewItem( otv->OptionsList, i18n( "Hide Items" ) );
628 new QListViewItem( opsHide, "HideOnSlew", i18n( "Toggle whether objects hidden while slewing display" ), i18n( "bool" ) );
629 new QListViewItem( opsHide, "SlewTimeScale", i18n( "Timestep threshold (in seconds) for hiding objects" ), i18n( "double" ) );
630 new QListViewItem( opsHide, "HideStars", i18n( "Hide faint stars while slewing?" ), i18n( "bool" ) );
631 new QListViewItem( opsHide, "HidePlanets", i18n( "Hide solar system bodies while slewing?" ), i18n( "bool" ) );
632 new QListViewItem( opsHide, "HideMessier", i18n( "Hide Messier objects while slewing?" ), i18n( "bool" ) );
633 new QListViewItem( opsHide, "HideNGC", i18n( "Hide NGC objects while slewing?" ), i18n( "bool" ) );
634 new QListViewItem( opsHide, "HideIC", i18n( "Hide IC objects while slewing?" ), i18n( "bool" ) );
635 new QListViewItem( opsHide, "HideMilkyWay", i18n( "Hide Milky Way while slewing?" ), i18n( "bool" ) );
636 new QListViewItem( opsHide, "HideCNames", i18n( "Hide constellation names while slewing?" ), i18n( "bool" ) );
637 new QListViewItem( opsHide, "HideCLines", i18n( "Hide constellation lines while slewing?" ), i18n( "bool" ) );
638 new QListViewItem( opsHide, "HideCBounds", i18n( "Hide constellation boundaries while slewing?" ), i18n( "bool" ) );
639 new QListViewItem( opsHide, "HideGrid", i18n( "Hide coordinate grid while slewing?" ), i18n( "bool" ) );
640 argChangeViewOption->OptionName->insertItem( "HideOnSlew" );
641 argChangeViewOption->OptionName->insertItem( "SlewTimeScale" );
642 argChangeViewOption->OptionName->insertItem( "HideStars" );
643 argChangeViewOption->OptionName->insertItem( "HidePlanets" );
644 argChangeViewOption->OptionName->insertItem( "HideMessier" );
645 argChangeViewOption->OptionName->insertItem( "HideNGC" );
646 argChangeViewOption->OptionName->insertItem( "HideIC" );
647 argChangeViewOption->OptionName->insertItem( "HideMilkyWay" );
648 argChangeViewOption->OptionName->insertItem( "HideCNames" );
649 argChangeViewOption->OptionName->insertItem( "HideCLines" );
650 argChangeViewOption->OptionName->insertItem( "HideCBounds" );
651 argChangeViewOption->OptionName->insertItem( "HideGrid" );
653 opsSkymap = new QListViewItem( otv->OptionsList, i18n( "Skymap Options" ) );
654 new QListViewItem( opsSkymap, "UseAltAz", i18n( "Use Horizontal coordinates? (otherwise, use Equatorial)" ), i18n( "bool" ) );
655 new QListViewItem( opsSkymap, "ZoomFactor", i18n( "Set the Zoom Factor" ), i18n( "double" ) );
656 new QListViewItem( opsSkymap, "FOV Size", i18n( "Select angular size for the FOV symbol (in arcmin)" ), i18n( "double" ) );
657 new QListViewItem( opsSkymap, "FOV Shape", i18n( "Select shape for the FOV symbol (0=Square, 1=Circle, 2=Crosshairs, 4=Bullseye)" ), i18n( "int" ) );
658 new QListViewItem( opsSkymap, "FOV Color", i18n( "Select color for the FOV symbol" ), i18n( "string" ) );
659 new QListViewItem( opsSkymap, "AnimateSlewing", i18n( "Use animated slewing? (otherwise, \"snap\" to new focus)" ), i18n( "bool" ) );
660 new QListViewItem( opsSkymap, "UseRefraction", i18n( "Correct for atmospheric refraction?" ), i18n( "bool" ) );
661 new QListViewItem( opsSkymap, "UseAutoLabel", i18n( "Automatically attach name label to centered object?" ), i18n( "bool" ) );
662 new QListViewItem( opsSkymap, "UseHoverLabel", i18n( "Attach temporary name label when hovering mouse over an object?" ), i18n( "bool" ) );
663 new QListViewItem( opsSkymap, "UseAutoTrail", i18n( "Automatically add trail to centered solar system body?" ), i18n( "bool" ) );
664 new QListViewItem( opsSkymap, "FadePlanetTrails", i18n( "Planet trails fade to sky color? (otherwise color is constant)" ), i18n( "bool" ) );
665 argChangeViewOption->OptionName->insertItem( "UseAltAz" );
666 argChangeViewOption->OptionName->insertItem( "ZoomFactor" );
667 argChangeViewOption->OptionName->insertItem( "FOVName" );
668 argChangeViewOption->OptionName->insertItem( "FOVSize" );
669 argChangeViewOption->OptionName->insertItem( "FOVShape" );
670 argChangeViewOption->OptionName->insertItem( "FOVColor" );
671 argChangeViewOption->OptionName->insertItem( "UseRefraction" );
672 argChangeViewOption->OptionName->insertItem( "UseAutoLabel" );
673 argChangeViewOption->OptionName->insertItem( "UseHoverLabel" );
674 argChangeViewOption->OptionName->insertItem( "UseAutoTrail" );
675 argChangeViewOption->OptionName->insertItem( "AnimateSlewing" );
676 argChangeViewOption->OptionName->insertItem( "FadePlanetTrails" );
678 opsLimit = new QListViewItem( otv->OptionsList, i18n( "Limits" ) );
679 new QListViewItem( opsLimit, "magLimitDrawStar", i18n( "magnitude of faintest star drawn on map when zoomed in" ), i18n( "double" ) );
680 new QListViewItem( opsLimit, "magLimitDrawStarZoomOut", i18n( "magnitude of faintest star drawn on map when zoomed out" ), i18n( "double" ) );
681 new QListViewItem( opsLimit, "magLimitDrawDeepSky", i18n( "magnitude of faintest nonstellar object drawn on map when zoomed in" ), i18n( "double" ) );
682 new QListViewItem( opsLimit, "magLimitDrawDeepSkyZoomOut", i18n( "magnitude of faintest nonstellar object drawn on map when zoomed out" ), i18n( "double" ) );
683 new QListViewItem( opsLimit, "magLimitDrawStarInfo", i18n( "magnitude of faintest star labeled on map" ), i18n( "double" ) );
684 new QListViewItem( opsLimit, "magLimitHideStar", i18n( "magnitude of brightest star hidden while slewing" ), i18n( "double" ) );
685 new QListViewItem( opsLimit, "magLimitAsteroid", i18n( "magnitude of faintest asteroid drawn on map" ), i18n( "double" ) );
686 new QListViewItem( opsLimit, "magLimitAsteroidName", i18n( "magnitude of faintest asteroid labeled on map" ), i18n( "double" ) );
687 new QListViewItem( opsLimit, "maxRadCometName", i18n( "comets nearer to the Sun than this (in AU) are labeled on map" ), i18n( "double" ) );
688 argChangeViewOption->OptionName->insertItem( "magLimitDrawStar" );
689 argChangeViewOption->OptionName->insertItem( "magLimitDrawStarZoomOut" );
690 argChangeViewOption->OptionName->insertItem( "magLimitDrawDeepSky" );
691 argChangeViewOption->OptionName->insertItem( "magLimitDrawDeepSkyZoomOut" );
692 argChangeViewOption->OptionName->insertItem( "magLimitDrawStarInfo" );
693 argChangeViewOption->OptionName->insertItem( "magLimitHideStar" );
694 argChangeViewOption->OptionName->insertItem( "magLimitAsteroid" );
695 argChangeViewOption->OptionName->insertItem( "magLimitAsteroidName" );
696 argChangeViewOption->OptionName->insertItem( "maxRadCometName" );
698 //init the list of color names and values
699 for ( unsigned int i=0; i < ks->data()->colorScheme()->numberOfColors(); ++i ) {
700 argSetColor->ColorName->insertItem( ks->data()->colorScheme()->nameAt(i) );
703 //init list of color scheme names
704 argLoadColorScheme->SchemeList->insertItem( i18n( "use default color scheme", "Default Colors" ) );
705 argLoadColorScheme->SchemeList->insertItem( i18n( "use 'star chart' color scheme", "Star Chart" ) );
706 argLoadColorScheme->SchemeList->insertItem( i18n( "use 'night vision' color scheme", "Night Vision" ) );
707 argLoadColorScheme->SchemeList->insertItem( i18n( "use 'moonless night' color scheme", "Moonless Night" ) );
709 QFile file;
710 QString line;
711 file.setName( locate( "appdata", "colors.dat" ) ); //determine filename in local user KDE directory tree.
712 if ( file.open( IO_ReadOnly ) ) {
713 QTextStream stream( &file );
715 while ( !stream.eof() ) {
716 line = stream.readLine();
717 argLoadColorScheme->SchemeList->insertItem( line.left( line.find( ':' ) ) );
719 file.close();
723 //Slots defined in ScriptBuilderUI
724 void ScriptBuilder::slotNew() {
725 saveWarning();
726 if ( !UnsavedChanges ) {
727 ScriptList.clear();
728 sb->ScriptListBox->clear();
729 sb->ArgStack->raiseWidget( argBlank );
731 sb->CopyButton->setEnabled( false );
732 sb->RemoveButton->setEnabled( false );
733 sb->RunButton->setEnabled( false );
735 currentFileURL = "";
736 currentScriptName = "";
740 void ScriptBuilder::slotOpen() {
741 saveWarning();
743 QString fname;
744 KTempFile tmpfile;
745 tmpfile.setAutoDelete(true);
747 if ( !UnsavedChanges ) {
748 currentFileURL = KFileDialog::getOpenURL( currentDir, "*.kstars|KStars Scripts (*.kstars)" );
750 if ( currentFileURL.isValid() ) {
751 currentDir = currentFileURL.directory();
753 ScriptList.clear();
754 sb->ScriptListBox->clear();
755 sb->ArgStack->raiseWidget( argBlank );
757 if ( currentFileURL.isLocalFile() ) {
758 fname = currentFileURL.path();
759 } else {
760 fname = tmpfile.name();
761 if ( ! KIO::NetAccess::download( currentFileURL, fname, (QWidget*) 0 ) )
762 KMessageBox::sorry( 0, i18n( "Could not download remote file." ), i18n( "Download Error" ) );
765 QFile f( fname );
766 if ( !f.open( IO_ReadOnly) ) {
767 QString message = i18n( "Could not open file %1." ).arg( f.name() );
768 KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
769 currentFileURL = "";
770 return;
773 QTextStream istream(&f);
774 readScript( istream );
776 f.close();
777 } else if ( ! currentFileURL.url().isEmpty() ) {
778 QString message = i18n( "Invalid URL: %1" ).arg( currentFileURL.url() );
779 KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
780 currentFileURL = "";
785 void ScriptBuilder::slotSave() {
786 QString fname;
787 KTempFile tmpfile;
788 tmpfile.setAutoDelete(true);
790 if ( currentScriptName.isEmpty() ) {
791 //Get Script Name and Author info
792 if ( snd->exec() == QDialog::Accepted ) {
793 currentScriptName = snd->ScriptName->text();
794 currentAuthor = snd->AuthorName->text();
795 } else {
796 return;
800 if ( currentFileURL.isEmpty() )
801 currentFileURL = KFileDialog::getSaveURL( currentDir, "*.kstars|KStars Scripts (*.kstars)" );
803 if ( currentFileURL.isValid() ) {
804 currentDir = currentFileURL.directory();
806 if ( currentFileURL.isLocalFile() ) {
807 fname = currentFileURL.path();
809 //Warn user if file exists
810 if (QFile::exists(currentFileURL.path())) {
811 int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
812 i18n( "A file named \"%1\" already exists. "
813 "Overwrite it?" ).arg(currentFileURL.fileName()),
814 i18n( "Overwrite File?" ),
815 i18n( "&Overwrite" ) );
817 if(r==KMessageBox::Cancel) return;
819 } else {
820 fname = tmpfile.name();
823 if ( fname.right( 7 ).lower() != ".kstars" ) fname += ".kstars";
825 QFile f( fname );
826 if ( !f.open( IO_WriteOnly) ) {
827 QString message = i18n( "Could not open file %1." ).arg( f.name() );
828 KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
829 currentFileURL = "";
830 return;
833 QTextStream ostream(&f);
834 writeScript( ostream );
835 f.close();
837 //set rwx for owner, rx for group, rx for other
838 chmod( fname.ascii(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
840 if ( tmpfile.name() == fname ) { //need to upload to remote location
841 if ( ! KIO::NetAccess::upload( tmpfile.name(), currentFileURL, (QWidget*) 0 ) ) {
842 QString message = i18n( "Could not upload image to remote location: %1" ).arg( currentFileURL.prettyURL() );
843 KMessageBox::sorry( 0, message, i18n( "Could not upload file" ) );
847 setUnsavedChanges( false );
849 } else {
850 QString message = i18n( "Invalid URL: %1" ).arg( currentFileURL.url() );
851 KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
852 currentFileURL = "";
856 void ScriptBuilder::slotSaveAs() {
857 currentFileURL = "";
858 currentScriptName = "";
859 slotSave();
862 void ScriptBuilder::saveWarning() {
863 if ( UnsavedChanges ) {
864 QString caption = i18n( "Save Changes to Script?" );
865 QString message = i18n( "The current script has unsaved changes. Would you like to save before closing it?" );
866 QString ybut = KStdGuiItem::save().text();
867 QString nbut = i18n( "&Discard" );
868 int ans = KMessageBox::warningYesNoCancel( 0, message, caption, ybut, nbut );
869 if ( ans == KMessageBox::Yes ) {
870 slotSave();
871 setUnsavedChanges( false );
872 } else if ( ans == KMessageBox::No ) {
873 setUnsavedChanges( false );
876 //Do nothing if 'cancel' selected
880 void ScriptBuilder::slotRunScript() {
881 //hide window while script runs
882 // If this is uncommented, the program hangs before the script is executed. Why?
883 // hide();
885 //Save current script to a temporary file, then execute that file.
886 //For some reason, I can't use KTempFile here! If I do, then the temporary script
887 //is not executable. Bizarre...
888 //KTempFile tmpfile;
889 //QString fname = tmpfile.name();
890 QString fname = locateLocal( "tmp", "kstars-tempscript" );
892 QFile f( fname );
893 if ( f.exists() ) f.remove();
894 if ( !f.open( IO_WriteOnly) ) {
895 QString message = i18n( "Could not open file %1." ).arg( f.name() );
896 KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
897 currentFileURL = "";
898 return;
901 QTextStream ostream(&f);
902 writeScript( ostream );
903 f.close();
905 //set rwx for owner, rx for group, rx for other
906 chmod( f.name().ascii(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
908 KProcess p;
909 p << f.name();
910 if ( ! p.start( KProcess::DontCare ) )
911 kdDebug() << "Process did not start." << endl;
913 while ( p.isRunning() ) kapp->processEvents( 50 ); //otherwise tempfile may get deleted before script completes.
915 //delete temp file
916 if ( f.exists() ) f.remove();
918 //uncomment if 'hide()' is uncommented...
919 // show();
922 void ScriptBuilder::writeScript( QTextStream &ostream ) {
923 QString mainpre = "dcop $KSTARS $MAIN ";
924 QString clockpre = "dcop $KSTARS $CLOCK ";
926 //Write script header
927 ostream << "#!/bin/bash" << endl;
928 ostream << "#KStars DCOP script: " << currentScriptName << endl;
929 ostream << "#by " << currentAuthor << endl;
930 ostream << "#last modified: " << KStarsDateTime::currentDateTime().toString() << endl;
931 ostream << "#" << endl;
932 ostream << "KSTARS=`dcopfind -a 'kstars*'`" << endl;
933 ostream << "MAIN=KStarsInterface" << endl;
934 ostream << "CLOCK=clock#1" << endl;
936 for ( ScriptFunction *sf = ScriptList.first(); sf; sf = ScriptList.next() )
938 if (!sf->valid()) continue;
939 if ( sf->isClockFunction() ) {
940 ostream << clockpre << sf->scriptLine() << endl;
941 } else {
942 ostream << mainpre << sf->scriptLine() << endl;
943 if (sb->AppendINDIWait->isChecked() && !sf->INDIProperty().isEmpty())
945 // Special case for telescope action, we need to know the parent property
946 if (sf->INDIProperty() == "CHECK")
948 if (sf->argVal(1) == "SLEW" || sf->argVal(1) == "TRACK" || sf->argVal(1) == "SYNC")
949 sf->setINDIProperty("ON_COORD_SET");
950 else if (sf->argVal(1) == "ABORT")
951 sf->setINDIProperty("ABORT_MOTION");
952 else
953 sf->setINDIProperty("PARK");
956 if ( sf->argVal(0).contains(" "))
957 ostream << mainpre << "waitForINDIAction " << "\"" << sf->argVal(0) << "\" " << sf->INDIProperty() << endl;
958 else
959 ostream << mainpre << "waitForINDIAction " << sf->argVal(0) << " " << sf->INDIProperty() << endl;
964 //Write script footer
965 ostream << "##" << endl;
968 void ScriptBuilder::readScript( QTextStream &istream ) {
969 QString line;
971 while ( ! istream.eof() ) {
972 line = istream.readLine();
974 //look for name of script
975 if ( line.contains( "#KStars DCOP script: " ) )
976 currentScriptName = line.mid( 21 ).stripWhiteSpace();
978 //look for author of scriptbuilder
979 if ( line.contains( "#by " ) )
980 currentAuthor = line.mid( 4 ).stripWhiteSpace();
982 //Actual script functions
983 if ( line.left(4) == "dcop" ) {
985 //is ClockFunction?
986 bool clockfcn( false );
987 if ( line.contains( "$CLOCK" ) ) clockfcn = true;
989 //remove leading dcop prefix
990 line = line.mid( 20 );
992 //construct a stringlist that is fcn name and its arg name/value pairs
993 QStringList fn = QStringList::split( " ", line );
994 if ( parseFunction( fn ) )
996 sb->ScriptListBox->insertItem( ScriptList.current()->name() );
997 // Initially, any read script is valid!
998 ScriptList.current()->setValid(true);
1000 else kdWarning() << i18n( "Could not parse script. Line was: %1" ).arg( line ) << endl;
1002 } // end if left(4) == "dcop"
1003 } // end while !eof()
1005 //Select first item in sb->ScriptListBox
1006 if ( sb->ScriptListBox->count() ) {
1007 sb->ScriptListBox->setCurrentItem( 0 );
1008 slotArgWidget();
1012 bool ScriptBuilder::parseFunction( QStringList &fn )
1014 // clean up the string list first if needed
1015 // We need to perform this in case we havea quoted string "NGC 3000" because this will counted
1016 // as two arguments, and it should be counted as one.
1017 bool foundQuote(false), quoteProcessed(false);
1018 QString cur, arg;
1019 QStringList::iterator it;
1021 for (it = fn.begin(); it != fn.end(); ++it)
1023 cur = (*it);
1025 if ( cur.startsWith("\""))
1027 arg += cur.right(cur.length() - 1);
1028 arg += " ";
1029 foundQuote = true;
1030 quoteProcessed = true;
1032 else if (cur.endsWith("\""))
1034 arg += cur.left(cur.length() -1);
1035 arg += "'";
1036 foundQuote = false;
1038 else if (foundQuote)
1040 arg += cur;
1041 arg += " ";
1043 else
1045 arg += cur;
1046 arg += "'";
1050 if (quoteProcessed)
1051 fn = QStringList::split( "'", arg );
1053 //loop over known functions to find a name match
1054 for ( ScriptFunction *sf = KStarsFunctionList.first(); sf; sf = KStarsFunctionList.next() )
1056 if ( fn[0] == sf->name() ) {
1058 if ( fn[0] == "setGeoLocation" ) {
1059 QString city( fn[1] ), prov( "" ), cntry( fn[2] );
1060 if ( fn.count() == 4 ) { prov = fn[2]; cntry = fn[3]; }
1061 if ( fn.count() == 3 || fn.count() == 4 ) {
1062 ScriptList.append( new ScriptFunction( sf ) );
1063 ScriptList.current()->setArg( 0, city );
1064 ScriptList.current()->setArg( 1, prov );
1065 ScriptList.current()->setArg( 2, cntry );
1066 } else return false;
1068 } else if ( fn.count() != sf->numArgs() + 1 ) return false;
1070 ScriptList.append( new ScriptFunction( sf ) );
1072 for ( unsigned int i=0; i<sf->numArgs(); ++i )
1073 ScriptList.current()->setArg( i, fn[i+1] );
1075 return true;
1078 for ( ScriptFunction *sf = INDIFunctionList.first(); sf; sf = INDIFunctionList.next() )
1080 if ( fn[0] == sf->name() )
1083 if ( fn.count() != sf->numArgs() + 1 ) return false;
1085 ScriptList.append( new ScriptFunction( sf ) );
1087 for ( unsigned int i=0; i<sf->numArgs(); ++i )
1088 ScriptList.current()->setArg( i, fn[i+1] );
1090 return true;
1095 //if we get here, no function-name match was found
1096 return false;
1099 void ScriptBuilder::setUnsavedChanges( bool b ) {
1100 UnsavedChanges = b;
1101 sb->SaveButton->setEnabled( b );
1102 sb->SaveAsButton->setEnabled( b );
1105 void ScriptBuilder::slotEnableScriptNameOK() {
1106 snd->OKButton->setEnabled( ! snd->ScriptName->text().isEmpty() );
1109 void ScriptBuilder::slotCopyFunction() {
1110 if ( ! UnsavedChanges ) setUnsavedChanges( true );
1112 int Pos = sb->ScriptListBox->currentItem() + 1;
1113 ScriptList.insert( Pos, new ScriptFunction( ScriptList.at( Pos-1 ) ) );
1114 //copy ArgVals
1115 for ( unsigned int i=0; i < ScriptList.at( Pos-1 )->numArgs(); ++i )
1116 ScriptList.at(Pos)->setArg(i, ScriptList.at( Pos-1 )->argVal(i) );
1118 sb->ScriptListBox->insertItem( ScriptList.current()->name(), Pos );
1119 sb->ScriptListBox->setSelected( Pos, true );
1122 void ScriptBuilder::slotRemoveFunction() {
1123 setUnsavedChanges( true );
1125 int Pos = sb->ScriptListBox->currentItem();
1126 ScriptList.remove( Pos );
1127 sb->ScriptListBox->removeItem( Pos );
1128 if ( sb->ScriptListBox->count() == 0 ) {
1129 sb->ArgStack->raiseWidget( argBlank );
1130 sb->CopyButton->setEnabled( false );
1131 sb->RemoveButton->setEnabled( false );
1132 } else {
1133 sb->ScriptListBox->setSelected( Pos, true );
1137 void ScriptBuilder::slotAddFunction() {
1139 ScriptFunction *sc = NULL;
1140 QListViewItem *currentItem = sb->FunctionListView->currentItem();
1142 if ( currentItem == NULL || currentItem->depth() == 0)
1143 return;
1145 for (sc = KStarsFunctionList.first(); sc; sc = KStarsFunctionList.next())
1146 if (sc->prototype() == currentItem->text(0))
1147 break;
1149 if (sc == NULL)
1151 for (sc = INDIFunctionList.first(); sc; sc = INDIFunctionList.next())
1152 if (sc->prototype() == currentItem->text(0))
1153 break;
1157 if (sc == NULL) return;
1159 setUnsavedChanges( true );
1161 int Pos = sb->ScriptListBox->currentItem() + 1;
1163 ScriptList.insert( Pos, new ScriptFunction(sc) );
1164 sb->ScriptListBox->insertItem( ScriptList.current()->name(), Pos );
1165 sb->ScriptListBox->setSelected( Pos, true );
1168 void ScriptBuilder::slotMoveFunctionUp() {
1169 if ( sb->ScriptListBox->currentItem() > 0 ) {
1170 setUnsavedChanges( true );
1172 QString t = sb->ScriptListBox->currentText();
1173 unsigned int n = sb->ScriptListBox->currentItem();
1175 ScriptFunction *tmp = ScriptList.take( n );
1176 ScriptList.insert( n-1, tmp );
1178 sb->ScriptListBox->removeItem( n );
1179 sb->ScriptListBox->insertItem( t, n-1 );
1180 sb->ScriptListBox->setSelected( n-1, true );
1184 void ScriptBuilder::slotMoveFunctionDown() {
1185 if ( sb->ScriptListBox->currentItem() > -1 &&
1186 sb->ScriptListBox->currentItem() < ((int) sb->ScriptListBox->count())-1 ) {
1187 setUnsavedChanges( true );
1189 QString t = sb->ScriptListBox->currentText();
1190 unsigned int n = sb->ScriptListBox->currentItem();
1192 ScriptFunction *tmp = ScriptList.take( n );
1193 ScriptList.insert( n+1, tmp );
1195 sb->ScriptListBox->removeItem( n );
1196 sb->ScriptListBox->insertItem( t, n+1 );
1197 sb->ScriptListBox->setSelected( n+1, true );
1201 void ScriptBuilder::slotArgWidget() {
1202 //First, setEnabled on buttons that act on the selected script function
1203 if ( sb->ScriptListBox->currentItem() == -1 ) { //no selection
1204 sb->CopyButton->setEnabled( false );
1205 sb->RemoveButton->setEnabled( false );
1206 sb->UpButton->setEnabled( false );
1207 sb->DownButton->setEnabled( false );
1208 } else if ( sb->ScriptListBox->count() == 1 ) { //only one item, so disable up/down buttons
1209 sb->CopyButton->setEnabled( true );
1210 sb->RemoveButton->setEnabled( true );
1211 sb->UpButton->setEnabled( false );
1212 sb->DownButton->setEnabled( false );
1213 } else if ( sb->ScriptListBox->currentItem() == 0 ) { //first item selected
1214 sb->CopyButton->setEnabled( true );
1215 sb->RemoveButton->setEnabled( true );
1216 sb->UpButton->setEnabled( false );
1217 sb->DownButton->setEnabled( true );
1218 } else if ( sb->ScriptListBox->currentItem() == ((int) sb->ScriptListBox->count())-1 ) { //last item selected
1219 sb->CopyButton->setEnabled( true );
1220 sb->RemoveButton->setEnabled( true );
1221 sb->UpButton->setEnabled( true );
1222 sb->DownButton->setEnabled( false );
1223 } else { //other item selected
1224 sb->CopyButton->setEnabled( true );
1225 sb->RemoveButton->setEnabled( true );
1226 sb->UpButton->setEnabled( true );
1227 sb->DownButton->setEnabled( true );
1230 //sb->RunButton enabled when script not empty.
1231 if ( sb->ScriptListBox->count() ) {
1232 sb->RunButton->setEnabled( true );
1233 } else {
1234 sb->RunButton->setEnabled( false );
1235 setUnsavedChanges( false );
1238 //Display the function's arguments widget
1239 if ( sb->ScriptListBox->currentItem() > -1 &&
1240 sb->ScriptListBox->currentItem() < ((int) sb->ScriptListBox->count()) ) {
1241 QString t = sb->ScriptListBox->currentText();
1242 unsigned int n = sb->ScriptListBox->currentItem();
1243 ScriptFunction *sf = ScriptList.at( n );
1245 if ( sf->name() == "lookTowards" ) {
1246 sb->ArgStack->raiseWidget( argLookToward );
1247 QString s = sf->argVal(0);
1248 argLookToward->FocusEdit->setCurrentText( s );
1250 } else if ( sf->name() == "setRaDec" ) {
1251 bool ok(false);
1252 double r(0.0),d(0.0);
1253 dms ra(0.0);
1255 sb->ArgStack->raiseWidget( argSetRaDec );
1257 ok = !sf->argVal(0).isEmpty();
1258 if (ok) r = sf->argVal(0).toDouble(&ok);
1259 else argSetRaDec->RaBox->clear();
1260 if (ok) { ra.setH(r); argSetRaDec->RaBox->showInHours( ra ); }
1262 ok = !sf->argVal(1).isEmpty();
1263 if (ok) d = sf->argVal(1).toDouble(&ok);
1264 else argSetRaDec->DecBox->clear();
1265 if (ok) argSetRaDec->DecBox->showInDegrees( dms(d) );
1267 } else if ( sf->name() == "setAltAz" ) {
1268 bool ok(false);
1269 double x(0.0),y(0.0);
1271 sb->ArgStack->raiseWidget( argSetAltAz );
1273 ok = !sf->argVal(0).isEmpty();
1274 if (ok) y = sf->argVal(0).toDouble(&ok);
1275 else argSetAltAz->AzBox->clear();
1276 if (ok) argSetAltAz->AltBox->showInDegrees( dms(y) );
1277 else argSetAltAz->AltBox->clear();
1279 ok = !sf->argVal(1).isEmpty();
1280 x = sf->argVal(1).toDouble(&ok);
1281 if (ok) argSetAltAz->AzBox->showInDegrees( dms(x) );
1283 } else if ( sf->name() == "zoomIn" ) {
1284 sb->ArgStack->raiseWidget( argBlank );
1285 //no Args
1287 } else if ( sf->name() == "zoomOut" ) {
1288 sb->ArgStack->raiseWidget( argBlank );
1289 //no Args
1291 } else if ( sf->name() == "defaultZoom" ) {
1292 sb->ArgStack->raiseWidget( argBlank );
1293 //no Args
1295 } else if ( sf->name() == "zoom" ) {
1296 sb->ArgStack->raiseWidget( argZoom );
1297 bool ok(false);
1298 /*double z = */sf->argVal(0).toDouble(&ok);
1299 if (ok) argZoom->ZoomBox->setText( sf->argVal(0) );
1300 else argZoom->ZoomBox->setText( "2000." );
1302 } else if ( sf->name() == "exportImage" ) {
1303 sb->ArgStack->raiseWidget( argExportImage );
1304 argExportImage->ExportFileName->setURL( sf->argVal(0) );
1305 bool ok(false);
1306 int w, h;
1307 w = sf->argVal(1).toInt( &ok );
1308 if (ok) h = sf->argVal(2).toInt( &ok );
1309 if (ok) {
1310 argExportImage->ExportWidth->setValue( w );
1311 argExportImage->ExportHeight->setValue( h );
1312 } else {
1313 argExportImage->ExportWidth->setValue( ks->map()->width() );
1314 argExportImage->ExportHeight->setValue( ks->map()->height() );
1317 } else if ( sf->name() == "printImage" ) {
1318 if ( sf->argVal(0) == i18n( "true" ) ) argPrintImage->UsePrintDialog->setChecked( true );
1319 else argPrintImage->UsePrintDialog->setChecked( false );
1320 if ( sf->argVal(1) == i18n( "true" ) ) argPrintImage->UseChartColors->setChecked( true );
1321 else argPrintImage->UseChartColors->setChecked( false );
1323 } else if ( sf->name() == "setLocalTime" ) {
1324 sb->ArgStack->raiseWidget( argSetLocalTime );
1325 bool ok(false);
1326 int year, month, day, hour, min, sec;
1328 year = sf->argVal(0).toInt(&ok);
1329 if (ok) month = sf->argVal(1).toInt(&ok);
1330 if (ok) day = sf->argVal(2).toInt(&ok);
1331 if (ok) argSetLocalTime->DateBox->setDate( ExtDate( year, month, day ) );
1332 else argSetLocalTime->DateBox->setDate( ExtDate::currentDate() );
1334 hour = sf->argVal(3).toInt(&ok);
1335 if ( sf->argVal(3).isEmpty() ) ok = false;
1336 if (ok) min = sf->argVal(4).toInt(&ok);
1337 if (ok) sec = sf->argVal(5).toInt(&ok);
1338 if (ok) argSetLocalTime->TimeBox->setTime( QTime( hour, min, sec ) );
1339 else argSetLocalTime->TimeBox->setTime( QTime( QTime::currentTime() ) );
1341 } else if ( sf->name() == "waitFor" ) {
1342 sb->ArgStack->raiseWidget( argWaitFor );
1343 bool ok(false);
1344 int sec = sf->argVal(0).toInt(&ok);
1345 if (ok) argWaitFor->DelayBox->setValue( sec );
1346 else argWaitFor->DelayBox->setValue( 0 );
1348 } else if ( sf->name() == "waitForKey" ) {
1349 sb->ArgStack->raiseWidget( argWaitForKey );
1350 if ( sf->argVal(0).length()==1 || sf->argVal(0).lower() == "space" )
1351 argWaitForKey->WaitKeyEdit->setText( sf->argVal(0) );
1352 else argWaitForKey->WaitKeyEdit->setText( "" );
1354 } else if ( sf->name() == "setTracking" ) {
1355 sb->ArgStack->raiseWidget( argSetTracking );
1356 if ( sf->argVal(0) == i18n( "true" ) ) argSetTracking->CheckTrack->setChecked( true );
1357 else argSetTracking->CheckTrack->setChecked( false );
1359 } else if ( sf->name() == "changeViewOption" ) {
1360 sb->ArgStack->raiseWidget( argChangeViewOption );
1361 //find argVal(0) in the combobox...if it isn't there, it will select nothing
1362 argChangeViewOption->OptionName->setCurrentItem( sf->argVal(0) );
1363 argChangeViewOption->OptionValue->setText( sf->argVal(1) );
1365 } else if ( sf->name() == "setGeoLocation" ) {
1366 sb->ArgStack->raiseWidget( argSetGeoLocation );
1367 argSetGeoLocation->CityName->setText( sf->argVal(0) );
1368 argSetGeoLocation->ProvinceName->setText( sf->argVal(1) );
1369 argSetGeoLocation->CountryName->setText( sf->argVal(2) );
1371 } else if ( sf->name() == "setColor" ) {
1372 sb->ArgStack->raiseWidget( argSetColor );
1373 if ( sf->argVal(0).isEmpty() ) sf->setArg( 0, "SkyColor" ); //initialize default value
1374 argSetColor->ColorName->setCurrentItem( ks->data()->colorScheme()->nameFromKey( sf->argVal(0) ) );
1375 argSetColor->ColorValue->setColor( QColor( sf->argVal(1).remove('\\') ) );
1377 } else if ( sf->name() == "loadColorScheme" ) {
1378 sb->ArgStack->raiseWidget( argLoadColorScheme );
1379 argLoadColorScheme->SchemeList->setCurrentItem( argLoadColorScheme->SchemeList->findItem( sf->argVal(0).remove('\"'), 0 ) );
1381 } else if ( sf->name() == "stop" ) {
1382 sb->ArgStack->raiseWidget( argBlank );
1383 //no Args
1385 } else if ( sf->name() == "start" ) {
1386 sb->ArgStack->raiseWidget( argBlank );
1387 //no Args
1389 } else if ( sf->name() == "setClockScale" ) {
1390 sb->ArgStack->raiseWidget( argTimeScale );
1391 bool ok(false);
1392 double ts = sf->argVal(0).toDouble(&ok);
1393 if (ok) argTimeScale->TimeScale->tsbox()->changeScale( float(ts) );
1394 else argTimeScale->TimeScale->tsbox()->changeScale( 0.0 );
1397 else if (sf->name() == "startINDI") {
1398 sb->ArgStack->raiseWidget( argStartINDI);
1400 argStartINDI->deviceName->setText(sf->argVal(0));
1401 if (sf->argVal(1) == "true")
1402 argStartINDI->LocalButton->setChecked(true);
1403 else if (! sf->argVal(1).isEmpty())
1404 argStartINDI->LocalButton->setChecked(false);
1406 else if (sf->name() == "shutdownINDI") {
1407 sb->ArgStack->raiseWidget( argShutdownINDI);
1409 //if (sf->valid()) kdDebug() << "begin: shutdown is valid" << endl;
1410 if (sb->ReuseINDIDeviceName->isChecked())
1412 if (!sf->argVal(0).isEmpty())
1413 argShutdownINDI->deviceName->setText(sf->argVal(0));
1414 else if (argShutdownINDI->deviceName->text().isEmpty() || sf->argVal(0).isEmpty())
1415 argShutdownINDI->deviceName->setText(lastINDIDeviceName);
1416 else
1417 slotINDIShutdown();
1419 else argShutdownINDI->deviceName->setText(sf->argVal(0));
1421 //if (sf->valid()) kdDebug() << "end: shutdown is valid" << endl;
1423 else if (sf->name() == "switchINDI") {
1424 sb->ArgStack->raiseWidget( argSwitchINDI);
1426 if (sf->argVal(1) == "true" || sf->argVal(1).isEmpty())
1427 argSwitchINDI->OnButton->setChecked(true);
1428 else
1429 argSwitchINDI->OffButton->setChecked(true);
1431 argSwitchINDI->deviceName->clear();
1433 if (sb->ReuseINDIDeviceName->isChecked())
1435 if (!sf->argVal(0).isEmpty())
1436 argSwitchINDI->deviceName->setText(sf->argVal(0));
1437 else
1438 argSwitchINDI->deviceName->setText(lastINDIDeviceName);
1440 else argSwitchINDI->deviceName->setText(sf->argVal(0));
1443 else if (sf->name() == "setINDIPort") {
1444 sb->ArgStack->raiseWidget( argSetPortINDI);
1446 argSetPortINDI->devicePort->setText(sf->argVal(1));
1448 argSetPortINDI->deviceName->clear();
1450 if (sb->ReuseINDIDeviceName->isChecked())
1452 if (!sf->argVal(0).isEmpty())
1453 argSetPortINDI->deviceName->setText(sf->argVal(0));
1454 else
1455 argSetPortINDI->deviceName->setText(lastINDIDeviceName);
1457 else argSetPortINDI->deviceName->setText(sf->argVal(0));
1460 else if (sf->name() == "setINDITargetCoord") {
1461 bool ok(false);
1462 double r(0.0),d(0.0);
1463 dms ra(0.0);
1465 sb->ArgStack->raiseWidget( argSetTargetCoordINDI);
1467 ok = !sf->argVal(1).isEmpty();
1468 if (ok) r = sf->argVal(1).toDouble(&ok);
1469 else argSetTargetCoordINDI->RaBox->clear();
1470 if (ok) { ra.setH(r); argSetTargetCoordINDI->RaBox->showInHours( ra ); }
1472 ok = !sf->argVal(2).isEmpty();
1473 if (ok) d = sf->argVal(2).toDouble(&ok);
1474 else argSetTargetCoordINDI->DecBox->clear();
1475 if (ok) argSetTargetCoordINDI->DecBox->showInDegrees( dms(d) );
1477 argSetTargetCoordINDI->deviceName->clear();
1479 if (sb->ReuseINDIDeviceName->isChecked())
1481 if (!sf->argVal(0).isEmpty())
1482 argSetTargetCoordINDI->deviceName->setText(sf->argVal(0));
1483 else
1484 argSetTargetCoordINDI->deviceName->setText(lastINDIDeviceName);
1486 else argSetTargetCoordINDI->deviceName->setText(sf->argVal(0));
1489 else if (sf->name() == "setINDITargetName") {
1490 sb->ArgStack->raiseWidget( argSetTargetNameINDI);
1492 argSetTargetNameINDI->objectName->setText(sf->argVal(1));
1494 argSetTargetNameINDI->deviceName->clear();
1496 if (sb->ReuseINDIDeviceName->isChecked())
1498 if (!sf->argVal(0).isEmpty())
1499 argSetTargetNameINDI->deviceName->setText(sf->argVal(0));
1500 else
1501 argSetTargetNameINDI->deviceName->setText(lastINDIDeviceName);
1503 else argSetTargetNameINDI->deviceName->setText(sf->argVal(0));
1506 else if (sf->name() == "setINDIAction") {
1507 sb->ArgStack->raiseWidget( argSetActionINDI);
1509 argSetActionINDI->actionName->setText(sf->argVal(1));
1511 argSetActionINDI->deviceName->clear();
1513 if (sb->ReuseINDIDeviceName->isChecked())
1515 if (!sf->argVal(0).isEmpty())
1516 argSetActionINDI->deviceName->setText(sf->argVal(0));
1517 else
1518 argSetActionINDI->deviceName->setText(lastINDIDeviceName);
1520 else argSetActionINDI->deviceName->setText(sf->argVal(0));
1523 else if (sf->name() == "waitForINDIAction") {
1524 sb->ArgStack->raiseWidget( argWaitForActionINDI);
1526 argWaitForActionINDI->actionName->setText(sf->argVal(1));
1528 argWaitForActionINDI->deviceName->clear();
1530 if (sb->ReuseINDIDeviceName->isChecked())
1532 if (!sf->argVal(0).isEmpty())
1533 argWaitForActionINDI->deviceName->setText(sf->argVal(0));
1534 else
1535 argWaitForActionINDI->deviceName->setText(lastINDIDeviceName);
1537 else argWaitForActionINDI->deviceName->setText(sf->argVal(0));
1540 else if (sf->name() == "setINDIFocusSpeed") {
1541 sb->ArgStack->raiseWidget( argSetFocusSpeedINDI);
1542 bool itemSet(false);
1544 for (int i=0; i < argSetFocusSpeedINDI->speedCombo->count(); i++)
1546 if (argSetFocusSpeedINDI->speedCombo->text(i) == sf->argVal(1))
1548 argSetFocusSpeedINDI->speedCombo->setCurrentItem(i);
1549 itemSet = true;
1550 break;
1554 if (!itemSet) argSetFocusSpeedINDI->speedCombo->setCurrentItem(0);
1556 argSetFocusSpeedINDI->deviceName->clear();
1558 if (sb->ReuseINDIDeviceName->isChecked())
1560 if (!sf->argVal(0).isEmpty())
1561 argSetFocusSpeedINDI->deviceName->setText(sf->argVal(0));
1562 else
1563 argSetFocusSpeedINDI->deviceName->setText(lastINDIDeviceName);
1565 else argSetFocusSpeedINDI->deviceName->setText(sf->argVal(0));
1568 else if (sf->name() == "startINDIFocus") {
1569 sb->ArgStack->raiseWidget( argStartFocusINDI);
1570 bool itemSet(false);
1572 for (int i=0; i < argStartFocusINDI->directionCombo->count(); i++)
1574 if (argStartFocusINDI->directionCombo->text(i) == sf->argVal(1))
1576 argStartFocusINDI->directionCombo->setCurrentItem(i);
1577 itemSet = true;
1578 break;
1582 if (!itemSet) argStartFocusINDI->directionCombo->setCurrentItem(0);
1584 argStartFocusINDI->deviceName->clear();
1586 if (sb->ReuseINDIDeviceName->isChecked())
1588 if (!sf->argVal(0).isEmpty())
1589 argStartFocusINDI->deviceName->setText(sf->argVal(0));
1590 else
1591 argStartFocusINDI->deviceName->setText(lastINDIDeviceName);
1593 else argStartFocusINDI->deviceName->setText(sf->argVal(0));
1596 else if (sf->name() == "setINDIFocusTimeout") {
1597 int t(0);
1598 bool ok(false);
1600 sb->ArgStack->raiseWidget( argSetFocusTimeoutINDI);
1602 t = sf->argVal(1).toInt(&ok);
1603 if (ok) argSetFocusTimeoutINDI->timeOut->setValue(t);
1604 else argSetFocusTimeoutINDI->timeOut->setValue(0);
1606 argSetFocusTimeoutINDI->deviceName->clear();
1608 if (sb->ReuseINDIDeviceName->isChecked())
1610 if (!sf->argVal(0).isEmpty())
1611 argSetFocusTimeoutINDI->deviceName->setText(sf->argVal(0));
1612 else
1613 argSetFocusTimeoutINDI->deviceName->setText(lastINDIDeviceName);
1615 else argSetFocusTimeoutINDI->deviceName->setText(sf->argVal(0));
1618 else if (sf->name() == "setINDIGeoLocation") {
1619 bool ok(false);
1620 double lo(0.0),la(0.0);
1622 sb->ArgStack->raiseWidget( argSetGeoLocationINDI);
1624 ok = !sf->argVal(1).isEmpty();
1625 if (ok) lo = sf->argVal(1).toDouble(&ok);
1626 else argSetGeoLocationINDI->longBox->clear();
1627 if (ok) { argSetGeoLocationINDI->longBox->showInDegrees( dms(lo) ); }
1629 ok = !sf->argVal(2).isEmpty();
1630 if (ok) la = sf->argVal(2).toDouble(&ok);
1631 else argSetGeoLocationINDI->latBox->clear();
1632 if (ok) argSetGeoLocationINDI->latBox->showInDegrees( dms(la) );
1634 argSetGeoLocationINDI->deviceName->clear();
1636 if (sb->ReuseINDIDeviceName->isChecked())
1638 if (!sf->argVal(0).isEmpty())
1639 argSetGeoLocationINDI->deviceName->setText(sf->argVal(0));
1640 else
1641 argSetGeoLocationINDI->deviceName->setText(lastINDIDeviceName);
1643 else argSetGeoLocationINDI->deviceName->setText(sf->argVal(0));
1646 else if (sf->name() == "startINDIExposure") {
1647 int t(0);
1648 bool ok(false);
1650 sb->ArgStack->raiseWidget( argStartExposureINDI);
1652 t = sf->argVal(1).toInt(&ok);
1653 if (ok) argStartExposureINDI->timeOut->setValue(t);
1654 else argStartExposureINDI->timeOut->setValue(0);
1656 argStartExposureINDI->deviceName->clear();
1658 if (sb->ReuseINDIDeviceName->isChecked())
1660 if (!sf->argVal(0).isEmpty())
1661 argStartExposureINDI->deviceName->setText(sf->argVal(0));
1662 else
1663 argStartExposureINDI->deviceName->setText(lastINDIDeviceName);
1665 else argStartExposureINDI->deviceName->setText(sf->argVal(0));
1668 else if (sf->name() == "setINDIUTC") {
1669 sb->ArgStack->raiseWidget( argSetUTCINDI);
1671 argSetUTCINDI->UTC->setText(sf->argVal(1));
1673 argSetUTCINDI->deviceName->clear();
1675 if (sb->ReuseINDIDeviceName->isChecked())
1677 if (!sf->argVal(0).isEmpty())
1678 argSetUTCINDI->deviceName->setText(sf->argVal(0));
1679 else
1680 argSetUTCINDI->deviceName->setText(lastINDIDeviceName);
1682 else argSetUTCINDI->deviceName->setText(sf->argVal(0));
1685 else if (sf->name() == "setINDIScopeAction") {
1686 sb->ArgStack->raiseWidget( argSetScopeActionINDI);
1687 bool itemSet(false);
1689 for (int i=0; i < argSetScopeActionINDI->actionCombo->count(); i++)
1691 if (argSetScopeActionINDI->actionCombo->text(i) == sf->argVal(1))
1693 argSetScopeActionINDI->actionCombo->setCurrentItem(i);
1694 itemSet = true;
1695 break;
1699 if (!itemSet) argSetScopeActionINDI->actionCombo->setCurrentItem(0);
1701 argSetScopeActionINDI->deviceName->clear();
1703 if (sb->ReuseINDIDeviceName->isChecked())
1705 if (!sf->argVal(0).isEmpty())
1706 argSetScopeActionINDI->deviceName->setText(sf->argVal(0));
1707 else
1708 argSetScopeActionINDI->deviceName->setText(lastINDIDeviceName);
1710 else argSetScopeActionINDI->deviceName->setText(sf->argVal(0));
1713 else if (sf->name() == "setINDIFrameType") {
1714 sb->ArgStack->raiseWidget( argSetFrameTypeINDI);
1715 bool itemSet(false);
1717 for (int i=0; i < argSetFrameTypeINDI->typeCombo->count(); i++)
1719 if (argSetFrameTypeINDI->typeCombo->text(i) == sf->argVal(1))
1721 argSetFrameTypeINDI->typeCombo->setCurrentItem(i);
1722 itemSet = true;
1723 break;
1727 if (!itemSet) argSetFrameTypeINDI->typeCombo->setCurrentItem(0);
1729 argSetFrameTypeINDI->deviceName->clear();
1731 if (sb->ReuseINDIDeviceName->isChecked())
1733 if (!sf->argVal(0).isEmpty())
1734 argSetFrameTypeINDI->deviceName->setText(sf->argVal(0));
1735 else
1736 argSetFrameTypeINDI->deviceName->setText(lastINDIDeviceName);
1738 else argSetFrameTypeINDI->deviceName->setText(sf->argVal(0));
1741 else if (sf->name() == "setINDICCDTemp") {
1742 int t(0);
1743 bool ok(false);
1745 sb->ArgStack->raiseWidget( argSetCCDTempINDI);
1747 t = sf->argVal(1).toInt(&ok);
1748 if (ok) argSetCCDTempINDI->temp->setValue(t);
1749 else argSetCCDTempINDI->temp->setValue(0);
1751 argSetCCDTempINDI->deviceName->clear();
1753 if (sb->ReuseINDIDeviceName->isChecked())
1755 if (!sf->argVal(0).isEmpty())
1756 argSetCCDTempINDI->deviceName->setText(sf->argVal(0));
1757 else
1758 argSetCCDTempINDI->deviceName->setText(lastINDIDeviceName);
1760 else argSetCCDTempINDI->deviceName->setText(sf->argVal(0));
1763 else if (sf->name() == "setINDIFilterNum") {
1764 int t(0);
1765 bool ok(false);
1767 sb->ArgStack->raiseWidget( argSetFilterNumINDI);
1769 t = sf->argVal(1).toInt(&ok);
1770 if (ok) argSetFilterNumINDI->filter_num->setValue(t);
1771 else argSetFilterNumINDI->filter_num->setValue(0);
1773 argSetFilterNumINDI->deviceName->clear();
1775 if (sb->ReuseINDIDeviceName->isChecked())
1777 if (!sf->argVal(0).isEmpty())
1778 argSetFilterNumINDI->deviceName->setText(sf->argVal(0));
1779 else
1780 argSetFilterNumINDI->deviceName->setText(lastINDIDeviceName);
1782 else argSetFilterNumINDI->deviceName->setText(sf->argVal(0));
1788 void ScriptBuilder::slotShowDoc() {
1789 ScriptFunction *sc = NULL;
1790 QListViewItem *currentItem = sb->FunctionListView->currentItem();
1792 if ( currentItem == NULL || currentItem->depth() == 0)
1793 return;
1795 for (sc = KStarsFunctionList.first(); sc; sc = KStarsFunctionList.next())
1796 if (sc->prototype() == currentItem->text(0))
1797 break;
1799 if (sc == NULL)
1801 for (sc = INDIFunctionList.first(); sc; sc = INDIFunctionList.next())
1802 if (sc->prototype() == currentItem->text(0))
1803 break;
1806 if (sc == NULL)
1808 sb->AddButton->setEnabled( false );
1809 kdWarning() << i18n( "Function index out of bounds." ) << endl;
1810 return;
1813 sb->AddButton->setEnabled( true );
1814 sb->FuncDoc->setText( sc->description() );
1817 //Slots for Arg Widgets
1818 void ScriptBuilder::slotFindCity() {
1819 LocationDialog ld( ks );
1821 if ( ld.exec() == QDialog::Accepted ) {
1822 if ( ld.selectedCity() ) {
1823 // set new location names
1824 argSetGeoLocation->CityName->setText( ld.selectedCityName() );
1825 argSetGeoLocation->ProvinceName->setText( ld.selectedProvinceName() );
1826 argSetGeoLocation->CountryName->setText( ld.selectedCountryName() );
1828 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
1829 if ( sf->name() == "setGeoLocation" ) {
1830 setUnsavedChanges( true );
1832 sf->setArg( 0, ld.selectedCityName() );
1833 sf->setArg( 1, ld.selectedProvinceName() );
1834 sf->setArg( 2, ld.selectedCountryName() );
1835 } else {
1836 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
1842 void ScriptBuilder::slotFindObject() {
1843 FindDialog fd( ks );
1845 if ( fd.exec() == QDialog::Accepted && fd.currentItem() ) {
1846 setUnsavedChanges( true );
1848 argLookToward->FocusEdit->setCurrentText( fd.currentItem()->objName()->text() );
1852 void ScriptBuilder::slotINDIFindObject() {
1853 FindDialog fd( ks );
1855 if ( fd.exec() == QDialog::Accepted && fd.currentItem() ) {
1856 setUnsavedChanges( true );
1858 argSetTargetNameINDI->objectName->setText( fd.currentItem()->objName()->text() );
1862 void ScriptBuilder::slotINDIWaitCheck(bool /*toggleState*/)
1865 setUnsavedChanges(true);
1869 void ScriptBuilder::slotShowOptions() {
1870 //Show tree-view of view options
1871 if ( otv->exec() == QDialog::Accepted ) {
1872 argChangeViewOption->OptionName->setCurrentItem( otv->OptionsList->currentItem()->text(0) );
1876 void ScriptBuilder::slotLookToward() {
1877 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
1879 if ( sf->name() == "lookTowards" ) {
1880 setUnsavedChanges( true );
1882 sf->setArg( 0, argLookToward->FocusEdit->currentText() );
1883 sf->setValid(true);
1884 } else {
1885 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "lookTowards" ) << endl;
1889 void ScriptBuilder::slotRa() {
1890 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
1892 if ( sf->name() == "setRaDec" ) {
1893 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
1894 if ( argSetRaDec->RaBox->text().isEmpty() ) return;
1896 bool ok(false);
1897 dms ra = argSetRaDec->RaBox->createDms(false, &ok);
1898 if ( ok ) {
1899 setUnsavedChanges( true );
1901 sf->setArg( 0, QString( "%1" ).arg( ra.Hours() ) );
1902 if ( ! sf->argVal(1).isEmpty() ) sf->setValid( true );
1904 } else {
1905 sf->setArg( 0, "" );
1906 sf->setValid( false );
1908 } else {
1909 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setRaDec" ) << endl;
1913 void ScriptBuilder::slotDec() {
1914 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
1916 if ( sf->name() == "setRaDec" ) {
1917 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
1918 if ( argSetRaDec->DecBox->text().isEmpty() ) return;
1920 bool ok(false);
1921 dms dec = argSetRaDec->DecBox->createDms(true, &ok);
1922 if ( ok ) {
1923 setUnsavedChanges( true );
1925 sf->setArg( 1, QString( "%1" ).arg( dec.Degrees() ) );
1926 if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
1928 } else {
1929 sf->setArg( 1, "" );
1930 sf->setValid( false );
1932 } else {
1933 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setRaDec" ) << endl;
1937 void ScriptBuilder::slotAz() {
1938 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
1940 if ( sf->name() == "setAltAz" ) {
1941 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
1942 if ( argSetAltAz->AzBox->text().isEmpty() ) return;
1944 bool ok(false);
1945 dms az = argSetAltAz->AzBox->createDms(true, &ok);
1946 if ( ok ) {
1947 setUnsavedChanges( true );
1948 sf->setArg( 1, QString( "%1" ).arg( az.Degrees() ) );
1949 if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
1950 } else {
1951 sf->setArg( 1, "" );
1952 sf->setValid( false );
1954 } else {
1955 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setAltAz" ) << endl;
1959 void ScriptBuilder::slotAlt() {
1960 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
1962 if ( sf->name() == "setAltAz" ) {
1963 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
1964 if ( argSetAltAz->AltBox->text().isEmpty() ) return;
1966 bool ok(false);
1967 dms alt = argSetAltAz->AltBox->createDms(true, &ok);
1968 if ( ok ) {
1969 setUnsavedChanges( true );
1971 sf->setArg( 0, QString( "%1" ).arg( alt.Degrees() ) );
1972 if ( ! sf->argVal(1).isEmpty() ) sf->setValid( true );
1973 } else {
1974 sf->setArg( 0, "" );
1975 sf->setValid( false );
1977 } else {
1978 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setAltAz" ) << endl;
1982 void ScriptBuilder::slotChangeDate() {
1983 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
1985 if ( sf->name() == "setLocalTime" ) {
1986 setUnsavedChanges( true );
1988 ExtDate date = argSetLocalTime->DateBox->date();
1990 sf->setArg( 0, QString( "%1" ).arg( date.year() ) );
1991 sf->setArg( 1, QString( "%1" ).arg( date.month() ) );
1992 sf->setArg( 2, QString( "%1" ).arg( date.day() ) );
1993 if ( ! sf->argVal(3).isEmpty() ) sf->setValid( true );
1994 } else {
1995 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setLocalTime" ) << endl;
1999 void ScriptBuilder::slotChangeTime() {
2000 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2002 if ( sf->name() == "setLocalTime" ) {
2003 setUnsavedChanges( true );
2005 QTime time = argSetLocalTime->TimeBox->time();
2007 sf->setArg( 3, QString( "%1" ).arg( time.hour() ) );
2008 sf->setArg( 4, QString( "%1" ).arg( time.minute() ) );
2009 sf->setArg( 5, QString( "%1" ).arg( time.second() ) );
2010 if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
2011 } else {
2012 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setLocalTime" ) << endl;
2016 void ScriptBuilder::slotWaitFor() {
2017 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2019 if ( sf->name() == "waitFor" ) {
2020 bool ok(false);
2021 int delay = argWaitFor->DelayBox->text().toInt( &ok );
2023 if ( ok ) {
2024 setUnsavedChanges( true );
2026 sf->setArg( 0, QString( "%1" ).arg( delay ) );
2027 sf->setValid( true );
2028 } else {
2029 sf->setValid( false );
2031 } else {
2032 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitFor" ) << endl;
2036 void ScriptBuilder::slotWaitForKey() {
2037 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2039 if ( sf->name() == "waitForKey" ) {
2040 QString sKey = argWaitForKey->WaitKeyEdit->text().stripWhiteSpace();
2042 //DCOP script can only use single keystrokes; make sure entry is either one character,
2043 //or the word 'space'
2044 if ( sKey.length() == 1 || sKey == "space" ) {
2045 setUnsavedChanges( true );
2047 sf->setArg( 0, sKey );
2048 sf->setValid( true );
2049 } else {
2050 sf->setValid( false );
2052 } else {
2053 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitForKey" ) << endl;
2057 void ScriptBuilder::slotTracking() {
2058 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2060 if ( sf->name() == "setTracking" ) {
2061 setUnsavedChanges( true );
2063 sf->setArg( 0, ( argSetTracking->CheckTrack->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
2064 sf->setValid( true );
2065 } else {
2066 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setTracking" ) << endl;
2070 void ScriptBuilder::slotViewOption() {
2071 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2073 if ( sf->name() == "changeViewOption" ) {
2074 if ( argChangeViewOption->OptionName->currentItem() >= 0
2075 && argChangeViewOption->OptionValue->text().length() ) {
2076 setUnsavedChanges( true );
2078 sf->setArg( 0, argChangeViewOption->OptionName->currentText() );
2079 sf->setArg( 1, argChangeViewOption->OptionValue->text() );
2080 sf->setValid( true );
2081 } else {
2082 sf->setValid( false );
2084 } else {
2085 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "changeViewOption" ) << endl;
2089 void ScriptBuilder::slotChangeCity() {
2090 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2092 if ( sf->name() == "setGeoLocation" ) {
2093 QString city = argSetGeoLocation->CityName->text();
2095 if ( city.length() ) {
2096 setUnsavedChanges( true );
2098 sf->setArg( 0, city );
2099 if ( sf->argVal(2).length() ) sf->setValid( true );
2100 } else {
2101 sf->setArg( 0, "" );
2102 sf->setValid( false );
2104 } else {
2105 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
2109 void ScriptBuilder::slotChangeProvince() {
2110 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2112 if ( sf->name() == "setGeoLocation" ) {
2113 QString province = argSetGeoLocation->ProvinceName->text();
2115 if ( province.length() ) {
2116 setUnsavedChanges( true );
2118 sf->setArg( 1, province );
2119 if ( sf->argVal(0).length() && sf->argVal(2).length() ) sf->setValid( true );
2120 } else {
2121 sf->setArg( 1, "" );
2122 //might not be invalid
2124 } else {
2125 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
2129 void ScriptBuilder::slotChangeCountry() {
2130 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2132 if ( sf->name() == "setGeoLocation" ) {
2133 QString country = argSetGeoLocation->CountryName->text();
2135 if ( country.length() ) {
2136 setUnsavedChanges( true );
2138 sf->setArg( 2, country );
2139 if ( sf->argVal(0).length() ) sf->setValid( true );
2140 } else {
2141 sf->setArg( 2, "" );
2142 sf->setValid( false );
2144 } else {
2145 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setGeoLocation" ) << endl;
2149 void ScriptBuilder::slotTimeScale() {
2150 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2152 if ( sf->name() == "setClockScale" ) {
2153 setUnsavedChanges( true );
2155 sf->setArg( 0, QString( "%1" ).arg( argTimeScale->TimeScale->tsbox()->timeScale() ) );
2156 sf->setValid( true );
2157 } else {
2158 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setClockScale" ) << endl;
2162 void ScriptBuilder::slotZoom() {
2163 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2165 if ( sf->name() == "zoom" ) {
2166 setUnsavedChanges( true );
2168 bool ok(false);
2169 argZoom->ZoomBox->text().toDouble(&ok);
2170 if ( ok ) {
2171 sf->setArg( 0, argZoom->ZoomBox->text() );
2172 sf->setValid( true );
2174 } else {
2175 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "zoom" ) << endl;
2179 void ScriptBuilder::slotExportImage() {
2180 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2182 if ( sf->name() == "exportImage" ) {
2183 setUnsavedChanges( true );
2185 sf->setArg( 0, argExportImage->ExportFileName->url() );
2186 sf->setArg( 1, QString("%1").arg( argExportImage->ExportWidth->value() ) );
2187 sf->setArg( 2, QString("%1").arg( argExportImage->ExportHeight->value() ) );
2188 sf->setValid( true );
2189 } else {
2190 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "exportImage" ) << endl;
2194 void ScriptBuilder::slotPrintImage() {
2195 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2197 if ( sf->name() == "printImage" ) {
2198 setUnsavedChanges( true );
2200 sf->setArg( 0, ( argPrintImage->UsePrintDialog->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
2201 sf->setArg( 1, ( argPrintImage->UseChartColors->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
2202 sf->setValid( true );
2203 } else {
2204 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "exportImage" ) << endl;
2208 void ScriptBuilder::slotChangeColorName() {
2209 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2211 if ( sf->name() == "setColor" ) {
2212 setUnsavedChanges( true );
2214 argSetColor->ColorValue->setColor( ks->data()->colorScheme()->colorAt( argSetColor->ColorName->currentItem() ) );
2215 sf->setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentItem() ) );
2216 QString cname( argSetColor->ColorValue->color().name() );
2217 if ( cname.at(0) == '#' ) cname = "\\" + cname; //prepend a "\" so bash doesn't think we have a comment
2218 sf->setArg( 1, cname );
2219 sf->setValid( true );
2220 } else {
2221 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setColor" ) << endl;
2225 void ScriptBuilder::slotChangeColor() {
2226 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2228 if ( sf->name() == "setColor" ) {
2229 setUnsavedChanges( true );
2231 sf->setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentItem() ) );
2232 QString cname( argSetColor->ColorValue->color().name() );
2233 if ( cname.at(0) == '#' ) cname = "\\" + cname; //prepend a "\" so bash doesn't think we have a comment
2234 sf->setArg( 1, cname );
2235 sf->setValid( true );
2236 } else {
2237 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setColor" ) << endl;
2241 void ScriptBuilder::slotLoadColorScheme(QListBoxItem */*i*/) {
2242 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2244 if ( sf->name() == "loadColorScheme" ) {
2245 setUnsavedChanges( true );
2247 sf->setArg( 0, "\"" + argLoadColorScheme->SchemeList->currentText() + "\"" );
2248 sf->setValid( true );
2249 } else {
2250 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "loadColorScheme" ) << endl;
2254 void ScriptBuilder::slotClose() {
2255 saveWarning();
2257 if ( !UnsavedChanges ) {
2258 emit closeClicked();
2259 reject();
2263 void ScriptBuilder::slotINDIStartDeviceName()
2265 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2267 if ( sf->name() == "startINDI" )
2269 setUnsavedChanges( true );
2271 lastINDIDeviceName = argStartINDI->deviceName->text();
2273 sf->setArg(0, lastINDIDeviceName);
2274 sf->setArg(1, argStartINDI->LocalButton->isChecked() ? "true" : "false");
2275 sf->setValid(true);
2277 else
2279 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDI" ) << endl;
2284 void ScriptBuilder::slotINDIStartDeviceMode()
2287 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2289 if ( sf->name() == "startINDI" )
2291 setUnsavedChanges( true );
2293 sf->setArg(1, argStartINDI->LocalButton->isChecked() ? "true" : "false");
2294 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
2296 else
2298 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDI" ) << endl;
2303 void ScriptBuilder::slotINDIShutdown()
2306 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2308 if ( sf->name() == "shutdownINDI" )
2310 if (argShutdownINDI->deviceName->text().isEmpty())
2312 sf->setValid(false);
2313 return;
2316 if (sf->argVal(0) != argShutdownINDI->deviceName->text())
2317 setUnsavedChanges( true );
2319 sf->setArg(0, argShutdownINDI->deviceName->text());
2320 sf->setValid(true);
2322 else
2324 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "shutdownINDI" ) << endl;
2329 void ScriptBuilder::slotINDISwitchDeviceName()
2331 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2333 if ( sf->name() == "switchINDI" )
2335 if (argSwitchINDI->deviceName->text().isEmpty())
2337 sf->setValid(false);
2338 return;
2341 if (sf->argVal(0) != argSwitchINDI->deviceName->text())
2342 setUnsavedChanges( true );
2344 sf->setArg(0, argSwitchINDI->deviceName->text());
2345 sf->setArg(1, argSwitchINDI->OnButton->isChecked() ? "true" : "false");
2346 sf->setValid(true);
2348 else
2350 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "switchdownINDI" ) << endl;
2355 void ScriptBuilder::slotINDISwitchDeviceConnection()
2358 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2360 if ( sf->name() == "switchINDI" )
2363 if (sf->argVal(1) != (argSwitchINDI->OnButton->isChecked() ? "true" : "false"))
2364 setUnsavedChanges( true );
2366 sf->setArg(1, argSwitchINDI->OnButton->isChecked() ? "true" : "false");
2367 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
2368 else sf->setValid(false);
2370 else
2372 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "switchINDI" ) << endl;
2377 void ScriptBuilder::slotINDISetPortDeviceName()
2380 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2382 if ( sf->name() == "setINDIPort" )
2384 if (argSetPortINDI->deviceName->text().isEmpty())
2386 sf->setValid(false);
2387 return;
2390 if (sf->argVal(0) != argSetPortINDI->deviceName->text())
2391 setUnsavedChanges( true );
2393 sf->setArg(0, argSetPortINDI->deviceName->text());
2394 if (! sf->argVal(1).isEmpty()) sf->setValid(true);
2395 else sf->setValid(false);
2398 else
2400 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIPort" ) << endl;
2406 void ScriptBuilder::slotINDISetPortDevicePort()
2408 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2410 if ( sf->name() == "setINDIPort" )
2413 if (argSetPortINDI->devicePort->text().isEmpty())
2415 sf->setValid(false);
2416 return;
2419 if (sf->argVal(1) != argSetPortINDI->devicePort->text())
2420 setUnsavedChanges( true );
2422 sf->setArg(1, argSetPortINDI->devicePort->text());
2423 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
2424 else sf->setValid(false);
2426 else
2428 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIPort" ) << endl;
2433 void ScriptBuilder::slotINDISetTargetCoordDeviceName()
2435 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2437 if ( sf->name() == "setINDITargetCoord" )
2439 if (argSetTargetCoordINDI->deviceName->text().isEmpty())
2441 sf->setValid(false);
2442 return;
2445 if (sf->argVal(0) != argSetTargetCoordINDI->deviceName->text())
2446 setUnsavedChanges( true );
2448 sf->setArg(0, argSetTargetCoordINDI->deviceName->text());
2449 if ((! sf->argVal(1).isEmpty()) && (! sf->argVal(2).isEmpty())) sf->setValid(true);
2450 else sf->setValid(false);
2452 else
2454 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetCoord" ) << endl;
2459 void ScriptBuilder::slotINDISetTargetCoordDeviceRA()
2461 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2463 if ( sf->name() == "setINDITargetCoord" ) {
2464 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2465 if ( argSetTargetCoordINDI->RaBox->text().isEmpty() )
2467 sf->setValid(false);
2468 return;
2471 bool ok(false);
2472 dms ra = argSetTargetCoordINDI->RaBox->createDms(false, &ok);
2473 if ( ok ) {
2475 if (sf->argVal(1) != QString( "%1" ).arg( ra.Hours() ))
2476 setUnsavedChanges( true );
2478 sf->setArg( 1, QString( "%1" ).arg( ra.Hours() ) );
2479 if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(2).isEmpty() )) sf->setValid( true );
2480 else sf->setValid(false);
2482 } else {
2483 sf->setArg( 1, "" );
2484 sf->setValid( false );
2486 } else {
2487 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetCoord" ) << endl;
2492 void ScriptBuilder::slotINDISetTargetCoordDeviceDEC()
2494 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2496 if ( sf->name() == "setINDITargetCoord" ) {
2497 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2498 if ( argSetTargetCoordINDI->DecBox->text().isEmpty() )
2500 sf->setValid(false);
2501 return;
2504 bool ok(false);
2505 dms dec = argSetTargetCoordINDI->DecBox->createDms(true, &ok);
2506 if ( ok ) {
2508 if (sf->argVal(2) != QString( "%1" ).arg( dec.Degrees() ))
2509 setUnsavedChanges( true );
2511 sf->setArg( 2, QString( "%1" ).arg( dec.Degrees() ) );
2512 if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(1).isEmpty() )) sf->setValid( true );
2513 else sf->setValid(false);
2515 } else {
2516 sf->setArg( 2, "" );
2517 sf->setValid( false );
2519 } else {
2520 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetCoord" ) << endl;
2525 void ScriptBuilder::slotINDISetTargetNameDeviceName()
2528 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2530 if ( sf->name() == "setINDITargetName" )
2532 if (argSetTargetNameINDI->deviceName->text().isEmpty())
2534 sf->setValid(false);
2535 return;
2538 if (sf->argVal(0) != argSetTargetNameINDI->deviceName->text())
2539 setUnsavedChanges( true );
2541 sf->setArg(0, argSetTargetNameINDI->deviceName->text());
2542 if ((! sf->argVal(1).isEmpty())) sf->setValid(true);
2543 else sf->setValid(false);
2545 else
2547 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetName" ) << endl;
2552 void ScriptBuilder::slotINDISetTargetNameObjectName()
2555 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2557 if ( sf->name() == "setINDITargetName" )
2559 if (argSetTargetNameINDI->objectName->text().isEmpty())
2561 sf->setValid(false);
2562 return;
2565 if (sf->argVal(1) != argSetTargetNameINDI->objectName->text())
2566 setUnsavedChanges( true );
2568 sf->setArg(1, argSetTargetNameINDI->objectName->text());
2569 if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
2570 else sf->setValid(false);
2572 else
2574 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDITargetName" ) << endl;
2579 void ScriptBuilder::slotINDISetActionDeviceName()
2582 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2584 if ( sf->name() == "setINDIAction" )
2586 if (argSetActionINDI->deviceName->text().isEmpty())
2588 sf->setValid(false);
2589 return;
2592 if (sf->argVal(0) != argSetActionINDI->deviceName->text())
2593 setUnsavedChanges( true );
2595 sf->setArg(0, argSetActionINDI->deviceName->text());
2596 if ((! sf->argVal(1).isEmpty())) sf->setValid(true);
2597 else sf->setValid(false);
2599 else
2601 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIAction") << endl;
2606 void ScriptBuilder::slotINDISetActionName()
2608 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2610 if ( sf->name() == "setINDIAction" )
2612 if (argSetActionINDI->actionName->text().isEmpty())
2614 sf->setValid(false);
2615 return;
2618 if (sf->argVal(1) != argSetActionINDI->actionName->text())
2619 setUnsavedChanges( true );
2621 sf->setArg(1, argSetActionINDI->actionName->text());
2622 if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
2623 else sf->setValid(false);
2625 else
2627 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIAction") << endl;
2632 void ScriptBuilder::slotINDIWaitForActionDeviceName()
2635 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2637 if ( sf->name() == "waitForINDIAction" )
2639 if (argWaitForActionINDI->deviceName->text().isEmpty())
2641 return;
2642 sf->setValid(false);
2645 if (sf->argVal(0) != argWaitForActionINDI->deviceName->text())
2646 setUnsavedChanges( true );
2648 sf->setArg(0, argWaitForActionINDI->deviceName->text());
2649 if ((! sf->argVal(1).isEmpty())) sf->setValid(true);
2650 else sf->setValid(false);
2652 else
2654 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitForINDIAction") << endl;
2659 void ScriptBuilder::slotINDIWaitForActionName()
2661 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2663 if ( sf->name() == "waitForINDIAction" )
2665 if (argWaitForActionINDI->actionName->text().isEmpty())
2667 sf->setValid(false);
2668 return;
2671 if (sf->argVal(1) != argWaitForActionINDI->actionName->text())
2672 setUnsavedChanges( true );
2674 sf->setArg(1, argWaitForActionINDI->actionName->text());
2675 if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
2676 else sf->setValid(false);
2678 else
2680 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "waitForINDIAction") << endl;
2685 void ScriptBuilder::slotINDISetFocusSpeedDeviceName()
2687 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2689 if ( sf->name() == "setINDIFocusSpeed" )
2691 if (argSetFocusSpeedINDI->deviceName->text().isEmpty())
2693 sf->setValid(false);
2694 return;
2697 if (sf->argVal(0) != argSetFocusSpeedINDI->deviceName->text())
2698 setUnsavedChanges( true );
2700 sf->setArg(0, argSetFocusSpeedINDI->deviceName->text());
2701 sf->setArg(1, argSetFocusSpeedINDI->speedCombo->currentText());
2702 sf->setValid(true);
2704 else
2706 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusSpeed") << endl;
2711 void ScriptBuilder::slotINDISetFocusSpeed()
2713 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2715 if ( sf->name() == "setINDIFocusSpeed" )
2718 if (sf->argVal(1) != argSetFocusSpeedINDI->speedCombo->currentText())
2719 setUnsavedChanges( true );
2721 sf->setArg(1, argSetFocusSpeedINDI->speedCombo->currentText());
2722 if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
2723 else sf->setValid(false);
2725 else
2727 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusSpeed") << endl;
2732 void ScriptBuilder::slotINDIStartFocusDeviceName()
2734 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2736 if ( sf->name() == "startINDIFocus" )
2738 if (argStartFocusINDI->deviceName->text().isEmpty())
2740 sf->setValid(false);
2741 return;
2744 if (sf->argVal(0) != argStartFocusINDI->deviceName->text())
2745 setUnsavedChanges( true );
2747 sf->setArg(0, argStartFocusINDI->deviceName->text());
2748 sf->setArg(1, argStartFocusINDI->directionCombo->currentText());
2749 sf->setValid(true);
2751 else
2753 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "StartINDIFocus") << endl;
2759 void ScriptBuilder::slotINDIStartFocusDirection()
2761 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2763 if ( sf->name() == "startINDIFocus" )
2765 if (sf->argVal(1) != argStartFocusINDI->directionCombo->currentText())
2766 setUnsavedChanges( true );
2768 sf->setArg(1, argStartFocusINDI->directionCombo->currentText());
2769 if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
2770 else sf->setValid(false);
2772 else
2774 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDIFocus") << endl;
2779 void ScriptBuilder::slotINDISetFocusTimeoutDeviceName()
2781 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2783 if ( sf->name() == "setINDIFocusTimeout" )
2785 if (argSetFocusTimeoutINDI->deviceName->text().isEmpty())
2787 sf->setValid(false);
2788 return;
2791 if (sf->argVal(0) != argSetFocusTimeoutINDI->deviceName->text())
2792 setUnsavedChanges( true );
2794 sf->setArg(0, argSetFocusTimeoutINDI->deviceName->text());
2795 sf->setArg(1, QString("%1").arg(argSetFocusTimeoutINDI->timeOut->value()));
2796 sf->setValid(true);
2798 else
2800 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusTimeout") << endl;
2805 void ScriptBuilder::slotINDISetFocusTimeout()
2807 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2809 if ( sf->name() == "setINDIFocusTimeout" )
2811 if (sf->argVal(1).toInt() != argSetFocusTimeoutINDI->timeOut->value())
2812 setUnsavedChanges( true );
2814 sf->setArg(1, QString("%1").arg(argSetFocusTimeoutINDI->timeOut->value()));
2815 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
2816 else sf->setValid(false);
2818 else
2820 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFocusTimeout") << endl;
2825 void ScriptBuilder::slotINDISetGeoLocationDeviceName()
2827 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2829 if ( sf->name() == "setINDIGeoLocation" )
2831 if (argSetGeoLocationINDI->deviceName->text().isEmpty())
2833 sf->setValid(false);
2834 return;
2837 if (sf->argVal(0) != argSetGeoLocationINDI->deviceName->text())
2838 setUnsavedChanges( true );
2840 sf->setArg(0, argSetGeoLocationINDI->deviceName->text());
2841 if ((! sf->argVal(1).isEmpty()) && (! sf->argVal(2).isEmpty())) sf->setValid(true);
2842 else sf->setValid(false);
2844 else
2846 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIGeoLocation" ) << endl;
2851 void ScriptBuilder::slotINDISetGeoLocationDeviceLong()
2853 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2855 if ( sf->name() == "setINDIGeoLocation" ) {
2856 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2857 if ( argSetGeoLocationINDI->longBox->text().isEmpty())
2859 sf->setValid(false);
2860 return;
2863 bool ok(false);
2864 dms longitude = argSetGeoLocationINDI->longBox->createDms(true, &ok);
2865 if ( ok ) {
2867 if (sf->argVal(1) != QString( "%1" ).arg( longitude.Degrees()))
2868 setUnsavedChanges( true );
2870 sf->setArg( 1, QString( "%1" ).arg( longitude.Degrees() ) );
2871 if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(2).isEmpty() )) sf->setValid( true );
2872 else sf->setValid(false);
2874 } else {
2875 sf->setArg( 1, "" );
2876 sf->setValid( false );
2878 } else {
2879 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIGeoLocation" ) << endl;
2884 void ScriptBuilder::slotINDISetGeoLocationDeviceLat()
2886 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2888 if ( sf->name() == "setINDIGeoLocation" ) {
2889 //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2890 if ( argSetGeoLocationINDI->latBox->text().isEmpty() )
2892 sf->setValid(false);
2893 return;
2896 bool ok(false);
2897 dms latitude = argSetGeoLocationINDI->latBox->createDms(true, &ok);
2898 if ( ok ) {
2900 if (sf->argVal(2) != QString( "%1" ).arg( latitude.Degrees()))
2901 setUnsavedChanges( true );
2903 sf->setArg( 2, QString( "%1" ).arg( latitude.Degrees() ) );
2904 if ( ( ! sf->argVal(0).isEmpty() ) && ( ! sf->argVal(1).isEmpty() )) sf->setValid( true );
2905 else sf->setValid(false);
2907 } else {
2908 sf->setArg( 2, "" );
2909 sf->setValid( false );
2911 } else {
2912 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIGeoLocation" ) << endl;
2917 void ScriptBuilder::slotINDIStartExposureDeviceName()
2919 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2921 if ( sf->name() == "startINDIExposure" )
2923 if (argStartExposureINDI->deviceName->text().isEmpty())
2925 sf->setValid(false);
2926 return;
2929 if (sf->argVal(0) != argStartExposureINDI->deviceName->text())
2930 setUnsavedChanges( true );
2932 sf->setArg(0, argStartExposureINDI->deviceName->text());
2933 sf->setArg(1, QString("%1").arg(argStartExposureINDI->timeOut->value()));
2934 sf->setValid(true);
2936 else
2938 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDIExposure") << endl;
2943 void ScriptBuilder::slotINDIStartExposureTimeout()
2945 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2947 if ( sf->name() == "startINDIExposure" )
2950 if (sf->argVal(1).toInt() != argStartExposureINDI->timeOut->value())
2951 setUnsavedChanges( true );
2953 sf->setArg(1, QString("%1").arg(argStartExposureINDI->timeOut->value()));
2954 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
2955 else sf->setValid(false);
2957 else
2959 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "startINDIExposure") << endl;
2964 void ScriptBuilder::slotINDISetUTCDeviceName()
2967 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2969 if ( sf->name() == "setINDIUTC" )
2971 if (argSetUTCINDI->deviceName->text().isEmpty())
2973 sf->setValid(false);
2974 return;
2977 if (sf->argVal(0) != argSetUTCINDI->deviceName->text())
2978 setUnsavedChanges( true );
2980 sf->setArg(0, argSetUTCINDI->deviceName->text());
2981 if (! sf->argVal(1).isEmpty()) sf->setValid(true);
2982 else sf->setValid(false);
2984 else
2986 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIUTC" ) << endl;
2992 void ScriptBuilder::slotINDISetUTC()
2994 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
2996 if ( sf->name() == "setINDIUTC" )
2999 if (argSetUTCINDI->UTC->text().isEmpty())
3001 sf->setValid(false);
3002 return;
3005 if (sf->argVal(1) != argSetUTCINDI->UTC->text())
3006 setUnsavedChanges( true );
3008 sf->setArg(1, argSetUTCINDI->UTC->text());
3009 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
3010 else sf->setValid(false);
3012 else
3014 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIUTC" ) << endl;
3019 void ScriptBuilder::slotINDISetScopeActionDeviceName()
3022 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3024 if ( sf->name() == "setINDIScopeAction" )
3026 if (argSetScopeActionINDI->deviceName->text().isEmpty())
3028 sf->setValid(false);
3029 return;
3032 if (sf->argVal(0) != argSetScopeActionINDI->deviceName->text())
3033 setUnsavedChanges( true );
3035 sf->setArg(0, argSetScopeActionINDI->deviceName->text());
3036 sf->setArg(1, argSetScopeActionINDI->actionCombo->currentText());
3037 sf->setINDIProperty("CHECK");
3038 sf->setValid(true);
3040 else
3042 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIScopeAction" ) << endl;
3047 void ScriptBuilder::slotINDISetScopeAction()
3049 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3051 if ( sf->name() == "setINDIScopeAction" )
3054 if (sf->argVal(1) != argSetScopeActionINDI->actionCombo->currentText())
3055 setUnsavedChanges( true );
3057 sf->setArg(1, argSetScopeActionINDI->actionCombo->currentText());
3058 sf->setINDIProperty("CHECK");
3059 if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
3060 else sf->setValid(false);
3062 else
3064 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIScopeAction") << endl;
3069 void ScriptBuilder::slotINDISetFrameTypeDeviceName()
3072 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3074 if ( sf->name() == "setINDIFrameType" )
3076 if (argSetFrameTypeINDI->deviceName->text().isEmpty())
3078 sf->setValid(false);
3079 return;
3082 if (sf->argVal(0) != argSetFrameTypeINDI->deviceName->text())
3083 setUnsavedChanges( true );
3085 sf->setArg(0, argSetFrameTypeINDI->deviceName->text());
3086 sf->setArg(1, argSetFrameTypeINDI->typeCombo->currentText());
3087 sf->setValid(true);
3089 else
3091 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFrameType" ) << endl;
3096 void ScriptBuilder::slotINDISetFrameType()
3098 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3100 if ( sf->name() == "setINDIFrameType" )
3103 if (sf->argVal(1) != argSetFrameTypeINDI->typeCombo->currentText())
3104 setUnsavedChanges( true );
3106 sf->setArg(1, argSetFrameTypeINDI->typeCombo->currentText());
3107 if ((! sf->argVal(0).isEmpty())) sf->setValid(true);
3108 else sf->setValid(false);
3110 else
3112 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFrameType") << endl;
3117 void ScriptBuilder::slotINDISetCCDTempDeviceName()
3119 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3121 if ( sf->name() == "setINDICCDTemp" )
3123 if (argSetCCDTempINDI->deviceName->text().isEmpty())
3125 sf->setValid(false);
3126 return;
3129 if (sf->argVal(0) != argSetCCDTempINDI->deviceName->text())
3130 setUnsavedChanges( true );
3132 sf->setArg(0, argSetCCDTempINDI->deviceName->text());
3133 sf->setArg(1, QString("%1").arg(argSetCCDTempINDI->temp->value()));
3134 sf->setValid(true);
3136 else
3138 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDICCDTemp") << endl;
3143 void ScriptBuilder::slotINDISetCCDTemp()
3145 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3147 if ( sf->name() == "setINDICCDTemp" )
3150 if (sf->argVal(1).toInt() != argSetCCDTempINDI->temp->value())
3151 setUnsavedChanges( true );
3153 sf->setArg(1, QString("%1").arg(argSetCCDTempINDI->temp->value()));
3154 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
3155 else sf->setValid(false);
3157 else
3159 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDICCDTemp") << endl;
3164 void ScriptBuilder::slotINDISetFilterNumDeviceName()
3167 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3169 if ( sf->name() == "setINDIFilterNum" )
3171 if (argSetFilterNumINDI->deviceName->text().isEmpty())
3173 sf->setValid(false);
3174 return;
3177 if (sf->argVal(0) != argSetFilterNumINDI->deviceName->text())
3178 setUnsavedChanges( true );
3180 sf->setArg(0, argSetFilterNumINDI->deviceName->text());
3181 sf->setArg(1, QString("%1").arg(argSetFilterNumINDI->filter_num->value()));
3182 sf->setValid(true);
3184 else
3186 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFilterNum") << endl;
3190 void ScriptBuilder::slotINDISetFilterNum()
3193 ScriptFunction *sf = ScriptList.at( sb->ScriptListBox->currentItem() );
3195 if ( sf->name() == "setINDIFilterNum" )
3198 if (sf->argVal(1).toInt() != argSetFilterNumINDI->filter_num->value())
3199 setUnsavedChanges( true );
3201 sf->setArg(1, QString("%1").arg(argSetFilterNumINDI->filter_num->value()));
3202 if (! sf->argVal(0).isEmpty()) sf->setValid(true);
3203 else sf->setValid(false);
3205 else
3207 kdWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)" ).arg( "setINDIFilterNum") << endl;
3213 #include "scriptbuilder.moc"