• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • tools
scriptbuilder.cpp
Go to the documentation of this file.
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  ***************************************************************************/
8 
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  ***************************************************************************/
17 
18 #include "scriptbuilder.h"
19 
20 //needed in slotSave() for chmod() syscall
21 #include <sys/stat.h>
22 
23 #include <QApplication>
24 #include <QFontMetrics>
25 #include <QTreeWidget>
26 #include <QTextStream>
27 
28 #include <kdebug.h>
29 #include <klocale.h>
30 #include <kio/netaccess.h>
31 #include <kprocess.h>
32 #include <kstandardguiitem.h>
33 #include <kstandarddirs.h>
34 #include <kurl.h>
35 #include <kiconloader.h>
36 #include <ktemporaryfile.h>
37 #include <kmessagebox.h>
38 #include <kfiledialog.h>
39 
40 #include "scriptfunction.h"
41 #include "kstars.h"
42 #include "kstarsdata.h"
43 #include "skymap.h"
44 #include "kstarsdatetime.h"
45 #include "dialogs/finddialog.h"
46 #include "dialogs/locationdialog.h"
47 #include "widgets/dmsbox.h"
48 #include "widgets/timestepbox.h"
49 
50 OptionsTreeViewWidget::OptionsTreeViewWidget( QWidget *p ) : QFrame( p ) {
51  setupUi( this );
52 }
53 
54 OptionsTreeView::OptionsTreeView( QWidget *p )
55  : KDialog( p )
56 {
57  otvw = new OptionsTreeViewWidget( this );
58  setMainWidget( otvw );
59  setCaption( i18n( "Options" ) );
60  setButtons( KDialog::Ok|KDialog::Cancel );
61  setModal( false );
62 }
63 
64 OptionsTreeView::~OptionsTreeView() {
65  delete otvw;
66 }
67 
68 void OptionsTreeView::resizeColumns() {
69  //Size each column to the maximum width of items in that column
70  int maxwidth[ 3 ] = { 0, 0, 0 };
71  QFontMetrics qfm = optionsList()->fontMetrics();
72 
73  for ( int i=0; i < optionsList()->topLevelItemCount(); ++i ) {
74  QTreeWidgetItem *topitem = optionsList()->topLevelItem( i );
75  topitem->setExpanded( true );
76 
77  for ( int j=0; j < topitem->childCount(); ++j ) {
78  QTreeWidgetItem *child = topitem->child( j );
79 
80  for ( int icol=0; icol<3; ++icol ) {
81  child->setExpanded( true );
82 
83  int w = qfm.width( child->text( icol ) ) + 4;
84  if ( icol == 0 ) {
85  w += 2*optionsList()->indentation();
86  }
87 
88  if ( w > maxwidth[icol] ) {
89  maxwidth[icol] = w;
90  }
91  }
92  }
93  }
94 
95  for ( int icol=0; icol < 3; ++icol ) {
96  //DEBUG
97  kDebug() << QString("max width of column %1: %2").arg(icol).arg(maxwidth[icol]) << endl;
98 
99  optionsList()->setColumnWidth( icol, maxwidth[icol] );
100  }
101 }
102 
103 ScriptNameWidget::ScriptNameWidget( QWidget *p ) : QFrame( p ) {
104  setupUi( this );
105 }
106 
107 ScriptNameDialog::ScriptNameDialog( QWidget *p )
108  : KDialog( p )
109 {
110  snw = new ScriptNameWidget( this );
111  setMainWidget( snw );
112  setCaption( i18n( "Script Data" ) );
113  setButtons( KDialog::Ok|KDialog::Cancel );
114 
115  connect( snw->ScriptName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEnableOkButton() ) );
116 }
117 
118 ScriptNameDialog::~ScriptNameDialog() {
119  delete snw;
120 }
121 
122 void ScriptNameDialog::slotEnableOkButton() {
123  enableButtonOk( ! snw->ScriptName->text().isEmpty() );
124 }
125 
126 ScriptBuilderUI::ScriptBuilderUI( QWidget *p ) : QFrame( p ) {
127  setupUi( this );
128 }
129 
130 ScriptBuilder::ScriptBuilder( QWidget *parent )
131  : KDialog( parent ), UnsavedChanges(false), checkForChanges(true),
132  currentFileURL(), currentDir( QDir::homePath() ),
133  currentScriptName(), currentAuthor()
134 {
135  ks = (KStars*)parent;
136  sb = new ScriptBuilderUI(this);
137  setMainWidget(sb);
138  setCaption( i18n( "Script Builder" ) );
139  setButtons( KDialog::User1 );
140  setButtonGuiItem( KDialog::User1, KGuiItem( i18n("&Close"), "dialog-close", i18n("Close the dialog") ) );
141 
142  sb->FuncDoc->setTextInteractionFlags( Qt::NoTextInteraction );
143 
144  //Initialize function templates and descriptions
145  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'.", QString( "dir" ) ), false, "QString", "dir" ) );
146  KStarsFunctionList.append( new ScriptFunction( "addLabel", i18n( "Add a name label to the object named %1.", QString( "name" ) ), false, "QString", "name" ) );
147  KStarsFunctionList.append( new ScriptFunction( "removeLabel", i18n( "Remove the name label from the object named %1.", QString( "name" ) ), false, "QString", "name" ) );
148  KStarsFunctionList.append( new ScriptFunction( "addTrail", i18n( "Add a trail to the solar system body named %1.", QString( "name" ) ), false, "QString", "name" ) );
149  KStarsFunctionList.append( new ScriptFunction( "removeTrail", i18n( "Remove the trail from the solar system body named %1.", QString( "name" ) ), false, "QString", "name" ) );
150  KStarsFunctionList.append( new ScriptFunction( "setRaDec", i18n( "Point the display at the specified RA/Dec coordinates. RA is expressed in Hours; Dec is expressed in Degrees." ),
151  false, "double", "ra", "double", "dec" ) );
152  KStarsFunctionList.append( new ScriptFunction( "setAltAz", i18n( "Point the display at the specified Alt/Az coordinates. Alt and Az are expressed in Degrees." ),
153  false, "double", "alt", "double", "az" ) );
154  KStarsFunctionList.append( new ScriptFunction( "zoomIn", i18n( "Increase the display Zoom Level." ), false ) );
155  KStarsFunctionList.append( new ScriptFunction( "zoomOut", i18n( "Decrease the display Zoom Level." ), false ) );
156  KStarsFunctionList.append( new ScriptFunction( "defaultZoom", i18n( "Set the display Zoom Level to its default value." ), false ) );
157  KStarsFunctionList.append( new ScriptFunction( "zoom", i18n( "Set the display Zoom Level manually." ), false, "double", "z" ) );
158  KStarsFunctionList.append( new ScriptFunction( "setLocalTime", i18n( "Set the system clock to the specified Local Time." ),
159  false, "int", "year", "int", "month", "int", "day", "int", "hour", "int", "minute", "int", "second" ) );
160  KStarsFunctionList.append( new ScriptFunction( "waitFor", i18n( "Pause script execution for specified number of seconds." ), false, "double", "sec" ) );
161  KStarsFunctionList.append( new ScriptFunction( "waitForKey", i18n( "Halt script execution until the specified key is pressed. Only single-key strokes are possible; use 'space' for the spacebar." ),
162  false, "QString", "key" ) );
163  KStarsFunctionList.append( new ScriptFunction( "setTracking", i18n( "Set whether the display is tracking the current location." ), false, "bool", "track" ) );
164  KStarsFunctionList.append( new ScriptFunction( "changeViewOption", i18n( "Change view option named %1 to value %2.", QString( "opName" ), QString( "opValue" ) ), false, "QString", "opName", "QString", "opValue" ) );
165  KStarsFunctionList.append( new ScriptFunction( "setGeoLocation", i18n( "Set the geographic location to the city specified by city, province and country." ),
166  false, "QString", "cityName", "QString", "provinceName", "QString", "countryName" ) );
167  KStarsFunctionList.append( new ScriptFunction( "setColor", i18n( "Set the color named %1 to the value %2.", QString("colorName"), QString("value") ), false, "QString", "colorName", "QString", "value" ) );
168  KStarsFunctionList.append( new ScriptFunction( "loadColorScheme", i18n( "Load the color scheme specified by name." ), false, "QString", "name" ) );
169  KStarsFunctionList.append( new ScriptFunction( "exportImage", i18n( "Export the sky image to the file, with specified width and height."), false, "QString", "fileName", "int", "width", "int", "height" ) );
170  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.", QString( "usePrintDialog" ), QString( "useChartColors" ) ), false, "bool", "usePrintDialog", "bool", "useChartColors" ) );
171  SimClockFunctionList.append( new ScriptFunction( "stop", i18n( "Halt the simulation clock." ), true ) );
172  SimClockFunctionList.append( new ScriptFunction( "start", i18n( "Start the simulation clock." ), true ) );
173  SimClockFunctionList.append( new ScriptFunction( "setClockScale", i18n( "Set the timescale of the simulation clock to specified scale. 1.0 means real-time; 2.0 means twice real-time; etc." ), true, "double", "scale" ) );
174 
175  //TODO JM: INDI Scripting to be supported in KDE 4.1
176  // INDI functions
177  #if 0
178  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), *setINDIDeviceFunc(NULL);
179 
180  startINDIFunc = new ScriptFunction( "startINDI", i18n("Establish an INDI device either in local mode or server mode."), false, "QString", "deviceName", "bool", "useLocal");
181  INDIFunctionList.append ( startINDIFunc );
182 
183  setINDIDeviceFunc = new ScriptFunction( "setINDIDevice", i18n("Change current active device. All subsequent function calls will communicate with this device until changed"), false, "QString", "deviceName");
184  INDIFunctionList.append(setINDIDeviceFunc);
185 
186  shutdownINDIFunc = new ScriptFunction( "shutdownINDI", i18n("Shutdown an INDI device."), false, "QString", "deviceName");
187  INDIFunctionList.append ( shutdownINDIFunc);
188 
189  switchINDIFunc = new ScriptFunction( "switchINDI", i18n("Connect or Disconnect an INDI device."), false, "bool", "turnOn");
190  switchINDIFunc->setINDIProperty("CONNECTION");
191  switchINDIFunc->setArg(0, "true");
192  INDIFunctionList.append ( switchINDIFunc);
193 
194  setINDIPortFunc = new ScriptFunction( "setINDIPort", i18n("Set INDI's device connection port."), false, "QString", "port");
195  setINDIPortFunc->setINDIProperty("DEVICE_PORT");
196  INDIFunctionList.append ( setINDIPortFunc);
197 
198  setINDIScopeActionFunc = new ScriptFunction( "setINDIScopeAction", i18n("Set the telescope action. Available actions are SLEW, TRACK, SYNC, PARK, and ABORT."), false, "QString", "action");
199  setINDIScopeActionFunc->setINDIProperty("CHECK");
200  setINDIScopeActionFunc->setArg(0, "SLEW");
201  INDIFunctionList.append( setINDIScopeActionFunc);
202 
203  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, "double", "RA", "double", "DEC" );
204  setINDITargetCoordFunc->setINDIProperty("EQUATORIAL_EOD_COORD");
205  INDIFunctionList.append ( setINDITargetCoordFunc );
206 
207  setINDITargetNameFunc = new ScriptFunction( "setINDITargetName", i18n("Set the telescope target coordinates to the RA/Dec coordinates of the selected object."), false, "QString", "targetName");
208  setINDITargetNameFunc->setINDIProperty("EQUATORIAL_EOD_COORD");
209  INDIFunctionList.append( setINDITargetNameFunc);
210 
211  setINDIGeoLocationFunc = new ScriptFunction ( "setINDIGeoLocation", i18n("Set the telescope longitude and latitude. The longitude is measured east from Greenwich, UK."), false, "double", "long", "double", "lat");
212  setINDIGeoLocationFunc->setINDIProperty("GEOGRAPHIC_COORD");
213  INDIFunctionList.append( setINDIGeoLocationFunc);
214 
215  setINDIUTCFunc = new ScriptFunction ( "setINDIUTC", i18n("Set the device UTC time in ISO 8601 format YYYY/MM/DDTHH:MM:SS."), false, "QString", "UTCDateTime");
216  setINDIUTCFunc->setINDIProperty("TIME_UTC");
217  INDIFunctionList.append( setINDIUTCFunc);
218 
219  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", "actionName");
220  INDIFunctionList.append( setINDIActionFunc);
221 
222  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", "actionName");
223  INDIFunctionList.append( waitForINDIActionFunc );
224 
225  setINDIFocusSpeedFunc = new ScriptFunction ("setINDIFocusSpeed", i18n("Set the telescope focuser speed. Set speed to 0 to halt the focuser. 1-3 correspond to slow, medium, and fast speeds respectively."), false, "unsigned int", "speed");
226  setINDIFocusSpeedFunc->setINDIProperty("FOCUS_SPEED");
227  INDIFunctionList.append( setINDIFocusSpeedFunc );
228 
229  startINDIFocusFunc = new ScriptFunction ("startINDIFocus", i18n("Start moving the focuser in the direction Dir, and for the duration specified by setINDIFocusTimeout."), false, "QString", "Dir");
230  startINDIFocusFunc->setINDIProperty("FOCUS_MOTION");
231  startINDIFocusFunc->setArg(0, "IN");
232  INDIFunctionList.append( startINDIFocusFunc);
233 
234  setINDIFocusTimeoutFunc = new ScriptFunction ( "setINDIFocusTimeout", i18n("Set the telescope focuser timer in seconds. This is the duration of any focusing procedure performed by calling startINDIFocus."), false, "int", "timeout");
235  setINDIFocusTimeoutFunc->setINDIProperty("FOCUS_TIMER");
236  INDIFunctionList.append( setINDIFocusTimeoutFunc);
237 
238  setINDICCDTempFunc = new ScriptFunction( "setINDICCDTemp", i18n("Set the target CCD chip temperature."), false, "int", "temp");
239  setINDICCDTempFunc->setINDIProperty("CCD_TEMPERATURE");
240  INDIFunctionList.append( setINDICCDTempFunc);
241 
242  setINDIFilterNumFunc = new ScriptFunction( "setINDIFilterNum", i18n("Set the target filter position."), false, "int", "filter_num");
243  setINDIFilterNumFunc->setINDIProperty("FILTER_SLOT");
244  INDIFunctionList.append ( setINDIFilterNumFunc);
245 
246  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", "type");
247  setINDIFrameTypeFunc->setINDIProperty("FRAME_TYPE");
248  setINDIFrameTypeFunc->setArg(0, "FRAME_LIGHT");
249  INDIFunctionList.append( setINDIFrameTypeFunc);
250 
251  startINDIExposureFunc = new ScriptFunction ( "startINDIExposure", i18n("Start Camera/CCD exposure. The duration is in seconds."), false, "int", "timeout");
252  startINDIExposureFunc->setINDIProperty("CCD_EXPOSE_DURATION");
253  INDIFunctionList.append( startINDIExposureFunc);
254  #endif
255 
256  // JM: We're using QTreeWdiget for Qt4 now
257  QTreeWidgetItem *kstars_tree = new QTreeWidgetItem( sb->FunctionTree, QStringList("KStars"));
258  QTreeWidgetItem *simclock_tree = new QTreeWidgetItem( sb->FunctionTree, QStringList("SimClock"));
259 
260  for ( int i=0; i < KStarsFunctionList.size(); ++i )
261  new QTreeWidgetItem (kstars_tree, QStringList( KStarsFunctionList[i]->prototype()) );
262 
263  for ( int i=0; i < SimClockFunctionList.size(); ++i )
264  new QTreeWidgetItem (simclock_tree, QStringList( SimClockFunctionList[i]->prototype()) );
265 
266  kstars_tree->sortChildren( 0, Qt::AscendingOrder );
267  simclock_tree->sortChildren( 0, Qt::AscendingOrder );
268 
269  sb->FunctionTree->setColumnCount(1);
270  sb->FunctionTree->setHeaderLabels( QStringList(i18n("Functions")) );
271  sb->FunctionTree->setSortingEnabled( false );
272 
273  #if 0
274  QTreeWidgetItem *INDI_tree = new QTreeWidgetItem( sb->FunctionTree, QStringList("INDI"));
275  QTreeWidgetItem *INDI_general = new QTreeWidgetItem( INDI_tree, QStringList("General"));
276  QTreeWidgetItem *INDI_telescope = new QTreeWidgetItem( INDI_tree, QStringList("Telescope"));
277  QTreeWidgetItem *INDI_ccd = new QTreeWidgetItem( INDI_tree, QStringList("Camera/CCD"));
278  QTreeWidgetItem *INDI_focuser = new QTreeWidgetItem( INDI_tree, QStringList("Focuser"));
279  QTreeWidgetItem *INDI_filter = new QTreeWidgetItem( INDI_tree, QStringList("Filter"));
280 
281  // General
282  new QTreeWidgetItem(INDI_general, QStringList(startINDIFunc->prototype()));
283  new QTreeWidgetItem(INDI_general, QStringList(shutdownINDIFunc->prototype()));
284  new QTreeWidgetItem(INDI_general, QStringList(setINDIDeviceFunc->prototype()));
285  new QTreeWidgetItem(INDI_general, QStringList(switchINDIFunc->prototype()));
286  new QTreeWidgetItem(INDI_general, QStringList(setINDIPortFunc->prototype()));
287  new QTreeWidgetItem(INDI_general, QStringList(setINDIActionFunc->prototype()));
288  new QTreeWidgetItem(INDI_general, QStringList(waitForINDIActionFunc->prototype()));
289 
290  // Telescope
291  new QTreeWidgetItem(INDI_telescope, QStringList(setINDIScopeActionFunc->prototype()));
292  new QTreeWidgetItem(INDI_telescope, QStringList(setINDITargetCoordFunc->prototype()));
293  new QTreeWidgetItem(INDI_telescope, QStringList(setINDITargetNameFunc->prototype()));
294  new QTreeWidgetItem(INDI_telescope, QStringList(setINDIGeoLocationFunc->prototype()));
295  new QTreeWidgetItem(INDI_telescope, QStringList(setINDIUTCFunc->prototype()));
296 
297  // CCD
298  new QTreeWidgetItem(INDI_ccd, QStringList(setINDICCDTempFunc->prototype()));
299  new QTreeWidgetItem(INDI_ccd, QStringList(setINDIFrameTypeFunc->prototype()));
300  new QTreeWidgetItem(INDI_ccd, QStringList(startINDIExposureFunc->prototype()));
301 
302  // Focuser
303  new QTreeWidgetItem(INDI_focuser, QStringList(setINDIFocusSpeedFunc->prototype()));
304  new QTreeWidgetItem(INDI_focuser, QStringList(setINDIFocusTimeoutFunc->prototype()));
305  new QTreeWidgetItem(INDI_focuser, QStringList(startINDIFocusFunc->prototype()));
306 
307  // Filter
308  new QTreeWidgetItem(INDI_filter, QStringList(setINDIFilterNumFunc->prototype()));
309  #endif
310 
311  //Add icons to Push Buttons
312  sb->NewButton->setIcon( KIcon( "document-new" ) );
313  sb->OpenButton->setIcon( KIcon( "document-open" ) );
314  sb->SaveButton->setIcon( KIcon( "document-save" ) );
315  sb->SaveAsButton->setIcon( KIcon( "document-save-as" ) );
316  sb->RunButton->setIcon( KIcon( "system-run" ) );
317  sb->CopyButton->setIcon( KIcon( "view-refresh" ) );
318  sb->AddButton->setIcon( KIcon( "go-previous" ) );
319  sb->RemoveButton->setIcon( KIcon( "go-next" ) );
320  sb->UpButton->setIcon( KIcon( "go-up" ) );
321  sb->DownButton->setIcon( KIcon( "go-down" ) );
322 
323  //Prepare the widget stack
324  argBlank = new QWidget();
325  argLookToward = new ArgLookToward( sb->ArgStack );
326  argFindObject = new ArgFindObject( sb->ArgStack ); //shared by Add/RemoveLabel and Add/RemoveTrail
327  argSetRaDec = new ArgSetRaDec( sb->ArgStack );
328  argSetAltAz = new ArgSetAltAz( sb->ArgStack );
329  argSetLocalTime = new ArgSetLocalTime( sb->ArgStack );
330  argWaitFor = new ArgWaitFor( sb->ArgStack );
331  argWaitForKey = new ArgWaitForKey( sb->ArgStack );
332  argSetTracking = new ArgSetTrack( sb->ArgStack );
333  argChangeViewOption = new ArgChangeViewOption( sb->ArgStack );
334  argSetGeoLocation = new ArgSetGeoLocation( sb->ArgStack );
335  argTimeScale = new ArgTimeScale( sb->ArgStack );
336  argZoom = new ArgZoom( sb->ArgStack );
337  argExportImage = new ArgExportImage( sb->ArgStack );
338  argPrintImage = new ArgPrintImage( sb->ArgStack );
339  argSetColor = new ArgSetColor( sb->ArgStack );
340  argLoadColorScheme = new ArgLoadColorScheme( sb->ArgStack );
341 
342  #if 0
343  argStartINDI = new ArgStartINDI ( sb->ArgStack );
344  argSetDeviceINDI = new ArgSetDeviceINDI (sb->ArgStack);
345  argShutdownINDI = new ArgShutdownINDI ( sb->ArgStack );
346  argSwitchINDI = new ArgSwitchINDI ( sb->ArgStack );
347  argSetPortINDI = new ArgSetPortINDI ( sb->ArgStack );
348  argSetTargetCoordINDI = new ArgSetTargetCoordINDI ( sb->ArgStack );
349  argSetTargetNameINDI = new ArgSetTargetNameINDI ( sb->ArgStack );
350  argSetActionINDI = new ArgSetActionINDI ( sb->ArgStack );
351  argWaitForActionINDI = new ArgSetActionINDI ( sb->ArgStack );
352  argSetFocusSpeedINDI = new ArgSetFocusSpeedINDI ( sb->ArgStack );
353  argStartFocusINDI = new ArgStartFocusINDI( sb->ArgStack );
354  argSetFocusTimeoutINDI = new ArgSetFocusTimeoutINDI( sb->ArgStack );
355  argSetGeoLocationINDI = new ArgSetGeoLocationINDI( sb->ArgStack );
356  argStartExposureINDI = new ArgStartExposureINDI( sb->ArgStack );
357  argSetUTCINDI = new ArgSetUTCINDI( sb->ArgStack );
358  argSetScopeActionINDI = new ArgSetScopeActionINDI( sb->ArgStack );
359  argSetFrameTypeINDI = new ArgSetFrameTypeINDI ( sb->ArgStack );
360  argSetCCDTempINDI = new ArgSetCCDTempINDI( sb->ArgStack );
361  argSetFilterNumINDI = new ArgSetFilterNumINDI( sb->ArgStack );
362 
363  argStartFocusINDI->directionCombo->addItem("IN");
364  argStartFocusINDI->directionCombo->addItem("OUT");
365 
366  argSetScopeActionINDI->actionCombo->addItem("SLEW");
367  argSetScopeActionINDI->actionCombo->addItem("TRACK");
368  argSetScopeActionINDI->actionCombo->addItem("SYNC");
369  argSetScopeActionINDI->actionCombo->addItem("PARK");
370  argSetScopeActionINDI->actionCombo->addItem("ABORT");
371 
372  argSetFrameTypeINDI->typeCombo->addItem("FRAME_LIGHT");
373  argSetFrameTypeINDI->typeCombo->addItem("FRAME_BIAS");
374  argSetFrameTypeINDI->typeCombo->addItem("FRAME_DARK");
375  argSetFrameTypeINDI->typeCombo->addItem("FRAME_FLAT");
376  #endif
377 
378  sb->ArgStack->addWidget( argBlank );
379  sb->ArgStack->addWidget( argLookToward );
380  sb->ArgStack->addWidget( argFindObject );
381  sb->ArgStack->addWidget( argSetRaDec );
382  sb->ArgStack->addWidget( argSetAltAz );
383  sb->ArgStack->addWidget( argSetLocalTime );
384  sb->ArgStack->addWidget( argWaitFor );
385  sb->ArgStack->addWidget( argWaitForKey );
386  sb->ArgStack->addWidget( argSetTracking );
387  sb->ArgStack->addWidget( argChangeViewOption );
388  sb->ArgStack->addWidget( argSetGeoLocation );
389  sb->ArgStack->addWidget( argTimeScale );
390  sb->ArgStack->addWidget( argZoom );
391  sb->ArgStack->addWidget( argExportImage );
392  sb->ArgStack->addWidget( argPrintImage );
393  sb->ArgStack->addWidget( argSetColor );
394  sb->ArgStack->addWidget( argLoadColorScheme );
395 
396  #if 0
397  sb->ArgStack->addWidget( argStartINDI);
398  sb->ArgStack->addWidget( argSetDeviceINDI);
399  sb->ArgStack->addWidget( argShutdownINDI);
400  sb->ArgStack->addWidget( argSwitchINDI);
401  sb->ArgStack->addWidget( argSetPortINDI);
402  sb->ArgStack->addWidget( argSetTargetCoordINDI);
403  sb->ArgStack->addWidget( argSetTargetNameINDI);
404  sb->ArgStack->addWidget( argSetActionINDI);
405  sb->ArgStack->addWidget( argWaitForActionINDI );
406  sb->ArgStack->addWidget( argSetFocusSpeedINDI );
407  sb->ArgStack->addWidget( argStartFocusINDI);
408  sb->ArgStack->addWidget( argSetFocusTimeoutINDI);
409  sb->ArgStack->addWidget( argSetGeoLocationINDI);
410  sb->ArgStack->addWidget( argStartExposureINDI);
411  sb->ArgStack->addWidget( argSetUTCINDI);
412  sb->ArgStack->addWidget( argSetScopeActionINDI);
413  sb->ArgStack->addWidget( argSetFrameTypeINDI);
414  sb->ArgStack->addWidget( argSetCCDTempINDI);
415  sb->ArgStack->addWidget( argSetFilterNumINDI);
416  #endif
417 
418  sb->ArgStack->setCurrentIndex( 0 );
419 
420  snd = new ScriptNameDialog( ks );
421  otv = new OptionsTreeView( ks );
422 
423  otv->resize( sb->width(), 0.5*sb->height() );
424 
425  initViewOptions();
426  otv->resizeColumns();
427 
428  //connect widgets in ScriptBuilderUI
429  connect( this, SIGNAL(user1Clicked()), this, SLOT(slotClose()));
430  connect( sb->FunctionTree, SIGNAL( itemDoubleClicked(QTreeWidgetItem *, int )), this, SLOT( slotAddFunction() ) );
431  connect( sb->FunctionTree, SIGNAL( itemClicked(QTreeWidgetItem*, int) ), this, SLOT( slotShowDoc() ) );
432  connect( sb->UpButton, SIGNAL( clicked() ), this, SLOT( slotMoveFunctionUp() ) );
433  connect( sb->ScriptListBox, SIGNAL( itemClicked(QListWidgetItem *) ), this, SLOT( slotArgWidget() ) );
434  connect( sb->DownButton, SIGNAL( clicked() ), this, SLOT( slotMoveFunctionDown() ) );
435  connect( sb->CopyButton, SIGNAL( clicked() ), this, SLOT( slotCopyFunction() ) );
436  connect( sb->RemoveButton, SIGNAL( clicked() ), this, SLOT( slotRemoveFunction() ) );
437  connect( sb->NewButton, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
438  connect( sb->OpenButton, SIGNAL( clicked() ), this, SLOT( slotOpen() ) );
439  connect( sb->SaveButton, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
440  connect( sb->SaveAsButton, SIGNAL( clicked() ), this, SLOT( slotSaveAs() ) );
441  connect( sb->AddButton, SIGNAL( clicked() ), this, SLOT( slotAddFunction() ) );
442  connect( sb->RunButton, SIGNAL( clicked() ), this, SLOT( slotRunScript() ) );
443 
444  //Connections for Arg Widgets
445  connect( argSetGeoLocation->FindCityButton, SIGNAL( clicked() ), this, SLOT( slotFindCity() ) );
446  connect( argLookToward->FindButton, SIGNAL( clicked() ), this, SLOT( slotFindObject() ) );
447  connect( argChangeViewOption->TreeButton, SIGNAL( clicked() ), this, SLOT( slotShowOptions() ) );
448 
449  connect( argLookToward->FocusEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotLookToward() ) );
450  connect( argFindObject->NameEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotArgFindObject() ) );
451  connect( argSetRaDec->RABox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotRa() ) );
452  connect( argSetRaDec->DecBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotDec() ) );
453  connect( argSetAltAz->AltBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotAlt() ) );
454  connect( argSetAltAz->AzBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotAz() ) );
455  connect( argSetLocalTime->DateWidget, SIGNAL( changed(const QDate&) ), this, SLOT( slotChangeDate() ) );
456  connect( argSetLocalTime->TimeBox, SIGNAL( timeChanged(const QTime&) ), this, SLOT( slotChangeTime() ) );
457  connect( argWaitFor->DelayBox, SIGNAL( valueChanged(int) ), this, SLOT( slotWaitFor() ) );
458  connect( argWaitForKey->WaitKeyEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotWaitForKey() ) );
459  connect( argSetTracking->CheckTrack, SIGNAL( stateChanged(int) ), this, SLOT( slotTracking() ) );
460  connect( argChangeViewOption->OptionName, SIGNAL( activated(const QString &) ), this, SLOT( slotViewOption() ) );
461  connect( argChangeViewOption->OptionValue, SIGNAL( textChanged(const QString &) ), this, SLOT( slotViewOption() ) );
462  connect( argSetGeoLocation->CityName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeCity() ) );
463  connect( argSetGeoLocation->ProvinceName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeProvince() ) );
464  connect( argSetGeoLocation->CountryName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotChangeCountry() ) );
465  connect( argTimeScale->TimeScale, SIGNAL( scaleChanged(float) ), this, SLOT( slotTimeScale() ) );
466  connect( argZoom->ZoomBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotZoom() ) );
467  connect( argExportImage->ExportFileName, SIGNAL( textChanged(const QString &) ), this, SLOT( slotExportImage() ) );
468  connect( argExportImage->ExportWidth, SIGNAL( valueChanged(int) ), this, SLOT( slotExportImage() ) );
469  connect( argExportImage->ExportHeight, SIGNAL( valueChanged(int) ), this, SLOT( slotExportImage() ) );
470  connect( argPrintImage->UsePrintDialog, SIGNAL( toggled(bool) ), this, SLOT( slotPrintImage() ) );
471  connect( argPrintImage->UseChartColors, SIGNAL( toggled(bool) ), this, SLOT( slotPrintImage() ) );
472  connect( argSetColor->ColorName, SIGNAL( activated(const QString &) ), this, SLOT( slotChangeColorName() ) );
473  connect( argSetColor->ColorValue, SIGNAL( changed(const QColor &) ), this, SLOT( slotChangeColor() ) );
474  connect( argLoadColorScheme->SchemeList, SIGNAL( itemClicked ( QListWidgetItem * )), this, SLOT( slotLoadColorScheme() ) );
475 
476  //connect( sb->AppendINDIWait, SIGNAL ( toggled(bool) ), this, SLOT(slotINDIWaitCheck(bool)));
477 
478  #if 0
479  // Connections for INDI's Arg widgets
480 
481  // INDI Start Device
482  connect (argStartINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIStartDeviceName()));
483  connect (argStartINDI->LocalButton, SIGNAL ( toggled(bool)), this, SLOT (slotINDIStartDeviceMode()));
484 
485  // Set Device Name
486  connect (argSetDeviceINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetDevice()));
487 
488  // INDI Shutdown Device
489  connect (argShutdownINDI->deviceName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIShutdown()));
490 
491  // INDI Swtich Device
492  connect (argSwitchINDI->OnButton, SIGNAL ( toggled( bool)), this, SLOT (slotINDISwitchDeviceConnection()));
493 
494  // INDI Set Device Port
495  connect (argSetPortINDI->devicePort, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetPortDevicePort()));
496 
497  // INDI Set Target Coord
498  connect( argSetTargetCoordINDI->RABox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetTargetCoordDeviceRA() ) );
499  connect( argSetTargetCoordINDI->DecBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetTargetCoordDeviceDEC() ) );
500 
501  // INDI Set Target Name
502  connect (argSetTargetNameINDI->targetName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetTargetNameTargetName()));
503 
504  // INDI Set Action
505  connect (argSetActionINDI->actionName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetActionName()));
506 
507  // INDI Wait For Action
508  connect (argWaitForActionINDI->actionName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDIWaitForActionName()));
509 
510  // INDI Set Focus Speed
511  connect (argSetFocusSpeedINDI->speedIN, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFocusSpeed()));
512 
513  // INDI Start Focus
514  connect (argStartFocusINDI->directionCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDIStartFocusDirection()));
515 
516  // INDI Set Focus Timeout
517  connect (argSetFocusTimeoutINDI->timeOut, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFocusTimeout()));
518 
519  // INDI Set Geo Location
520  connect( argSetGeoLocationINDI->longBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetGeoLocationDeviceLong() ) );
521  connect( argSetGeoLocationINDI->latBox, SIGNAL( textChanged(const QString &) ), this, SLOT( slotINDISetGeoLocationDeviceLat() ) );
522 
523  // INDI Start Exposure
524  connect (argStartExposureINDI->timeOut, SIGNAL( valueChanged(int) ), this, SLOT(slotINDIStartExposureTimeout()));
525 
526  // INDI Set UTC
527  connect (argSetUTCINDI->UTC, SIGNAL( textChanged(const QString &) ), this, SLOT(slotINDISetUTC()));
528 
529  // INDI Set Scope Action
530  connect (argSetScopeActionINDI->actionCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDISetScopeAction()));
531 
532  // INDI Set Frame type
533  connect (argSetFrameTypeINDI->typeCombo, SIGNAL( activated(const QString &) ), this, SLOT(slotINDISetFrameType()));
534 
535  // INDI Set CCD Temp
536  connect (argSetCCDTempINDI->temp, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetCCDTemp()));
537 
538  // INDI Set Filter Num
539  connect (argSetFilterNumINDI->filter_num, SIGNAL( valueChanged(int) ), this, SLOT(slotINDISetFilterNum()));
540  #endif
541 
542 
543  //disable some buttons
544  sb->CopyButton->setEnabled( false );
545  sb->AddButton->setEnabled( false );
546  sb->RemoveButton->setEnabled( false );
547  sb->UpButton->setEnabled( false );
548  sb->DownButton->setEnabled( false );
549  sb->SaveButton->setEnabled( false );
550  sb->SaveAsButton->setEnabled( false );
551  sb->RunButton->setEnabled( false );
552 }
553 
554 ScriptBuilder::~ScriptBuilder()
555 {
556  while ( ! KStarsFunctionList.isEmpty() )
557  delete KStarsFunctionList.takeFirst();
558 
559  // while ( ! INDIFunctionList.isEmpty() )
560  // delete INDIFunctionList.takeFirst();
561 
562  while( !SimClockFunctionList.isEmpty() )
563  delete SimClockFunctionList.takeFirst();
564 
565  while ( ! ScriptList.isEmpty() )
566  delete ScriptList.takeFirst();
567 }
568 
569 void ScriptBuilder::initViewOptions() {
570  otv->optionsList()->setRootIsDecorated( true );
571  QStringList fields;
572 
573  //InfoBoxes
574  opsGUI = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "InfoBoxes" )) );
575  fields << "ShowInfoBoxes" << i18n( "Toggle display of all InfoBoxes" ) << i18n( "bool" );
576  new QTreeWidgetItem( opsGUI, fields );
577  fields.clear();
578  fields << "ShowTimeBox" << i18n( "Toggle display of Time InfoBox" ) << i18n( "bool" );
579  new QTreeWidgetItem( opsGUI, fields );
580  fields.clear();
581  fields << "ShowGeoBox" << i18n( "Toggle display of Geographic InfoBox" ) << i18n( "bool" );
582  new QTreeWidgetItem( opsGUI, fields );
583  fields.clear();
584  fields << "ShowFocusBox" << i18n( "Toggle display of Focus InfoBox" ) << i18n( "bool" );
585  new QTreeWidgetItem( opsGUI, fields );
586  fields.clear();
587  fields << "ShadeTimeBox" << i18n( "(un)Shade Time InfoBox" ) << i18n( "bool" );
588  new QTreeWidgetItem( opsGUI, fields );
589  fields.clear();
590  fields << "ShadeGeoBox" << i18n( "(un)Shade Geographic InfoBox" ) << i18n( "bool" );
591  new QTreeWidgetItem( opsGUI, fields );
592  fields.clear();
593  fields << "ShadeFocusBox" << i18n( "(un)Shade Focus InfoBox" ) << i18n( "bool" );
594  new QTreeWidgetItem( opsGUI, fields );
595  fields.clear();
596 
597  argChangeViewOption->OptionName->addItem( "ShowInfoBoxes" );
598  argChangeViewOption->OptionName->addItem( "ShowTimeBox" );
599  argChangeViewOption->OptionName->addItem( "ShowGeoBox" );
600  argChangeViewOption->OptionName->addItem( "ShowFocusBox" );
601  argChangeViewOption->OptionName->addItem( "ShadeTimeBox" );
602  argChangeViewOption->OptionName->addItem( "ShadeGeoBox" );
603  argChangeViewOption->OptionName->addItem( "ShadeFocusBox" );
604 
605  //Toolbars
606  opsToolbar = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "Toolbars" )) );
607  fields << "ShowMainToolBar" << i18n( "Toggle display of main toolbar" ) << i18n( "bool" );
608  new QTreeWidgetItem( opsToolbar, fields );
609  fields.clear();
610  fields << "ShowViewToolBar" << i18n( "Toggle display of view toolbar" ) << i18n( "bool" );
611  new QTreeWidgetItem( opsToolbar, fields );
612  fields.clear();
613 
614  argChangeViewOption->OptionName->addItem( "ShowMainToolBar" );
615  argChangeViewOption->OptionName->addItem( "ShowViewToolBar" );
616 
617  //Show Objects
618  opsShowObj = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "Show Objects" )) );
619  fields << "ShowStars" << i18n( "Toggle display of Stars" ) << i18n( "bool" );
620  new QTreeWidgetItem( opsShowObj, fields );
621  fields.clear();
622  fields << "ShowDeepSky" << i18n( "Toggle display of all deep-sky objects" ) << i18n( "bool" );
623  new QTreeWidgetItem( opsShowObj, fields );
624  fields.clear();
625  fields << "ShowMessier" << i18n( "Toggle display of Messier object symbols" ) << i18n( "bool" );
626  new QTreeWidgetItem( opsShowObj, fields );
627  fields.clear();
628  fields << "ShowMessierImages" << i18n( "Toggle display of Messier object images" ) << i18n( "bool" );
629  new QTreeWidgetItem( opsShowObj, fields );
630  fields.clear();
631  fields << "ShowNGC" << i18n( "Toggle display of NGC objects" ) << i18n( "bool" );
632  new QTreeWidgetItem( opsShowObj, fields );
633  fields.clear();
634  fields << "ShowIC" << i18n( "Toggle display of IC objects" ) << i18n( "bool" );
635  new QTreeWidgetItem( opsShowObj, fields );
636  fields.clear();
637  fields << "ShowSolarSystem" << i18n( "Toggle display of all solar system bodies" ) << i18n( "bool" );
638  new QTreeWidgetItem( opsShowObj, fields );
639  fields.clear();
640  fields << "ShowSun" << i18n( "Toggle display of Sun" ) << i18n( "bool" );
641  new QTreeWidgetItem( opsShowObj, fields );
642  fields.clear();
643  fields << "ShowMoon" << i18n( "Toggle display of Moon" ) << i18n( "bool" );
644  new QTreeWidgetItem( opsShowObj, fields );
645  fields.clear();
646  fields << "ShowMercury" << i18n( "Toggle display of Mercury" ) << i18n( "bool" );
647  new QTreeWidgetItem( opsShowObj, fields );
648  fields.clear();
649  fields << "ShowVenus" << i18n( "Toggle display of Venus" ) << i18n( "bool" );
650  new QTreeWidgetItem( opsShowObj, fields );
651  fields.clear();
652  fields << "ShowMars" << i18n( "Toggle display of Mars" ) << i18n( "bool" );
653  new QTreeWidgetItem( opsShowObj, fields );
654  fields.clear();
655  fields << "ShowJupiter" << i18n( "Toggle display of Jupiter" ) << i18n( "bool" );
656  new QTreeWidgetItem( opsShowObj, fields );
657  fields.clear();
658  fields << "ShowSaturn" << i18n( "Toggle display of Saturn" ) << i18n( "bool" );
659  new QTreeWidgetItem( opsShowObj, fields );
660  fields.clear();
661  fields << "ShowUranus" << i18n( "Toggle display of Uranus" ) << i18n( "bool" );
662  new QTreeWidgetItem( opsShowObj, fields );
663  fields.clear();
664  fields << "ShowNeptune" << i18n( "Toggle display of Neptune" ) << i18n( "bool" );
665  new QTreeWidgetItem( opsShowObj, fields );
666  fields.clear();
667  fields << "ShowPluto" << i18n( "Toggle display of Pluto" ) << i18n( "bool" );
668  new QTreeWidgetItem( opsShowObj, fields );
669  fields.clear();
670  fields << "ShowAsteroids" << i18n( "Toggle display of Asteroids" ) << i18n( "bool" );
671  new QTreeWidgetItem( opsShowObj, fields );
672  fields.clear();
673  fields << "ShowComets" << i18n( "Toggle display of Comets" ) << i18n( "bool" );
674  new QTreeWidgetItem( opsShowObj, fields );
675  fields.clear();
676 
677  argChangeViewOption->OptionName->addItem( "ShowStars" );
678  argChangeViewOption->OptionName->addItem( "ShowDeepSky" );
679  argChangeViewOption->OptionName->addItem( "ShowMessier" );
680  argChangeViewOption->OptionName->addItem( "ShowMessierImages" );
681  argChangeViewOption->OptionName->addItem( "ShowNGC" );
682  argChangeViewOption->OptionName->addItem( "ShowIC" );
683  argChangeViewOption->OptionName->addItem( "ShowSolarSystem" );
684  argChangeViewOption->OptionName->addItem( "ShowSun" );
685  argChangeViewOption->OptionName->addItem( "ShowMoon" );
686  argChangeViewOption->OptionName->addItem( "ShowMercury" );
687  argChangeViewOption->OptionName->addItem( "ShowVenus" );
688  argChangeViewOption->OptionName->addItem( "ShowMars" );
689  argChangeViewOption->OptionName->addItem( "ShowJupiter" );
690  argChangeViewOption->OptionName->addItem( "ShowSaturn" );
691  argChangeViewOption->OptionName->addItem( "ShowUranus" );
692  argChangeViewOption->OptionName->addItem( "ShowNeptune" );
693  argChangeViewOption->OptionName->addItem( "ShowPluto" );
694  argChangeViewOption->OptionName->addItem( "ShowAsteroids" );
695  argChangeViewOption->OptionName->addItem( "ShowComets" );
696 
697  opsShowOther = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "Show Other" )) );
698  fields << "ShowCLines" << i18n( "Toggle display of constellation lines" ) << i18n( "bool" );
699  new QTreeWidgetItem( opsShowOther, fields );
700  fields.clear();
701  fields << "ShowCBounds" << i18n( "Toggle display of constellation boundaries" ) << i18n( "bool" );
702  new QTreeWidgetItem( opsShowOther, fields );
703  fields.clear();
704  fields << "ShowCNames" << i18n( "Toggle display of constellation names" ) << i18n( "bool" );
705  new QTreeWidgetItem( opsShowOther, fields );
706  fields.clear();
707  fields << "ShowMilkyWay" << i18n( "Toggle display of Milky Way" ) << i18n( "bool" );
708  new QTreeWidgetItem( opsShowOther, fields );
709  fields.clear();
710  fields << "ShowGrid" << i18n( "Toggle display of the coordinate grid" ) << i18n( "bool" );
711  new QTreeWidgetItem( opsShowOther, fields );
712  fields.clear();
713  fields << "ShowEquator" << i18n( "Toggle display of the celestial equator" ) << i18n( "bool" );
714  new QTreeWidgetItem( opsShowOther, fields );
715  fields.clear();
716  fields << "ShowEcliptic" << i18n( "Toggle display of the ecliptic" ) << i18n( "bool" );
717  new QTreeWidgetItem( opsShowOther, fields );
718  fields.clear();
719  fields << "ShowHorizon" << i18n( "Toggle display of the horizon line" ) << i18n( "bool" );
720  new QTreeWidgetItem( opsShowOther, fields );
721  fields.clear();
722  fields << "ShowGround" << i18n( "Toggle display of the opaque ground" ) << i18n( "bool" );
723  new QTreeWidgetItem( opsShowOther, fields );
724  fields.clear();
725  fields << "ShowStarNames" << i18n( "Toggle display of star name labels" ) << i18n( "bool" );
726  new QTreeWidgetItem( opsShowOther, fields );
727  fields.clear();
728  fields << "ShowStarMagnitudes" << i18n( "Toggle display of star magnitude labels" ) << i18n( "bool" );
729  new QTreeWidgetItem( opsShowOther, fields );
730  fields.clear();
731  fields << "ShowAsteroidNames" << i18n( "Toggle display of asteroid name labels" ) << i18n( "bool" );
732  new QTreeWidgetItem( opsShowOther, fields );
733  fields.clear();
734  fields << "ShowCometNames" << i18n( "Toggle display of comet name labels" ) << i18n( "bool" );
735  new QTreeWidgetItem( opsShowOther, fields );
736  fields.clear();
737  fields << "ShowPlanetNames" << i18n( "Toggle display of planet name labels" ) << i18n( "bool" );
738  new QTreeWidgetItem( opsShowOther, fields );
739  fields.clear();
740  fields << "ShowPlanetImages" << i18n( "Toggle display of planet images" ) << i18n( "bool" );
741  new QTreeWidgetItem( opsShowOther, fields );
742  fields.clear();
743 
744  argChangeViewOption->OptionName->addItem( "ShowCLines" );
745  argChangeViewOption->OptionName->addItem( "ShowCBounds" );
746  argChangeViewOption->OptionName->addItem( "ShowCNames" );
747  argChangeViewOption->OptionName->addItem( "ShowMilkyWay" );
748  argChangeViewOption->OptionName->addItem( "ShowGrid" );
749  argChangeViewOption->OptionName->addItem( "ShowEquator" );
750  argChangeViewOption->OptionName->addItem( "ShowEcliptic" );
751  argChangeViewOption->OptionName->addItem( "ShowHorizon" );
752  argChangeViewOption->OptionName->addItem( "ShowGround" );
753  argChangeViewOption->OptionName->addItem( "ShowStarNames" );
754  argChangeViewOption->OptionName->addItem( "ShowStarMagnitudes" );
755  argChangeViewOption->OptionName->addItem( "ShowAsteroidNames" );
756  argChangeViewOption->OptionName->addItem( "ShowCometNames" );
757  argChangeViewOption->OptionName->addItem( "ShowPlanetNames" );
758  argChangeViewOption->OptionName->addItem( "ShowPlanetImages" );
759 
760  opsCName = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "Constellation Names" )) );
761  fields << "UseLatinConstellNames" << i18n( "Show Latin constellation names" ) << i18n( "bool" );
762  new QTreeWidgetItem( opsCName, fields );
763  fields.clear();
764  fields << "UseLocalConstellNames" <<i18n( "Show constellation names in local language" ) << i18n( "bool" );
765  new QTreeWidgetItem( opsCName, fields );
766  fields.clear();
767  fields << "UseAbbrevConstellNames" <<i18n( "Show IAU-standard constellation abbreviations" ) << i18n( "bool" );
768  new QTreeWidgetItem( opsCName, fields );
769  fields.clear();
770 
771  argChangeViewOption->OptionName->addItem( "UseLatinConstellNames" );
772  argChangeViewOption->OptionName->addItem( "UseLocalConstellNames" );
773  argChangeViewOption->OptionName->addItem( "UseAbbrevConstellNames" );
774 
775  opsHide = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "Hide Items" )) );
776  fields << "HideOnSlew" << i18n( "Toggle whether objects hidden while slewing display" ) << i18n( "bool" );
777  new QTreeWidgetItem( opsHide, fields );
778  fields.clear();
779  fields << "SlewTimeScale" << i18n( "Timestep threshold (in seconds) for hiding objects") << i18n( "double" );
780  new QTreeWidgetItem( opsHide, fields );
781  fields.clear();
782  fields << "HideStars" << i18n( "Hide faint stars while slewing?" ) << i18n( "bool" );
783  new QTreeWidgetItem( opsHide, fields );
784  fields.clear();
785  fields << "HidePlanets" << i18n( "Hide solar system bodies while slewing?" ) << i18n( "bool" );
786  new QTreeWidgetItem( opsHide, fields );
787  fields.clear();
788  fields << "HideMessier" << i18n( "Hide Messier objects while slewing?" ) << i18n( "bool" );
789  new QTreeWidgetItem( opsHide, fields );
790  fields.clear();
791  fields << "HideNGC" << i18n( "Hide NGC objects while slewing?" ) << i18n( "bool" );
792  new QTreeWidgetItem( opsHide, fields );
793  fields.clear();
794  fields << "HideIC" << i18n( "Hide IC objects while slewing?" ) << i18n( "bool" );
795  new QTreeWidgetItem( opsHide, fields );
796  fields.clear();
797  fields << "HideMilkyWay" << i18n( "Hide Milky Way while slewing?" ) << i18n( "bool" );
798  new QTreeWidgetItem( opsHide, fields );
799  fields.clear();
800  fields << "HideCNames" << i18n( "Hide constellation names while slewing?" ) << i18n( "bool" );
801  new QTreeWidgetItem( opsHide, fields );
802  fields.clear();
803  fields << "HideCLines" << i18n( "Hide constellation lines while slewing?" ) << i18n( "bool" );
804  new QTreeWidgetItem( opsHide, fields );
805  fields.clear();
806  fields << "HideCBounds" << i18n( "Hide constellation boundaries while slewing?" ) << i18n( "bool" );
807  new QTreeWidgetItem( opsHide, fields );
808  fields.clear();
809  fields << "HideGrid" << i18n( "Hide coordinate grid while slewing?" ) << i18n( "bool" );
810  new QTreeWidgetItem( opsHide, fields );
811  fields.clear();
812 
813  argChangeViewOption->OptionName->addItem( "HideOnSlew" );
814  argChangeViewOption->OptionName->addItem( "SlewTimeScale" );
815  argChangeViewOption->OptionName->addItem( "HideStars" );
816  argChangeViewOption->OptionName->addItem( "HidePlanets" );
817  argChangeViewOption->OptionName->addItem( "HideMessier" );
818  argChangeViewOption->OptionName->addItem( "HideNGC" );
819  argChangeViewOption->OptionName->addItem( "HideIC" );
820  argChangeViewOption->OptionName->addItem( "HideMilkyWay" );
821  argChangeViewOption->OptionName->addItem( "HideCNames" );
822  argChangeViewOption->OptionName->addItem( "HideCLines" );
823  argChangeViewOption->OptionName->addItem( "HideCBounds" );
824  argChangeViewOption->OptionName->addItem( "HideGrid" );
825 
826  opsSkymap = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "Skymap Options" )) );
827  fields << "UseAltAz" << i18n( "Use Horizontal coordinates? (otherwise, use Equatorial)") << i18n( "bool" );
828  new QTreeWidgetItem( opsSkymap, fields );
829  fields.clear();
830  fields << "ZoomFactor" << i18n( "Set the Zoom Factor" ) << i18n( "double" );
831  new QTreeWidgetItem( opsSkymap, fields );
832  fields.clear();
833  fields << "FOVName" << i18n( "Select angular size for the FOV symbol (in arcmin)") << i18n( "double" );
834  new QTreeWidgetItem( opsSkymap, fields );
835  fields.clear();
836  fields << "FOVShape" << i18n( "Select shape for the FOV symbol (0=Square, 1=Circle, 2=Crosshairs, 4=Bullseye)" ) << i18n( "int" );
837  new QTreeWidgetItem( opsSkymap, fields );
838  fields.clear();
839  fields << "FOVColor" << i18n( "Select color for the FOV symbol" ) << i18n( "string" );
840  new QTreeWidgetItem( opsSkymap, fields );
841  fields.clear();
842  fields << "UseAnimatedSlewing" << i18n( "Use animated slewing? (otherwise, \"snap\" to new focus)" ) << i18n( "bool" );
843  new QTreeWidgetItem( opsSkymap, fields );
844  fields.clear();
845  fields << "UseRefraction" << i18n( "Correct for atmospheric refraction?" ) << i18n( "bool" );
846  new QTreeWidgetItem( opsSkymap, fields );
847  fields.clear();
848  fields << "UseAutoLabel" << i18n( "Automatically attach name label to centered object?" ) << i18n( "bool" );
849  new QTreeWidgetItem( opsSkymap, fields );
850  fields.clear();
851  fields << "UseHoverLabel" << i18n( "Attach temporary name label when hovering mouse over an object?" ) << i18n( "bool" );
852  new QTreeWidgetItem( opsSkymap, fields );
853  fields.clear();
854  fields << "UseAutoTrail" << i18n( "Automatically add trail to centered solar system body?" ) << i18n( "bool" );
855  new QTreeWidgetItem( opsSkymap, fields );
856  fields.clear();
857  fields << "FadePlanetTrails" << i18n( "Planet trails fade to sky color? (otherwise color is constant)" ) << i18n( "bool" );
858  new QTreeWidgetItem( opsSkymap, fields );
859  fields.clear();
860 
861  argChangeViewOption->OptionName->addItem( "UseAltAz" );
862  argChangeViewOption->OptionName->addItem( "ZoomFactor" );
863  argChangeViewOption->OptionName->addItem( "FOVName" );
864  argChangeViewOption->OptionName->addItem( "FOVSize" );
865  argChangeViewOption->OptionName->addItem( "FOVShape" );
866  argChangeViewOption->OptionName->addItem( "FOVColor" );
867  argChangeViewOption->OptionName->addItem( "UseRefraction" );
868  argChangeViewOption->OptionName->addItem( "UseAutoLabel" );
869  argChangeViewOption->OptionName->addItem( "UseHoverLabel" );
870  argChangeViewOption->OptionName->addItem( "UseAutoTrail" );
871  argChangeViewOption->OptionName->addItem( "AnimateSlewing" );
872  argChangeViewOption->OptionName->addItem( "FadePlanetTrails" );
873 
874 
875  opsLimit = new QTreeWidgetItem( otv->optionsList(), QStringList(i18n( "Limits" )) );
876  /*
877  fields << "magLimitDrawStar" << i18n( "magnitude of faintest star drawn on map when zoomed in" ) << i18n( "double" );
878  new QTreeWidgetItem( opsLimit, fields );
879  fields.clear();
880  fields << "magLimitDrawStarZoomOut" << i18n( "magnitude of faintest star drawn on map when zoomed out" ) << i18n( "double" );
881  new QTreeWidgetItem( opsLimit, fields );
882  fields.clear();
883  */
884 
885  // TODO: We have disabled the following two features. Enable them when feasible...
886  /*
887  fields << "magLimitDrawDeepSky" << i18n( "magnitude of faintest nonstellar object drawn on map when zoomed in" ) << i18n( "double" );
888  new QTreeWidgetItem( opsLimit, fields );
889  fields.clear();
890  fields << "magLimitDrawDeepSkyZoomOut" << i18n( "magnitude of faintest nonstellar object drawn on map when zoomed out" ) << i18n( "double" );
891  new QTreeWidgetItem( opsLimit, fields );
892  fields.clear();
893  */
894 
895  //FIXME: This description is incorrect! Fix after strings freeze
896  fields << "starLabelDensity" << i18n( "magnitude of faintest star labeled on map" ) << i18n( "double" );
897  new QTreeWidgetItem( opsLimit, fields );
898  fields.clear();
899  fields << "magLimitHideStar" << i18n( "magnitude of brightest star hidden while slewing" ) << i18n( "double" );
900  new QTreeWidgetItem( opsLimit, fields );
901  fields.clear();
902  fields << "magLimitAsteroid" << i18n( "magnitude of faintest asteroid drawn on map" ) << i18n( "double" );
903  new QTreeWidgetItem( opsLimit, fields );
904  fields.clear();
905  //FIXME: This description is incorrect! Fix after strings freeze
906  fields << "asteroidLabelDensity" << i18n( "magnitude of faintest asteroid labeled on map" ) << i18n( "double" );
907  new QTreeWidgetItem( opsLimit, fields );
908  fields.clear();
909  fields << "maxRadCometName" << i18n( "comets nearer to the Sun than this (in AU) are labeled on map" ) << i18n( "double" );
910  new QTreeWidgetItem( opsLimit, fields );
911  fields.clear();
912 
913  // argChangeViewOption->OptionName->addItem( "magLimitDrawStar" );
914  // argChangeViewOption->OptionName->addItem( "magLimitDrawStarZoomOut" );
915  argChangeViewOption->OptionName->addItem( "magLimitDrawDeepSky" );
916  argChangeViewOption->OptionName->addItem( "magLimitDrawDeepSkyZoomOut" );
917  argChangeViewOption->OptionName->addItem( "starLabelDensity" );
918  argChangeViewOption->OptionName->addItem( "magLimitHideStar" );
919  argChangeViewOption->OptionName->addItem( "magLimitAsteroid" );
920  argChangeViewOption->OptionName->addItem( "asteroidLabelDensity" );
921  argChangeViewOption->OptionName->addItem( "maxRadCometName" );
922 
923  //init the list of color names and values
924  for ( unsigned int i=0; i < ks->data()->colorScheme()->numberOfColors(); ++i ) {
925  argSetColor->ColorName->addItem( ks->data()->colorScheme()->nameAt(i) );
926  }
927 
928  //init list of color scheme names
929  argLoadColorScheme->SchemeList->addItem( i18nc( "use default color scheme", "Default Colors" ) );
930  argLoadColorScheme->SchemeList->addItem( i18nc( "use 'star chart' color scheme", "Star Chart" ) );
931  argLoadColorScheme->SchemeList->addItem( i18nc( "use 'night vision' color scheme", "Night Vision" ) );
932  argLoadColorScheme->SchemeList->addItem( i18nc( "use 'moonless night' color scheme", "Moonless Night" ) );
933 
934  QFile file;
935  QString line;
936  file.setFileName( KStandardDirs::locate( "appdata", "colors.dat" ) ); //determine filename in local user KDE directory tree.
937  if ( file.open( QIODevice::ReadOnly ) ) {
938  QTextStream stream( &file );
939 
940  while ( !stream.atEnd() ) {
941  line = stream.readLine();
942  argLoadColorScheme->SchemeList->addItem( line.left( line.indexOf( ':' ) ) );
943  }
944  file.close();
945  }
946 }
947 
948 //Slots defined in ScriptBuilderUI
949 void ScriptBuilder::slotNew() {
950  saveWarning();
951  if ( !UnsavedChanges ) {
952  ScriptList.clear();
953  sb->ScriptListBox->clear();
954  sb->ArgStack->setCurrentWidget( argBlank );
955 
956  sb->CopyButton->setEnabled( false );
957  sb->RemoveButton->setEnabled( false );
958  sb->RunButton->setEnabled( false );
959  sb->SaveAsButton->setEnabled( false );
960 
961  currentFileURL.clear();
962  currentScriptName.clear();
963  }
964 }
965 
966 void ScriptBuilder::slotOpen() {
967  saveWarning();
968 
969  QString fname;
970  KTemporaryFile tmpfile;
971  tmpfile.open();
972 
973  if ( !UnsavedChanges ) {
974  currentFileURL = KFileDialog::getOpenUrl( currentDir, "*.kstars|" + i18nc("Filter by file type: KStars Scripts.", "KStars Scripts (*.kstars)") );
975 
976  if ( currentFileURL.isValid() ) {
977  currentDir = currentFileURL.directory();
978 
979  ScriptList.clear();
980  sb->ScriptListBox->clear();
981  sb->ArgStack->setCurrentWidget( argBlank );
982 
983  if ( currentFileURL.isLocalFile() ) {
984  fname = currentFileURL.toLocalFile();
985  } else {
986  fname = tmpfile.fileName();
987  if ( ! KIO::NetAccess::download( currentFileURL, fname, (QWidget*) 0 ) )
988  KMessageBox::sorry( 0, i18n( "Could not download remote file." ), i18n( "Download Error" ) );
989  }
990 
991  QFile f( fname );
992  if ( !f.open( QIODevice::ReadOnly) ) {
993  QString message = i18n( "Could not open file %1.", f.fileName() );
994  KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
995  currentFileURL.clear();
996  return;
997  }
998 
999  QTextStream istream(&f);
1000  readScript( istream );
1001 
1002  f.close();
1003  } else if ( ! currentFileURL.url().isEmpty() ) {
1004  QString message = i18n( "Invalid URL: %1", currentFileURL.url() );
1005  KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
1006  currentFileURL.clear();
1007  }
1008  }
1009 }
1010 
1011 void ScriptBuilder::slotSave()
1012 {
1013  QString fname;
1014  KTemporaryFile tmpfile;
1015  tmpfile.open();
1016 
1017  if ( currentScriptName.isEmpty() ) {
1018  //Get Script Name and Author info
1019  if ( snd->exec() == QDialog::Accepted ) {
1020  currentScriptName = snd->scriptName();
1021  currentAuthor = snd->authorName();
1022  } else {
1023  return;
1024  }
1025  }
1026 
1027  bool newFilename = false;
1028  if ( currentFileURL.isEmpty() ) {
1029  currentFileURL = KFileDialog::getSaveUrl( currentDir, "*.kstars|" + i18nc("Filter by file type: KStars Scripts.", "KStars Scripts (*.kstars)") );
1030  newFilename = true;
1031  }
1032 
1033  if ( currentFileURL.isValid() ) {
1034  currentDir = currentFileURL.directory();
1035 
1036  if ( currentFileURL.isLocalFile() ) {
1037  fname = currentFileURL.toLocalFile();
1038 
1039  //Warn user if file exists
1040  if (newFilename == true && QFile::exists(currentFileURL.path())) {
1041  int r=KMessageBox::warningContinueCancel(static_cast<QWidget *>(parent()),
1042  i18n( "A file named \"%1\" already exists. "
1043  "Overwrite it?" , currentFileURL.fileName()),
1044  i18n( "Overwrite File?" ),
1045  KStandardGuiItem::overwrite() );
1046 
1047  if(r==KMessageBox::Cancel) return;
1048  }
1049  } else {
1050  fname = tmpfile.fileName();
1051  }
1052 
1053  if ( fname.right( 7 ).toLower() != ".kstars" ) fname += ".kstars";
1054 
1055  QFile f( fname );
1056  if ( !f.open( QIODevice::WriteOnly) ) {
1057  QString message = i18n( "Could not open file %1.", f.fileName() );
1058  KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
1059  currentFileURL.clear();
1060  return;
1061  }
1062 
1063  QTextStream ostream(&f);
1064  writeScript( ostream );
1065  f.close();
1066 
1067  //set rwx for owner, rx for group, rx for other
1068  chmod( fname.toAscii(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
1069 
1070  if ( tmpfile.fileName() == fname ) { //need to upload to remote location
1071  if ( ! KIO::NetAccess::upload( tmpfile.fileName(), currentFileURL, (QWidget*) 0 ) ) {
1072  QString message = i18n( "Could not upload image to remote location: %1", currentFileURL.prettyUrl() );
1073  KMessageBox::sorry( 0, message, i18n( "Could not upload file" ) );
1074  }
1075  }
1076 
1077  setUnsavedChanges( false );
1078 
1079  } else {
1080  QString message = i18n( "Invalid URL: %1", currentFileURL.url() );
1081  KMessageBox::sorry( 0, message, i18n( "Invalid URL" ) );
1082  currentFileURL.clear();
1083  }
1084 }
1085 
1086 void ScriptBuilder::slotSaveAs() {
1087  currentFileURL.clear();
1088  currentScriptName.clear();
1089  slotSave();
1090 }
1091 
1092 void ScriptBuilder::saveWarning() {
1093  if ( UnsavedChanges ) {
1094  QString caption = i18n( "Save Changes to Script?" );
1095  QString message = i18n( "The current script has unsaved changes. Would you like to save before closing it?" );
1096  int ans = KMessageBox::warningYesNoCancel( 0, message, caption, KStandardGuiItem::save(), KStandardGuiItem::discard() );
1097  if ( ans == KMessageBox::Yes ) {
1098  slotSave();
1099  setUnsavedChanges( false );
1100  } else if ( ans == KMessageBox::No ) {
1101  setUnsavedChanges( false );
1102  }
1103 
1104  //Do nothing if 'cancel' selected
1105  }
1106 }
1107 
1108 void ScriptBuilder::slotRunScript() {
1109  //hide window while script runs
1110  // If this is uncommented, the program hangs before the script is executed. Why?
1111  // hide();
1112 
1113  //Save current script to a temporary file, then execute that file.
1114  //For some reason, I can't use KTempFile here! If I do, then the temporary script
1115  //is not executable. Bizarre...
1116  //KTempFile tmpfile;
1117  //QString fname = tmpfile.name();
1118  QString fname = KStandardDirs::locateLocal( "tmp", "kstars-tempscript" );
1119 
1120  QFile f( fname );
1121  if ( f.exists() ) f.remove();
1122  if ( !f.open( QIODevice::WriteOnly) ) {
1123  QString message = i18n( "Could not open file %1.", f.fileName() );
1124  KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
1125  currentFileURL.clear();
1126  return;
1127  }
1128 
1129  QTextStream ostream(&f);
1130  writeScript( ostream );
1131  f.close();
1132 
1133  //set rwx for owner, rx for group, rx for other
1134  chmod( QFile::encodeName( f.fileName() ), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH );
1135 
1136  KProcess p;
1137  p << f.fileName();
1138  p.start();
1139 
1140  if( !p.waitForStarted() )
1141  kDebug() << "Process did not start.";
1142 
1143  while ( !p.waitForFinished(10) ) {
1144  qApp->processEvents(); //otherwise tempfile may get deleted before script completes.
1145  if( p.state() != QProcess::Running )
1146  break;
1147  }
1148  //delete temp file
1149  if ( f.exists() ) f.remove();
1150 
1151  //uncomment if 'hide()' is uncommented...
1152  // show();
1153 }
1154 
1155 /*
1156  This can't work anymore and is also not protable in any way :(
1157 */
1158 void ScriptBuilder::writeScript( QTextStream &ostream )
1159 {
1160  // FIXME Without --print-reply, the dbus-send doesn't do anything, why??
1161  QString dbus_call = "dbus-send --dest=org.kde.kstars --print-reply ";
1162  QString main_method = "/KStars org.kde.kstars.";
1163  QString clock_method = "/KStars/SimClock org.kde.kstars.SimClock.";
1164 
1165  //Write script header
1166  ostream << "#!/bin/bash" << endl;
1167  ostream << "#KStars DBus script: " << currentScriptName << endl;
1168  ostream << "#by " << currentAuthor << endl;
1169  ostream << "#last modified: " << KStarsDateTime::currentDateTime().toString( KDateTime::ISODate ) << endl;
1170  ostream << "#" << endl;
1171 
1172  foreach ( ScriptFunction *sf, ScriptList )
1173  {
1174  if (!sf->valid()) continue;
1175 
1176  if ( sf->isClockFunction() )
1177  {
1178  ostream << dbus_call << clock_method << sf->scriptLine() << endl;
1179  } else
1180  {
1181  ostream << dbus_call << main_method << sf->scriptLine() << endl;
1182 
1183  // TODO INDI scripting to be supported under KDE 4.1
1184  #if 0
1185 
1186  if (sb->AppendINDIWait->isChecked() && !sf->INDIProperty().isEmpty())
1187  {
1188  // Special case for telescope action, we need to know the parent property
1189  if (sf->INDIProperty() == "CHECK")
1190  {
1191  if (sf->argVal(1) == "SLEW" || sf->argVal(1) == "TRACK" || sf->argVal(1) == "SYNC")
1192  sf->setINDIProperty("ON_COORD_SET");
1193  else if (sf->argVal(1) == "ABORT")
1194  sf->setINDIProperty("ABORT_MOTION");
1195  else
1196  sf->setINDIProperty("PARK");
1197  }
1198 
1199  if ( sf->argVal(0).contains(" "))
1200  ostream << mainpre << "waitForINDIAction " << "\"" << sf->argVal(0) << "\" " << sf->INDIProperty() << endl;
1201  else
1202  ostream << mainpre << "waitForINDIAction " << sf->argVal(0) << " " << sf->INDIProperty() << endl;
1203  }
1204  #endif
1205  }
1206  }
1207 
1208  //Write script footer
1209  ostream << "##" << endl;
1210 }
1211 
1212 void ScriptBuilder::readScript( QTextStream &istream )
1213 {
1214  QString line;
1215  QString service_name = "org.kde.kstars.";
1216  QString fn_name;
1217 
1218  while ( ! istream.atEnd() ) {
1219  line = istream.readLine();
1220 
1221  //look for name of script
1222  if ( line.contains( "#KStars DBus script: " ) )
1223  currentScriptName = line.mid( 21 ).trimmed();
1224 
1225  //look for author of scriptbuilder
1226  if ( line.contains( "#by " ) )
1227  currentAuthor = line.mid( 4 ).trimmed();
1228 
1229  //Actual script functions
1230  if ( line.left(4) == "dbus" ) {
1231 
1232  //is ClockFunction?
1233  if ( line.contains( "SimClock" ) ) {
1234  service_name += "SimClock.";
1235  }
1236 
1237  //remove leading dbus prefix
1238  line = line.mid( line.lastIndexOf(service_name) + service_name.count() );
1239 
1240 
1241  fn_name = line.left(line.indexOf(" "));
1242 
1243  line = line.mid(line.indexOf(" ") + 1);
1244 
1245  //construct a stringlist that is fcn name and its arg name/value pairs
1246  QStringList fn;
1247 
1248  // If the function lacks any arguments, do not attempt to split
1249  if (fn_name != line)
1250  fn = line.split(' ');
1251 
1252  if ( parseFunction( fn_name, fn ) )
1253  {
1254  sb->ScriptListBox->addItem( ScriptList.last()->name() );
1255  // Initially, any read script is valid!
1256  ScriptList.last()->setValid(true);
1257  }
1258  else kWarning() << i18n( "Could not parse script. Line was: %1", line ) ;
1259 
1260  } // end if left(4) == "dcop"
1261  } // end while !atEnd()
1262 
1263  //Select first item in sb->ScriptListBox
1264  if ( sb->ScriptListBox->count() ) {
1265  sb->ScriptListBox->setCurrentItem( 0 );
1266  slotArgWidget();
1267  }
1268 }
1269 
1270 bool ScriptBuilder::parseFunction( QString fn_name, QStringList &fn )
1271 {
1272  // clean up the string list first if needed
1273  // We need to perform this in case we havea quoted string "NGC 3000" because this will counted
1274  // as two arguments, and it should be counted as one.
1275  bool foundQuote(false), quoteProcessed(false);
1276  QString cur, arg;
1277  QStringList::iterator it;
1278 
1279  for (it = fn.begin(); it != fn.end(); ++it)
1280  {
1281  cur = (*it);
1282 
1283  cur = cur.mid(cur.indexOf(":") + 1).remove('\'');
1284 
1285  (*it) = cur;
1286 
1287  if ( cur.startsWith('\"'))
1288  {
1289  arg += cur.right(cur.length() - 1);
1290  arg += ' ';
1291  foundQuote = true;
1292  quoteProcessed = true;
1293  }
1294  else if (cur.endsWith('\"'))
1295  {
1296  arg += cur.left(cur.length() -1);
1297  arg += '\'';
1298  foundQuote = false;
1299  }
1300  else if (foundQuote)
1301  {
1302  arg += cur;
1303  arg += ' ';
1304  }
1305  else
1306  {
1307  arg += cur;
1308  arg += '\'';
1309  }
1310  }
1311 
1312  if (quoteProcessed)
1313  fn = arg.split( '\'', QString::SkipEmptyParts );
1314 
1315  //loop over known functions to find a name match
1316  foreach ( ScriptFunction *sf, KStarsFunctionList )
1317  {
1318  if ( fn_name == sf->name() )
1319  {
1320 
1321  if ( fn_name == "setGeoLocation" )
1322  {
1323  QString city( fn[0] ), prov, cntry( fn[1] );
1324  prov.clear();
1325  if ( fn.count() == 4 ) { prov = fn[1]; cntry = fn[2]; }
1326  if ( fn.count() == 3 || fn.count() == 4 )
1327  {
1328  ScriptList.append( new ScriptFunction( sf ) );
1329  ScriptList.last()->setArg( 0, city );
1330  ScriptList.last()->setArg( 1, prov );
1331  ScriptList.last()->setArg( 2, cntry );
1332  } else return false;
1333 
1334  } else if ( fn.count() != sf->numArgs()) return false;
1335 
1336  ScriptList.append( new ScriptFunction( sf ) );
1337 
1338  for ( int i=0; i<sf->numArgs(); ++i )
1339  ScriptList.last()->setArg( i, fn[i] );
1340 
1341  return true;
1342  }
1343 
1344  foreach ( ScriptFunction *sf, SimClockFunctionList )
1345  {
1346  if ( fn_name == sf->name() )
1347  {
1348 
1349  if ( fn.count() != sf->numArgs()) return false;
1350 
1351  ScriptList.append( new ScriptFunction( sf ) );
1352 
1353  for ( int i=0; i<sf->numArgs(); ++i )
1354  ScriptList.last()->setArg( i, fn[i] );
1355 
1356  return true;
1357  }
1358 
1359  }
1360 
1361  #if 0
1362  foreach ( ScriptFunction *sf, INDIFunctionList )
1363  {
1364  if ( fn[0] == sf->name() )
1365  {
1366 
1367  if ( fn.count() != sf->numArgs() + 1 ) return false;
1368 
1369  ScriptList.append( new ScriptFunction( sf ) );
1370 
1371  for ( int i=0; i<sf->numArgs(); ++i )
1372  ScriptList.last()->setArg( i, fn[i+1] );
1373 
1374  return true;
1375  }
1376  }
1377  #endif
1378  }
1379 
1380  //if we get here, no function-name match was found
1381  return false;
1382 }
1383 
1384 void ScriptBuilder::setUnsavedChanges( bool b ) {
1385  if ( checkForChanges ) {
1386  UnsavedChanges = b;
1387  sb->SaveButton->setEnabled( b );
1388  }
1389 }
1390 
1391 void ScriptBuilder::slotCopyFunction() {
1392  if ( ! UnsavedChanges ) setUnsavedChanges( true );
1393 
1394  int Pos = sb->ScriptListBox->currentRow() + 1;
1395  ScriptList.insert( Pos, new ScriptFunction( ScriptList[ Pos-1 ] ) );
1396  //copy ArgVals
1397  for ( int i=0; i < ScriptList[ Pos-1 ]->numArgs(); ++i )
1398  ScriptList[Pos]->setArg(i, ScriptList[ Pos-1 ]->argVal(i) );
1399 
1400  sb->ScriptListBox->insertItem( Pos, ScriptList[Pos]->name());
1401  //sb->ScriptListBox->setSelected( Pos, true );
1402  sb->ScriptListBox->setCurrentRow(Pos);
1403  slotArgWidget();
1404 }
1405 
1406 void ScriptBuilder::slotRemoveFunction() {
1407  setUnsavedChanges( true );
1408 
1409  int Pos = sb->ScriptListBox->currentRow();
1410  ScriptList.removeAt( Pos );
1411  sb->ScriptListBox->takeItem( Pos );
1412  if ( sb->ScriptListBox->count() == 0 ) {
1413  sb->ArgStack->setCurrentWidget( argBlank );
1414  sb->CopyButton->setEnabled( false );
1415  sb->RemoveButton->setEnabled( false );
1416  sb->RunButton->setEnabled( false );
1417  sb->SaveAsButton->setEnabled( false );
1418  } else {
1419  //sb->ScriptListBox->setSelected( Pos, true );
1420  if ( Pos == sb->ScriptListBox->count() ) {
1421  Pos = Pos - 1;
1422  }
1423  sb->ScriptListBox->setCurrentRow(Pos);
1424  }
1425  slotArgWidget();
1426 }
1427 
1428 void ScriptBuilder::slotAddFunction() {
1429 
1430  ScriptFunction *sc = NULL, *found = NULL;
1431  QTreeWidgetItem *currentItem = sb->FunctionTree->currentItem();
1432 
1433  if ( currentItem == NULL || currentItem->parent() == 0)
1434  return;
1435 
1436  foreach ( sc, KStarsFunctionList )
1437  if (sc->prototype() == currentItem->text(0))
1438  {
1439  found = sc;
1440  break;
1441  }
1442 
1443  foreach ( sc, SimClockFunctionList )
1444  if (sc->prototype() == currentItem->text(0))
1445  {
1446  found = sc;
1447  break;
1448  }
1449 
1450  #if 0
1451  if (found == NULL)
1452  {
1453  foreach ( sc, INDIFunctionList )
1454  if (sc->prototype() == currentItem->text(0))
1455  {
1456  found = sc;
1457  break;
1458  }
1459  }
1460  #endif
1461 
1462  if (found == NULL) return;
1463 
1464  setUnsavedChanges( true );
1465 
1466  int Pos = sb->ScriptListBox->currentRow() + 1;
1467 
1468  ScriptList.insert( Pos, new ScriptFunction(found) );
1469  sb->ScriptListBox->insertItem(Pos, ScriptList[Pos]->name());
1470  sb->ScriptListBox->setCurrentRow(Pos);
1471  slotArgWidget();
1472 }
1473 
1474 void ScriptBuilder::slotMoveFunctionUp() {
1475  if ( sb->ScriptListBox->currentRow() > 0 ) {
1476  setUnsavedChanges( true );
1477 
1478  //QString t = sb->ScriptListBox->currentItem()->text();
1479  QString t = sb->ScriptListBox->currentItem()->text();
1480  unsigned int n = sb->ScriptListBox->currentRow();
1481 
1482  ScriptFunction *tmp = ScriptList.takeAt( n );
1483  ScriptList.insert( n-1, tmp );
1484 
1485  sb->ScriptListBox->takeItem( n );
1486  sb->ScriptListBox->insertItem( n-1, t);
1487  sb->ScriptListBox->setCurrentRow(n-1);
1488  slotArgWidget();
1489  }
1490 }
1491 
1492 void ScriptBuilder::slotMoveFunctionDown() {
1493  if ( sb->ScriptListBox->currentRow() > -1 &&
1494  sb->ScriptListBox->currentRow() < ((int) sb->ScriptListBox->count())-1 ) {
1495  setUnsavedChanges( true );
1496 
1497  QString t = sb->ScriptListBox->currentItem()->text();
1498  unsigned int n = sb->ScriptListBox->currentRow();
1499 
1500  ScriptFunction *tmp = ScriptList.takeAt( n );
1501  ScriptList.insert( n+1, tmp );
1502 
1503  sb->ScriptListBox->takeItem( n );
1504  sb->ScriptListBox->insertItem( n+1 , t);
1505  sb->ScriptListBox->setCurrentRow( n+1);
1506  slotArgWidget();
1507  }
1508 }
1509 
1510 void ScriptBuilder::slotArgWidget() {
1511  //First, setEnabled on buttons that act on the selected script function
1512  if ( sb->ScriptListBox->currentRow() == -1 ) { //no selection
1513  sb->CopyButton->setEnabled( false );
1514  sb->RemoveButton->setEnabled( false );
1515  sb->UpButton->setEnabled( false );
1516  sb->DownButton->setEnabled( false );
1517  } else if ( sb->ScriptListBox->count() == 1 ) { //only one item, so disable up/down buttons
1518  sb->CopyButton->setEnabled( true );
1519  sb->RemoveButton->setEnabled( true );
1520  sb->UpButton->setEnabled( false );
1521  sb->DownButton->setEnabled( false );
1522  } else if ( sb->ScriptListBox->currentRow() == 0 ) { //first item selected
1523  sb->CopyButton->setEnabled( true );
1524  sb->RemoveButton->setEnabled( true );
1525  sb->UpButton->setEnabled( false );
1526  sb->DownButton->setEnabled( true );
1527  } else if ( sb->ScriptListBox->currentRow() == ((int) sb->ScriptListBox->count())-1 ) { //last item selected
1528  sb->CopyButton->setEnabled( true );
1529  sb->RemoveButton->setEnabled( true );
1530  sb->UpButton->setEnabled( true );
1531  sb->DownButton->setEnabled( false );
1532  } else { //other item selected
1533  sb->CopyButton->setEnabled( true );
1534  sb->RemoveButton->setEnabled( true );
1535  sb->UpButton->setEnabled( true );
1536  sb->DownButton->setEnabled( true );
1537  }
1538 
1539  //RunButton and SaveAs button enabled when script not empty.
1540  if ( sb->ScriptListBox->count() ) {
1541  sb->RunButton->setEnabled( true );
1542  sb->SaveAsButton->setEnabled( true );
1543  } else {
1544  sb->RunButton->setEnabled( false );
1545  sb->SaveAsButton->setEnabled( false );
1546  setUnsavedChanges( false );
1547  }
1548 
1549  //Display the function's arguments widget
1550  if ( sb->ScriptListBox->currentRow() > -1 &&
1551  sb->ScriptListBox->currentRow() < ((int) sb->ScriptListBox->count()) ) {
1552  QString t = sb->ScriptListBox->currentItem()->text();
1553  unsigned int n = sb->ScriptListBox->currentRow();
1554  ScriptFunction *sf = ScriptList.at( n );
1555 
1556  checkForChanges = false; //Don't signal unsaved changes
1557 
1558  if ( sf->name() == "lookTowards" ) {
1559  sb->ArgStack->setCurrentWidget( argLookToward );
1560  QString s = sf->argVal(0);
1561  argLookToward->FocusEdit->setEditText( s );
1562 
1563  } else if ( sf->name() == "addLabel" || sf->name() == "removeLabel" || sf->name() == "addTrail" || sf->name() == "removeTrail" ) {
1564  sb->ArgStack->setCurrentWidget( argFindObject );
1565  QString s = sf->argVal(0);
1566  argFindObject->NameEdit->setText( s );
1567 
1568  } else if ( sf->name() == "setRaDec" ) {
1569  bool ok(false);
1570  double r(0.0),d(0.0);
1571  dms ra(0.0);
1572 
1573  sb->ArgStack->setCurrentWidget( argSetRaDec );
1574 
1575  ok = !sf->argVal(0).isEmpty();
1576  if (ok) r = sf->argVal(0).toDouble(&ok);
1577  else argSetRaDec->RABox->clear();
1578  if (ok) { ra.setH(r); argSetRaDec->RABox->showInHours( ra ); }
1579 
1580  ok = !sf->argVal(1).isEmpty();
1581  if (ok) d = sf->argVal(1).toDouble(&ok);
1582  else argSetRaDec->DecBox->clear();
1583  if (ok) argSetRaDec->DecBox->showInDegrees( dms(d) );
1584 
1585  } else if ( sf->name() == "setAltAz" ) {
1586  bool ok(false);
1587  double x(0.0),y(0.0);
1588 
1589  sb->ArgStack->setCurrentWidget( argSetAltAz );
1590 
1591  ok = !sf->argVal(0).isEmpty();
1592  if (ok) y = sf->argVal(0).toDouble(&ok);
1593  else argSetAltAz->AzBox->clear();
1594  if (ok) argSetAltAz->AltBox->showInDegrees( dms(y) );
1595  else argSetAltAz->AltBox->clear();
1596 
1597  ok = !sf->argVal(1).isEmpty();
1598  x = sf->argVal(1).toDouble(&ok);
1599  if (ok) argSetAltAz->AzBox->showInDegrees( dms(x) );
1600 
1601  } else if ( sf->name() == "zoomIn" ) {
1602  sb->ArgStack->setCurrentWidget( argBlank );
1603  //no Args
1604 
1605  } else if ( sf->name() == "zoomOut" ) {
1606  sb->ArgStack->setCurrentWidget( argBlank );
1607  //no Args
1608 
1609  } else if ( sf->name() == "defaultZoom" ) {
1610  sb->ArgStack->setCurrentWidget( argBlank );
1611  //no Args
1612 
1613  } else if ( sf->name() == "zoom" ) {
1614  sb->ArgStack->setCurrentWidget( argZoom );
1615  bool ok(false);
1616  /*double z = */sf->argVal(0).toDouble(&ok);
1617  if (ok) argZoom->ZoomBox->setText( sf->argVal(0) );
1618  else argZoom->ZoomBox->setText( "2000." );
1619 
1620  } else if ( sf->name() == "exportImage" ) {
1621  sb->ArgStack->setCurrentWidget( argExportImage );
1622  argExportImage->ExportFileName->setUrl( sf->argVal(0) );
1623  bool ok(false);
1624  int w=0, h=0;
1625  w = sf->argVal(1).toInt( &ok );
1626  if (ok) h = sf->argVal(2).toInt( &ok );
1627  if (ok) {
1628  argExportImage->ExportWidth->setValue( w );
1629  argExportImage->ExportHeight->setValue( h );
1630  } else {
1631  argExportImage->ExportWidth->setValue( ks->map()->width() );
1632  argExportImage->ExportHeight->setValue( ks->map()->height() );
1633  }
1634 
1635  } else if ( sf->name() == "printImage" ) {
1636  if ( sf->argVal(0) == i18n( "true" ) ) argPrintImage->UsePrintDialog->setChecked( true );
1637  else argPrintImage->UsePrintDialog->setChecked( false );
1638  if ( sf->argVal(1) == i18n( "true" ) ) argPrintImage->UseChartColors->setChecked( true );
1639  else argPrintImage->UseChartColors->setChecked( false );
1640 
1641  } else if ( sf->name() == "setLocalTime" ) {
1642  sb->ArgStack->setCurrentWidget( argSetLocalTime );
1643  bool ok(false);
1644  int year=0, month=0, day=0, hour=0, min=0, sec=0;
1645 
1646  year = sf->argVal(0).toInt(&ok);
1647  if (ok) month = sf->argVal(1).toInt(&ok);
1648  if (ok) day = sf->argVal(2).toInt(&ok);
1649  if (ok) argSetLocalTime->DateWidget->setDate( QDate( year, month, day ) );
1650  else argSetLocalTime->DateWidget->setDate( QDate::currentDate() );
1651 
1652  hour = sf->argVal(3).toInt(&ok);
1653  if ( sf->argVal(3).isEmpty() ) ok = false;
1654  if (ok) min = sf->argVal(4).toInt(&ok);
1655  if (ok) sec = sf->argVal(5).toInt(&ok);
1656  if (ok) argSetLocalTime->TimeBox->setTime( QTime( hour, min, sec ) );
1657  else argSetLocalTime->TimeBox->setTime( QTime( QTime::currentTime() ) );
1658 
1659  } else if ( sf->name() == "waitFor" ) {
1660  sb->ArgStack->setCurrentWidget( argWaitFor );
1661  bool ok(false);
1662  int sec = sf->argVal(0).toInt(&ok);
1663  if (ok) argWaitFor->DelayBox->setValue( sec );
1664  else argWaitFor->DelayBox->setValue( 0 );
1665 
1666  } else if ( sf->name() == "waitForKey" ) {
1667  sb->ArgStack->setCurrentWidget( argWaitForKey );
1668  if ( sf->argVal(0).length()==1 || sf->argVal(0).toLower() == "space" )
1669  argWaitForKey->WaitKeyEdit->setText( sf->argVal(0) );
1670  else argWaitForKey->WaitKeyEdit->setText( QString() );
1671 
1672  } else if ( sf->name() == "setTracking" ) {
1673  sb->ArgStack->setCurrentWidget( argSetTracking );
1674  if ( sf->argVal(0) == i18n( "true" ) ) argSetTracking->CheckTrack->setChecked( true );
1675  else argSetTracking->CheckTrack->setChecked( false );
1676 
1677  } else if ( sf->name() == "changeViewOption" ) {
1678  sb->ArgStack->setCurrentWidget( argChangeViewOption );
1679  argChangeViewOption->OptionName->setCurrentIndex(
1680  argChangeViewOption->OptionName->findText( sf->argVal(0) ) );
1681  argChangeViewOption->OptionValue->setText( sf->argVal(1) );
1682 
1683  } else if ( sf->name() == "setGeoLocation" ) {
1684  sb->ArgStack->setCurrentWidget( argSetGeoLocation );
1685  argSetGeoLocation->CityName->setText( sf->argVal(0) );
1686  argSetGeoLocation->ProvinceName->setText( sf->argVal(1) );
1687  argSetGeoLocation->CountryName->setText( sf->argVal(2) );
1688 
1689  } else if ( sf->name() == "setColor" ) {
1690  sb->ArgStack->setCurrentWidget( argSetColor );
1691  if ( sf->argVal(0).isEmpty() ) sf->setArg( 0, "SkyColor" ); //initialize default value
1692  argSetColor->ColorName->setCurrentIndex(
1693  argSetColor->ColorName->findText(
1694  ks->data()->colorScheme()->nameFromKey( sf->argVal(0) ) )
1695  );
1696  argSetColor->ColorValue->setColor( QColor( sf->argVal(1).remove('\\') ) );
1697 
1698  } else if ( sf->name() == "loadColorScheme" ) {
1699  sb->ArgStack->setCurrentWidget( argLoadColorScheme );
1700  argLoadColorScheme->SchemeList->setCurrentItem( argLoadColorScheme->SchemeList->findItems( sf->argVal(0).remove('\"'), Qt::MatchExactly ).at(0) );
1701 
1702  } else if ( sf->name() == "stop" ) {
1703  sb->ArgStack->setCurrentWidget( argBlank );
1704  //no Args
1705 
1706  } else if ( sf->name() == "start" ) {
1707  sb->ArgStack->setCurrentWidget( argBlank );
1708  //no Args
1709 
1710  } else if ( sf->name() == "setClockScale" ) {
1711  sb->ArgStack->setCurrentWidget( argTimeScale );
1712  bool ok(false);
1713  double ts = sf->argVal(0).toDouble(&ok);
1714  if (ok) argTimeScale->TimeScale->tsbox()->changeScale( float(ts) );
1715  else argTimeScale->TimeScale->tsbox()->changeScale( 0.0 );
1716 
1717  }
1718 
1719  //TODO JM: INDI Scripting to be included in KDE 4.1
1720  #if 0
1721  else if (sf->name() == "startINDI") {
1722  sb->ArgStack->setCurrentWidget( argStartINDI);
1723 
1724  argStartINDI->deviceName->setText(sf->argVal(0));
1725  if (sf->argVal(1) == "true")
1726  argStartINDI->LocalButton->setChecked(true);
1727  else if (! sf->argVal(1).isEmpty())
1728  argStartINDI->LocalButton->setChecked(false);
1729  }
1730  else if (sf->name() == "setINDIDevice")
1731  {
1732  sb->ArgStack->setCurrentWidget( argSetDeviceINDI);
1733  argSetDeviceINDI->deviceName->setText(sf->argVal(0));
1734  }
1735  else if (sf->name() == "shutdownINDI") {
1736  sb->ArgStack->setCurrentWidget( argShutdownINDI);
1737  }
1738  else if (sf->name() == "switchINDI") {
1739  sb->ArgStack->setCurrentWidget( argSwitchINDI);
1740 
1741  if (sf->argVal(0) == "true" || sf->argVal(0).isEmpty())
1742  argSwitchINDI->OnButton->setChecked(true);
1743  else
1744  argSwitchINDI->OffButton->setChecked(true);
1745  }
1746  else if (sf->name() == "setINDIPort") {
1747  sb->ArgStack->setCurrentWidget( argSetPortINDI);
1748 
1749  argSetPortINDI->devicePort->setText(sf->argVal(0));
1750 
1751 
1752  }
1753  else if (sf->name() == "setINDITargetCoord") {
1754  bool ok(false);
1755  double r(0.0),d(0.0);
1756  dms ra(0.0);
1757 
1758  sb->ArgStack->setCurrentWidget( argSetTargetCoordINDI);
1759 
1760  ok = !sf->argVal(0).isEmpty();
1761  if (ok) r = sf->argVal(0).toDouble(&ok);
1762  else argSetTargetCoordINDI->RABox->clear();
1763  if (ok) { ra.setH(r); argSetTargetCoordINDI->RABox->showInHours( ra ); }
1764 
1765  ok = !sf->argVal(1).isEmpty();
1766  if (ok) d = sf->argVal(1).toDouble(&ok);
1767  else argSetTargetCoordINDI->DecBox->clear();
1768  if (ok) argSetTargetCoordINDI->DecBox->showInDegrees( dms(d) );
1769 
1770 
1771  }
1772  else if (sf->name() == "setINDITargetName") {
1773  sb->ArgStack->setCurrentWidget( argSetTargetNameINDI);
1774 
1775  argSetTargetNameINDI->targetName->setText(sf->argVal(0));
1776 
1777 
1778  }
1779  else if (sf->name() == "setINDIAction") {
1780  sb->ArgStack->setCurrentWidget( argSetActionINDI);
1781 
1782  argSetActionINDI->actionName->setText(sf->argVal(0));
1783 
1784 
1785  }
1786  else if (sf->name() == "waitForINDIAction") {
1787  sb->ArgStack->setCurrentWidget( argWaitForActionINDI);
1788 
1789  argWaitForActionINDI->actionName->setText(sf->argVal(0));
1790 
1791 
1792  }
1793  else if (sf->name() == "setINDIFocusSpeed") {
1794  int t(0);
1795  bool ok(false);
1796 
1797  sb->ArgStack->setCurrentWidget( argSetFocusSpeedINDI);
1798 
1799  t = sf->argVal(0).toInt(&ok);
1800  if (ok) argSetFocusSpeedINDI->speedIN->setValue(t);
1801  else argSetFocusSpeedINDI->speedIN->setValue(0);
1802 
1803 
1804  }
1805  else if (sf->name() == "startINDIFocus") {
1806  sb->ArgStack->setCurrentWidget( argStartFocusINDI);
1807  bool itemSet(false);
1808 
1809  for (int i=0; i < argStartFocusINDI->directionCombo->count(); i++)
1810  {
1811  if (argStartFocusINDI->directionCombo->itemText(i) == sf->argVal(0))
1812  {
1813  argStartFocusINDI->directionCombo->setCurrentIndex(i);
1814  itemSet = true;
1815  break;
1816  }
1817  }
1818 
1819  if (!itemSet) argStartFocusINDI->directionCombo->setCurrentIndex(0);
1820 
1821 
1822  }
1823  else if (sf->name() == "setINDIFocusTimeout") {
1824  int t(0);
1825  bool ok(false);
1826 
1827  sb->ArgStack->setCurrentWidget( argSetFocusTimeoutINDI);
1828 
1829  t = sf->argVal(0).toInt(&ok);
1830  if (ok) argSetFocusTimeoutINDI->timeOut->setValue(t);
1831  else argSetFocusTimeoutINDI->timeOut->setValue(0);
1832 
1833 
1834  }
1835  else if (sf->name() == "setINDIGeoLocation") {
1836  bool ok(false);
1837  double lo(0.0),la(0.0);
1838 
1839  sb->ArgStack->setCurrentWidget( argSetGeoLocationINDI);
1840 
1841  ok = !sf->argVal(0).isEmpty();
1842  if (ok) lo = sf->argVal(0).toDouble(&ok);
1843  else argSetGeoLocationINDI->longBox->clear();
1844  if (ok) { argSetGeoLocationINDI->longBox->showInDegrees( dms(lo) ); }
1845 
1846  ok = !sf->argVal(1).isEmpty();
1847  if (ok) la = sf->argVal(1).toDouble(&ok);
1848  else argSetGeoLocationINDI->latBox->clear();
1849  if (ok) argSetGeoLocationINDI->latBox->showInDegrees( dms(la) );
1850 
1851  }
1852  else if (sf->name() == "startINDIExposure") {
1853  int t(0);
1854  bool ok(false);
1855 
1856  sb->ArgStack->setCurrentWidget( argStartExposureINDI);
1857 
1858  t = sf->argVal(0).toInt(&ok);
1859  if (ok) argStartExposureINDI->timeOut->setValue(t);
1860  else argStartExposureINDI->timeOut->setValue(0);
1861 
1862  }
1863  else if (sf->name() == "setINDIUTC") {
1864  sb->ArgStack->setCurrentWidget( argSetUTCINDI);
1865 
1866  argSetUTCINDI->UTC->setText(sf->argVal(0));
1867 
1868  }
1869  else if (sf->name() == "setINDIScopeAction") {
1870  sb->ArgStack->setCurrentWidget( argSetScopeActionINDI);
1871  bool itemSet(false);
1872 
1873  for (int i=0; i < argSetScopeActionINDI->actionCombo->count(); i++)
1874  {
1875  if (argSetScopeActionINDI->actionCombo->itemText(i) == sf->argVal(0))
1876  {
1877  argSetScopeActionINDI->actionCombo->setCurrentIndex(i);
1878  itemSet = true;
1879  break;
1880  }
1881  }
1882 
1883  if (!itemSet) argSetScopeActionINDI->actionCombo->setCurrentIndex(0);
1884 
1885  }
1886  else if (sf->name() == "setINDIFrameType") {
1887  sb->ArgStack->setCurrentWidget( argSetFrameTypeINDI);
1888  bool itemSet(false);
1889 
1890  for (int i=0; i < argSetFrameTypeINDI->typeCombo->count(); i++)
1891  {
1892  if (argSetFrameTypeINDI->typeCombo->itemText(i) == sf->argVal(0))
1893  {
1894  argSetFrameTypeINDI->typeCombo->setCurrentIndex(i);
1895  itemSet = true;
1896  break;
1897  }
1898  }
1899 
1900  if (!itemSet) argSetFrameTypeINDI->typeCombo->setCurrentIndex(0);
1901 
1902  }
1903  else if (sf->name() == "setINDICCDTemp") {
1904  int t(0);
1905  bool ok(false);
1906 
1907  sb->ArgStack->setCurrentWidget( argSetCCDTempINDI);
1908 
1909  t = sf->argVal(0).toInt(&ok);
1910  if (ok) argSetCCDTempINDI->temp->setValue(t);
1911  else argSetCCDTempINDI->temp->setValue(0);
1912 
1913  }
1914  else if (sf->name() == "setINDIFilterNum") {
1915  int t(0);
1916  bool ok(false);
1917 
1918  sb->ArgStack->setCurrentWidget( argSetFilterNumINDI);
1919 
1920  t = sf->argVal(0).toInt(&ok);
1921  if (ok) argSetFilterNumINDI->filter_num->setValue(t);
1922  else argSetFilterNumINDI->filter_num->setValue(0);
1923 
1924  }
1925  #endif
1926 
1927  checkForChanges = true; //signal unsaved changes if the argument widgets are changed
1928  }
1929 }
1930 
1931 void ScriptBuilder::slotShowDoc() {
1932  ScriptFunction *sc = NULL, *found= NULL;
1933  QTreeWidgetItem *currentItem = sb->FunctionTree->currentItem();
1934 
1935  if ( currentItem == NULL || currentItem->parent() == 0)
1936  return;
1937 
1938  foreach ( sc, KStarsFunctionList )
1939  if (sc->prototype() == currentItem->text(0))
1940  {
1941  found = sc;
1942  break;
1943  }
1944 
1945  foreach ( sc, SimClockFunctionList )
1946  if (sc->prototype() == currentItem->text(0))
1947  {
1948  found = sc;
1949  break;
1950  }
1951 
1952 #if 0
1953  if (found == NULL)
1954  {
1955  foreach (sc, INDIFunctionList )
1956  if (sc->prototype() == currentItem->text(0))
1957  {
1958  found = sc;
1959  break;
1960  }
1961  }
1962 #endif
1963 
1964  if (found == NULL)
1965  {
1966  sb->AddButton->setEnabled( false );
1967  kWarning() << i18n( "Function index out of bounds." ) ;
1968  return;
1969  }
1970 
1971  sb->AddButton->setEnabled( true );
1972  sb->FuncDoc->setHtml( found->description() );
1973 }
1974 
1975 //Slots for Arg Widgets
1976 void ScriptBuilder::slotFindCity() {
1977  QPointer<LocationDialog> ld = new LocationDialog( this );
1978 
1979  if ( ld->exec() == QDialog::Accepted ) {
1980  if ( ld->selectedCity() ) {
1981  // set new location names
1982  argSetGeoLocation->CityName->setText( ld->selectedCityName() );
1983  if ( ! ld->selectedProvinceName().isEmpty() ) {
1984  argSetGeoLocation->ProvinceName->setText( ld->selectedProvinceName() );
1985  } else {
1986  argSetGeoLocation->ProvinceName->clear();
1987  }
1988  argSetGeoLocation->CountryName->setText( ld->selectedCountryName() );
1989 
1990  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
1991  if ( sf->name() == "setGeoLocation" ) {
1992  setUnsavedChanges( true );
1993 
1994  sf->setArg( 0, ld->selectedCityName() );
1995  sf->setArg( 1, ld->selectedProvinceName() );
1996  sf->setArg( 2, ld->selectedCountryName() );
1997  } else {
1998  warningMismatch( "setGeoLocation" );
1999  }
2000  }
2001  }
2002  delete ld;
2003 }
2004 
2005 void ScriptBuilder::slotFindObject() {
2006  QPointer<FindDialog> fd = new FindDialog( ks );
2007 
2008  if ( fd->exec() == QDialog::Accepted && fd->selectedObject() ) {
2009  setUnsavedChanges( true );
2010 
2011  argLookToward->FocusEdit->setEditText( fd->selectedObject()->name() );
2012  }
2013  delete fd;
2014 }
2015 
2016 //TODO JM: INDI Scripting to be included in KDE 4.1
2017 
2018 #if 0
2019 void ScriptBuilder::slotINDIFindObject() {
2020  FindDialog fd( ks );
2021 
2022  if ( fd.exec() == QDialog::Accepted && fd.selectedObject() ) {
2023  setUnsavedChanges( true );
2024 
2025  argSetTargetNameINDI->targetName->setText( fd.selectedObject()->name() );
2026  }
2027 }
2028 
2029 void ScriptBuilder::slotINDIWaitCheck(bool /*toggleState*/)
2030 {
2031 
2032  setUnsavedChanges(true);
2033 
2034 }
2035 #endif
2036 
2037 void ScriptBuilder::slotShowOptions() {
2038  //Show tree-view of view options
2039  if ( otv->exec() == QDialog::Accepted ) {
2040  argChangeViewOption->OptionName->setCurrentIndex(
2041  argChangeViewOption->OptionName->findText(
2042  otv->optionsList()->currentItem()->text(0) )
2043  );
2044  }
2045 }
2046 
2047 void ScriptBuilder::slotLookToward() {
2048  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2049 
2050  if ( sf->name() == "lookTowards" ) {
2051  setUnsavedChanges( true );
2052 
2053  sf->setArg( 0, argLookToward->FocusEdit->currentText() );
2054  sf->setValid(true);
2055  } else {
2056  warningMismatch( "lookTowards" );
2057  }
2058 }
2059 
2060 void ScriptBuilder::slotArgFindObject() {
2061  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2062 
2063  if ( sf->name() == "addLabel" || sf->name() == "removeLabel" || sf->name() == "addTrail" || sf->name() == "removeTrail" ) {
2064  setUnsavedChanges( true );
2065 
2066  sf->setArg( 0, argFindObject->NameEdit->text() );
2067  sf->setValid(true);
2068  } else {
2069  warningMismatch( sf->name() );
2070  }
2071 }
2072 
2073 void ScriptBuilder::slotRa() {
2074  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2075 
2076  if ( sf->name() == "setRaDec" ) {
2077  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2078  if ( argSetRaDec->RABox->text().isEmpty() ) return;
2079 
2080  bool ok(false);
2081  dms ra = argSetRaDec->RABox->createDms(false, &ok);
2082  if ( ok ) {
2083  setUnsavedChanges( true );
2084 
2085  sf->setArg( 0, QString( "%1" ).arg( ra.Hours() ) );
2086  if ( ! sf->argVal(1).isEmpty() ) sf->setValid( true );
2087 
2088  } else {
2089  sf->setArg( 0, QString() );
2090  sf->setValid( false );
2091  }
2092  } else {
2093  warningMismatch( "setRaDec" );
2094  }
2095 }
2096 
2097 void ScriptBuilder::slotDec() {
2098  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2099 
2100  if ( sf->name() == "setRaDec" ) {
2101  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2102  if ( argSetRaDec->DecBox->text().isEmpty() ) return;
2103 
2104  bool ok(false);
2105  dms dec = argSetRaDec->DecBox->createDms(true, &ok);
2106  if ( ok ) {
2107  setUnsavedChanges( true );
2108 
2109  sf->setArg( 1, QString( "%1" ).arg( dec.Degrees() ) );
2110  if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
2111 
2112  } else {
2113  sf->setArg( 1, QString() );
2114  sf->setValid( false );
2115  }
2116  } else {
2117  warningMismatch( "setRaDec" );
2118  }
2119 }
2120 
2121 void ScriptBuilder::slotAz() {
2122  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2123 
2124  if ( sf->name() == "setAltAz" ) {
2125  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2126  if ( argSetAltAz->AzBox->text().isEmpty() ) return;
2127 
2128  bool ok(false);
2129  dms az = argSetAltAz->AzBox->createDms(true, &ok);
2130  if ( ok ) {
2131  setUnsavedChanges( true );
2132  sf->setArg( 1, QString( "%1" ).arg( az.Degrees() ) );
2133  if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
2134  } else {
2135  sf->setArg( 1, QString() );
2136  sf->setValid( false );
2137  }
2138  } else {
2139  warningMismatch( "setAltAz" );
2140  }
2141 }
2142 
2143 void ScriptBuilder::slotAlt() {
2144  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2145 
2146  if ( sf->name() == "setAltAz" ) {
2147  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2148  if ( argSetAltAz->AltBox->text().isEmpty() ) return;
2149 
2150  bool ok(false);
2151  dms alt = argSetAltAz->AltBox->createDms(true, &ok);
2152  if ( ok ) {
2153  setUnsavedChanges( true );
2154 
2155  sf->setArg( 0, QString( "%1" ).arg( alt.Degrees() ) );
2156  if ( ! sf->argVal(1).isEmpty() ) sf->setValid( true );
2157  } else {
2158  sf->setArg( 0, QString() );
2159  sf->setValid( false );
2160  }
2161  } else {
2162  warningMismatch( "setAltAz" );
2163  }
2164 }
2165 
2166 void ScriptBuilder::slotChangeDate() {
2167  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2168 
2169  if ( sf->name() == "setLocalTime" ) {
2170  setUnsavedChanges( true );
2171 
2172  QDate date = argSetLocalTime->DateWidget->date();
2173 
2174  sf->setArg( 0, QString( "%1" ).arg( date.year() ) );
2175  sf->setArg( 1, QString( "%1" ).arg( date.month() ) );
2176  sf->setArg( 2, QString( "%1" ).arg( date.day() ) );
2177  if ( ! sf->argVal(3).isEmpty() ) sf->setValid( true );
2178  } else {
2179  warningMismatch( "setLocalTime" );
2180  }
2181 }
2182 
2183 void ScriptBuilder::slotChangeTime() {
2184  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2185 
2186  if ( sf->name() == "setLocalTime" ) {
2187  setUnsavedChanges( true );
2188 
2189  QTime time = argSetLocalTime->TimeBox->time();
2190 
2191  sf->setArg( 3, QString( "%1" ).arg( time.hour() ) );
2192  sf->setArg( 4, QString( "%1" ).arg( time.minute() ) );
2193  sf->setArg( 5, QString( "%1" ).arg( time.second() ) );
2194  if ( ! sf->argVal(0).isEmpty() ) sf->setValid( true );
2195  } else {
2196  warningMismatch( "setLocalTime" );
2197  }
2198 }
2199 
2200 void ScriptBuilder::slotWaitFor() {
2201  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2202 
2203  if ( sf->name() == "waitFor" ) {
2204  bool ok(false);
2205  int delay = argWaitFor->DelayBox->text().toInt( &ok );
2206 
2207  if ( ok ) {
2208  setUnsavedChanges( true );
2209 
2210  sf->setArg( 0, QString( "%1" ).arg( delay ) );
2211  sf->setValid( true );
2212  } else {
2213  sf->setValid( false );
2214  }
2215  } else {
2216  warningMismatch( "waitFor" );
2217  }
2218 }
2219 
2220 void ScriptBuilder::slotWaitForKey() {
2221  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2222 
2223  if ( sf->name() == "waitForKey" ) {
2224  QString sKey = argWaitForKey->WaitKeyEdit->text().trimmed();
2225 
2226  //DCOP script can only use single keystrokes; make sure entry is either one character,
2227  //or the word 'space'
2228  if ( sKey.length() == 1 || sKey == "space" ) {
2229  setUnsavedChanges( true );
2230 
2231  sf->setArg( 0, sKey );
2232  sf->setValid( true );
2233  } else {
2234  sf->setValid( false );
2235  }
2236  } else {
2237  warningMismatch( "waitForKey" );
2238  }
2239 }
2240 
2241 void ScriptBuilder::slotTracking() {
2242  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2243 
2244  if ( sf->name() == "setTracking" ) {
2245  setUnsavedChanges( true );
2246 
2247  sf->setArg( 0, ( argSetTracking->CheckTrack->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
2248  sf->setValid( true );
2249  } else {
2250  warningMismatch( "setTracking" );
2251  }
2252 }
2253 
2254 void ScriptBuilder::slotViewOption() {
2255  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2256 
2257  if ( sf->name() == "changeViewOption" ) {
2258  if ( argChangeViewOption->OptionName->currentIndex() >= 0
2259  && argChangeViewOption->OptionValue->text().length() ) {
2260  setUnsavedChanges( true );
2261 
2262  sf->setArg( 0, argChangeViewOption->OptionName->currentText() );
2263  sf->setArg( 1, argChangeViewOption->OptionValue->text() );
2264  sf->setValid( true );
2265  } else {
2266  sf->setValid( false );
2267  }
2268  } else {
2269  warningMismatch( "changeViewOption" );
2270  }
2271 }
2272 
2273 void ScriptBuilder::slotChangeCity() {
2274  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2275 
2276  if ( sf->name() == "setGeoLocation" ) {
2277  QString city = argSetGeoLocation->CityName->text();
2278 
2279  if ( city.length() ) {
2280  setUnsavedChanges( true );
2281 
2282  sf->setArg( 0, city );
2283  if ( sf->argVal(2).length() ) sf->setValid( true );
2284  } else {
2285  sf->setArg( 0, QString() );
2286  sf->setValid( false );
2287  }
2288  } else {
2289  warningMismatch( "setGeoLocation" );
2290  }
2291 }
2292 
2293 void ScriptBuilder::slotChangeProvince() {
2294  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2295 
2296  if ( sf->name() == "setGeoLocation" ) {
2297  QString province = argSetGeoLocation->ProvinceName->text();
2298 
2299  if ( province.length() ) {
2300  setUnsavedChanges( true );
2301 
2302  sf->setArg( 1, province );
2303  if ( sf->argVal(0).length() && sf->argVal(2).length() ) sf->setValid( true );
2304  } else {
2305  sf->setArg( 1, QString() );
2306  //might not be invalid
2307  }
2308  } else {
2309  warningMismatch( "setGeoLocation" );
2310  }
2311 }
2312 
2313 void ScriptBuilder::slotChangeCountry() {
2314  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2315 
2316  if ( sf->name() == "setGeoLocation" ) {
2317  QString country = argSetGeoLocation->CountryName->text();
2318 
2319  if ( country.length() ) {
2320  setUnsavedChanges( true );
2321 
2322  sf->setArg( 2, country );
2323  if ( sf->argVal(0).length() ) sf->setValid( true );
2324  } else {
2325  sf->setArg( 2, QString() );
2326  sf->setValid( false );
2327  }
2328  } else {
2329  warningMismatch( "setGeoLocation" );
2330  }
2331 }
2332 
2333 void ScriptBuilder::slotTimeScale() {
2334  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2335 
2336  if ( sf->name() == "setClockScale" ) {
2337  setUnsavedChanges( true );
2338 
2339  sf->setArg( 0, QString( "%1" ).arg( argTimeScale->TimeScale->tsbox()->timeScale() ) );
2340  sf->setValid( true );
2341  } else {
2342  warningMismatch( "setClockScale" );
2343  }
2344 }
2345 
2346 void ScriptBuilder::slotZoom() {
2347  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2348 
2349  if ( sf->name() == "zoom" ) {
2350  setUnsavedChanges( true );
2351 
2352  bool ok(false);
2353  argZoom->ZoomBox->text().toDouble(&ok);
2354  if ( ok ) {
2355  sf->setArg( 0, argZoom->ZoomBox->text() );
2356  sf->setValid( true );
2357  }
2358  } else {
2359  warningMismatch( "zoom" );
2360  }
2361 }
2362 
2363 void ScriptBuilder::slotExportImage() {
2364  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2365 
2366  if ( sf->name() == "exportImage" ) {
2367  setUnsavedChanges( true );
2368 
2369  sf->setArg( 0, argExportImage->ExportFileName->url().url() );
2370  sf->setArg( 1, QString("%1").arg( argExportImage->ExportWidth->value() ) );
2371  sf->setArg( 2, QString("%1").arg( argExportImage->ExportHeight->value() ) );
2372  sf->setValid( true );
2373  } else {
2374  warningMismatch( "exportImage" );
2375  }
2376 }
2377 
2378 void ScriptBuilder::slotPrintImage() {
2379  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2380 
2381  if ( sf->name() == "printImage" ) {
2382  setUnsavedChanges( true );
2383 
2384  sf->setArg( 0, ( argPrintImage->UsePrintDialog->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
2385  sf->setArg( 1, ( argPrintImage->UseChartColors->isChecked() ? i18n( "true" ) : i18n( "false" ) ) );
2386  sf->setValid( true );
2387  } else {
2388  warningMismatch( "exportImage" );
2389  }
2390 }
2391 
2392 void ScriptBuilder::slotChangeColorName() {
2393  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2394 
2395  if ( sf->name() == "setColor" ) {
2396  setUnsavedChanges( true );
2397 
2398  argSetColor->ColorValue->setColor( ks->data()->colorScheme()->colorAt( argSetColor->ColorName->currentIndex() ) );
2399  sf->setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentIndex() ) );
2400  QString cname( argSetColor->ColorValue->color().name() );
2401  //if ( cname.at(0) == '#' ) cname = "\\" + cname; //prepend a "\" so bash doesn't think we have a comment
2402  sf->setArg( 1, cname );
2403  sf->setValid( true );
2404  } else {
2405  warningMismatch( "setColor" );
2406  }
2407 }
2408 
2409 void ScriptBuilder::slotChangeColor() {
2410  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2411 
2412  if ( sf->name() == "setColor" ) {
2413  setUnsavedChanges( true );
2414 
2415  sf->setArg( 0, ks->data()->colorScheme()->keyAt( argSetColor->ColorName->currentIndex() ) );
2416  QString cname( argSetColor->ColorValue->color().name() );
2417  //if ( cname.at(0) == '#' ) cname = "\\" + cname; //prepend a "\" so bash doesn't think we have a comment
2418  sf->setArg( 1, cname );
2419  sf->setValid( true );
2420  } else {
2421  warningMismatch( "setColor" );
2422  }
2423 }
2424 
2425 void ScriptBuilder::slotLoadColorScheme() {
2426  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2427 
2428  if ( sf->name() == "loadColorScheme" ) {
2429  setUnsavedChanges( true );
2430 
2431  sf->setArg( 0, '\"' + argLoadColorScheme->SchemeList->currentItem()->text() + '\"' );
2432  sf->setValid( true );
2433  } else {
2434  warningMismatch( "loadColorScheme" );
2435  }
2436 }
2437 
2438 void ScriptBuilder::slotClose()
2439 {
2440  saveWarning();
2441 
2442  if ( !UnsavedChanges ) {
2443  ScriptList.clear();
2444  sb->ScriptListBox->clear();
2445  sb->ArgStack->setCurrentWidget( argBlank );
2446  close();
2447  }
2448 }
2449 
2450 //TODO JM: INDI Scripting to be included in KDE 4.1
2451 
2452 #if 0
2453 void ScriptBuilder::slotINDIStartDeviceName()
2454 {
2455  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2456 
2457  if ( sf->name() == "startINDI" )
2458  {
2459  setUnsavedChanges( true );
2460 
2461  sf->setArg(0, argStartINDI->deviceName->text());
2462  sf->setArg(1, argStartINDI->LocalButton->isChecked() ? "true" : "false");
2463  sf->setValid(true);
2464  }
2465  else
2466  {
2467  warningMismatch( "startINDI" );
2468  }
2469 
2470 }
2471 
2472 void ScriptBuilder::slotINDIStartDeviceMode()
2473 {
2474 
2475  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2476 
2477  if ( sf->name() == "startINDI" )
2478  {
2479  setUnsavedChanges( true );
2480 
2481  sf->setArg(1, argStartINDI->LocalButton->isChecked() ? "true" : "false");
2482  sf->setValid(true);
2483  }
2484  else
2485  {
2486  warningMismatch( "startINDI" );
2487  }
2488 
2489 }
2490 
2491 void ScriptBuilder::slotINDISetDevice()
2492 {
2493 
2494  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2495 
2496  if ( sf->name() == "setINDIDevice" )
2497  {
2498  setUnsavedChanges( true );
2499 
2500  sf->setArg(0, argSetDeviceINDI->deviceName->text());
2501  sf->setValid(true);
2502  }
2503  else
2504  {
2505  warningMismatch( "startINDI" );
2506  }
2507 }
2508 
2509 void ScriptBuilder::slotINDIShutdown()
2510 {
2511 
2512  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2513 
2514  if ( sf->name() == "shutdownINDI" )
2515  {
2516  if (argShutdownINDI->deviceName->text().isEmpty())
2517  {
2518  sf->setValid(false);
2519  return;
2520  }
2521 
2522  if (sf->argVal(0) != argShutdownINDI->deviceName->text())
2523  setUnsavedChanges( true );
2524 
2525  sf->setArg(0, argShutdownINDI->deviceName->text());
2526  sf->setValid(true);
2527  }
2528  else
2529  {
2530  warningMismatch( "shutdownINDI" );
2531  }
2532 
2533 }
2534 
2535 void ScriptBuilder::slotINDISwitchDeviceConnection()
2536 {
2537 
2538  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2539 
2540  if ( sf->name() == "switchINDI" )
2541  {
2542 
2543  if (sf->argVal(0) != (argSwitchINDI->OnButton->isChecked() ? "true" : "false"))
2544  setUnsavedChanges( true );
2545 
2546  sf->setArg(0, argSwitchINDI->OnButton->isChecked() ? "true" : "false");
2547  sf->setValid(true);
2548  }
2549  else
2550  {
2551  warningMismatch( "switchINDI" );
2552  }
2553 
2554 }
2555 
2556 void ScriptBuilder::slotINDISetPortDevicePort()
2557 {
2558  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2559 
2560  if ( sf->name() == "setINDIPort" )
2561  {
2562 
2563  if (argSetPortINDI->devicePort->text().isEmpty())
2564  {
2565  sf->setValid(false);
2566  return;
2567  }
2568 
2569  if (sf->argVal(0) != argSetPortINDI->devicePort->text())
2570  setUnsavedChanges( true );
2571 
2572  sf->setArg(0, argSetPortINDI->devicePort->text());
2573  sf->setValid(true);
2574  }
2575  else
2576  {
2577  warningMismatch( "setINDIPort" );
2578  }
2579 
2580 }
2581 
2582 void ScriptBuilder::slotINDISetTargetCoordDeviceRA()
2583 {
2584  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2585 
2586  if ( sf->name() == "setINDITargetCoord" ) {
2587  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2588  if ( argSetTargetCoordINDI->RABox->text().isEmpty() )
2589  {
2590  sf->setValid(false);
2591  return;
2592  }
2593 
2594  bool ok(false);
2595  dms ra = argSetTargetCoordINDI->RABox->createDms(false, &ok);
2596  if ( ok )
2597  {
2598 
2599  if (sf->argVal(0) != QString( "%1" ).arg( ra.Hours() ))
2600  setUnsavedChanges( true );
2601 
2602  sf->setArg( 0, QString( "%1" ).arg( ra.Hours() ) );
2603  if ( ( ! sf->argVal(1).isEmpty() ))
2604  sf->setValid( true );
2605  else
2606  sf->setValid(false);
2607 
2608  } else
2609  {
2610  sf->setArg( 0, QString() );
2611  sf->setValid( false );
2612  }
2613  } else {
2614  warningMismatch( "setINDITargetCoord" );
2615  }
2616 
2617 }
2618 
2619 void ScriptBuilder::slotINDISetTargetCoordDeviceDEC()
2620 {
2621  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2622 
2623  if ( sf->name() == "setINDITargetCoord" ) {
2624  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2625  if ( argSetTargetCoordINDI->DecBox->text().isEmpty() )
2626  {
2627  sf->setValid(false);
2628  return;
2629  }
2630 
2631  bool ok(false);
2632  dms dec = argSetTargetCoordINDI->DecBox->createDms(true, &ok);
2633  if ( ok )
2634  {
2635 
2636  if (sf->argVal(1) != QString( "%1" ).arg( dec.Degrees() ))
2637  setUnsavedChanges( true );
2638 
2639  sf->setArg( 1, QString( "%1" ).arg( dec.Degrees() ) );
2640  if ( ( ! sf->argVal(0).isEmpty() ))
2641  sf->setValid( true );
2642  else
2643  sf->setValid(false);
2644 
2645  } else
2646  {
2647  sf->setArg( 1, QString() );
2648  sf->setValid( false );
2649  }
2650  } else {
2651  warningMismatch( "setINDITargetCoord" );
2652  }
2653 
2654 }
2655 
2656 void ScriptBuilder::slotINDISetTargetNameTargetName()
2657 {
2658 
2659  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2660 
2661  if ( sf->name() == "setINDITargetName" )
2662  {
2663  if (argSetTargetNameINDI->targetName->text().isEmpty())
2664  {
2665  sf->setValid(false);
2666  return;
2667  }
2668 
2669  if (sf->argVal(0) != argSetTargetNameINDI->targetName->text())
2670  setUnsavedChanges( true );
2671 
2672  sf->setArg(0, argSetTargetNameINDI->targetName->text());
2673  sf->setValid(true);
2674  }
2675  else
2676  {
2677  warningMismatch( "setINDITargetName" );
2678  }
2679 
2680 }
2681 
2682 void ScriptBuilder::slotINDISetActionName()
2683 {
2684  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2685 
2686  if ( sf->name() == "setINDIAction" )
2687  {
2688  if (argSetActionINDI->actionName->text().isEmpty())
2689  {
2690  sf->setValid(false);
2691  return;
2692  }
2693 
2694  if (sf->argVal(0) != argSetActionINDI->actionName->text())
2695  setUnsavedChanges( true );
2696 
2697  sf->setArg(0, argSetActionINDI->actionName->text());
2698  sf->setValid(true);
2699  }
2700  else
2701  {
2702  warningMismatch( "setINDIAction" );
2703  }
2704 
2705 }
2706 
2707 void ScriptBuilder::slotINDIWaitForActionName()
2708 {
2709  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2710 
2711  if ( sf->name() == "waitForINDIAction" )
2712  {
2713  if (argWaitForActionINDI->actionName->text().isEmpty())
2714  {
2715  sf->setValid(false);
2716  return;
2717  }
2718 
2719  if (sf->argVal(0) != argWaitForActionINDI->actionName->text())
2720  setUnsavedChanges( true );
2721 
2722  sf->setArg(0, argWaitForActionINDI->actionName->text());
2723  sf->setValid(true);
2724  }
2725  else
2726  {
2727  warningMismatch( "waitForINDIAction" );
2728  }
2729 
2730 }
2731 
2732 void ScriptBuilder::slotINDISetFocusSpeed()
2733 {
2734  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2735 
2736  if ( sf->name() == "setINDIFocusSpeed" )
2737  {
2738 
2739  if (sf->argVal(0).toInt() != argSetFocusSpeedINDI->speedIN->value())
2740  setUnsavedChanges( true );
2741 
2742  sf->setArg(0, QString("%1").arg(argSetFocusSpeedINDI->speedIN->value()));
2743  sf->setValid(true);
2744  }
2745  else
2746  {
2747  warningMismatch( "setINDIFocusSpeed" );
2748  }
2749 
2750 }
2751 
2752 void ScriptBuilder::slotINDIStartFocusDirection()
2753 {
2754  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2755 
2756  if ( sf->name() == "startINDIFocus" )
2757  {
2758  if (sf->argVal(0) != argStartFocusINDI->directionCombo->currentText())
2759  setUnsavedChanges( true );
2760 
2761  sf->setArg(0, argStartFocusINDI->directionCombo->currentText());
2762  sf->setValid(true);
2763  }
2764  else
2765  {
2766  warningMismatch( "startINDIFocus" );
2767  }
2768 
2769 }
2770 
2771 void ScriptBuilder::slotINDISetFocusTimeout()
2772 {
2773  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2774 
2775  if ( sf->name() == "setINDIFocusTimeout" )
2776  {
2777  if (sf->argVal(0).toInt() != argSetFocusTimeoutINDI->timeOut->value())
2778  setUnsavedChanges( true );
2779 
2780  sf->setArg(0, QString("%1").arg(argSetFocusTimeoutINDI->timeOut->value()));
2781  sf->setValid(true);
2782  }
2783  else
2784  {
2785  warningMismatch( "setINDIFocusTimeout" );
2786  }
2787 
2788 }
2789 
2790 void ScriptBuilder::slotINDISetGeoLocationDeviceLong()
2791 {
2792  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2793 
2794  if ( sf->name() == "setINDIGeoLocation" ) {
2795  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2796  if ( argSetGeoLocationINDI->longBox->text().isEmpty())
2797  {
2798  sf->setValid(false);
2799  return;
2800  }
2801 
2802  bool ok(false);
2803  dms longitude = argSetGeoLocationINDI->longBox->createDms(true, &ok);
2804  if ( ok ) {
2805 
2806  if (sf->argVal(0) != QString( "%1" ).arg( longitude.Degrees()))
2807  setUnsavedChanges( true );
2808 
2809  sf->setArg( 0, QString( "%1" ).arg( longitude.Degrees() ) );
2810  if ( ! sf->argVal(1).isEmpty() )
2811  sf->setValid( true );
2812  else
2813  sf->setValid(false);
2814 
2815  } else
2816  {
2817  sf->setArg( 0, QString() );
2818  sf->setValid( false );
2819  }
2820  } else {
2821  warningMismatch( "setINDIGeoLocation" );
2822  }
2823 
2824 }
2825 
2826 void ScriptBuilder::slotINDISetGeoLocationDeviceLat()
2827 {
2828  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2829 
2830  if ( sf->name() == "setINDIGeoLocation" ) {
2831  //do nothing if box is blank (because we could be clearing boxes while switcing argWidgets)
2832  if ( argSetGeoLocationINDI->latBox->text().isEmpty() )
2833  {
2834  sf->setValid(false);
2835  return;
2836  }
2837 
2838  bool ok(false);
2839  dms latitude = argSetGeoLocationINDI->latBox->createDms(true, &ok);
2840  if ( ok ) {
2841 
2842  if (sf->argVal(1) != QString( "%1" ).arg( latitude.Degrees()))
2843  setUnsavedChanges( true );
2844 
2845  sf->setArg( 1, QString( "%1" ).arg( latitude.Degrees() ) );
2846  if ( ! sf->argVal(0).isEmpty() )
2847  sf->setValid( true );
2848  else
2849  sf->setValid(false);
2850 
2851  } else
2852  {
2853  sf->setArg( 1, QString() );
2854  sf->setValid( false );
2855  }
2856  } else {
2857  warningMismatch( "setINDIGeoLocation" );
2858  }
2859 
2860 }
2861 
2862 void ScriptBuilder::slotINDIStartExposureTimeout()
2863 {
2864  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2865 
2866  if ( sf->name() == "startINDIExposure" )
2867  {
2868 
2869  if (sf->argVal(0).toInt() != argStartExposureINDI->timeOut->value())
2870  setUnsavedChanges( true );
2871 
2872  sf->setArg(0, QString("%1").arg(argStartExposureINDI->timeOut->value()));
2873  sf->setValid(true);
2874  }
2875  else
2876  {
2877  warningMismatch( "startINDIExposure" );
2878  }
2879 
2880 }
2881 
2882 void ScriptBuilder::slotINDISetUTC()
2883 {
2884  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2885 
2886  if ( sf->name() == "setINDIUTC" )
2887  {
2888 
2889  if (argSetUTCINDI->UTC->text().isEmpty())
2890  {
2891  sf->setValid(false);
2892  return;
2893  }
2894 
2895  if (sf->argVal(0) != argSetUTCINDI->UTC->text())
2896  setUnsavedChanges( true );
2897 
2898  sf->setArg(0, argSetUTCINDI->UTC->text());
2899  sf->setValid(true);
2900  }
2901  else
2902  {
2903  warningMismatch( "setINDIUTC" );
2904  }
2905 
2906 }
2907 
2908 void ScriptBuilder::slotINDISetScopeAction()
2909 {
2910  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2911 
2912  if ( sf->name() == "setINDIScopeAction" )
2913  {
2914 
2915  if (sf->argVal(0) != argSetScopeActionINDI->actionCombo->currentText())
2916  setUnsavedChanges( true );
2917 
2918  sf->setArg(0, argSetScopeActionINDI->actionCombo->currentText());
2919  sf->setINDIProperty("CHECK");
2920  sf->setValid(true);
2921  }
2922  else
2923  {
2924  warningMismatch( "setINDIScopeAction" );
2925  }
2926 
2927 }
2928 
2929 void ScriptBuilder::slotINDISetFrameType()
2930 {
2931  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2932 
2933  if ( sf->name() == "setINDIFrameType" )
2934  {
2935 
2936  if (sf->argVal(0) != argSetFrameTypeINDI->typeCombo->currentText())
2937  setUnsavedChanges( true );
2938 
2939  sf->setArg(0, argSetFrameTypeINDI->typeCombo->currentText());
2940  sf->setValid(true);
2941  }
2942  else
2943  {
2944  warningMismatch( "setINDIFrameType" );
2945  }
2946 
2947 }
2948 
2949 void ScriptBuilder::slotINDISetCCDTemp()
2950 {
2951  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2952 
2953  if ( sf->name() == "setINDICCDTemp" )
2954  {
2955 
2956  if (sf->argVal(0).toInt() != argSetCCDTempINDI->temp->value())
2957  setUnsavedChanges( true );
2958 
2959  sf->setArg(0, QString("%1").arg(argSetCCDTempINDI->temp->value()));
2960  sf->setValid(true);
2961  }
2962  else
2963  {
2964  warningMismatch( "setINDICCDTemp" );
2965  }
2966 
2967 }
2968 
2969 void ScriptBuilder::slotINDISetFilterNum()
2970 {
2971 
2972  ScriptFunction *sf = ScriptList[ sb->ScriptListBox->currentRow() ];
2973 
2974  if ( sf->name() == "setINDIFilterNum" )
2975  {
2976 
2977  if (sf->argVal(0).toInt() != argSetFilterNumINDI->filter_num->value())
2978  setUnsavedChanges( true );
2979 
2980  sf->setArg(0, QString("%1").arg(argSetFilterNumINDI->filter_num->value()));
2981  sf->setValid(true);
2982  }
2983  else
2984  {
2985  warningMismatch( "setINDIFilterNum" );
2986  }
2987 
2988 
2989 }
2990 #endif
2991 
2992 void ScriptBuilder::warningMismatch (const QString &expected) const {
2993  kWarning() << i18n( "Mismatch between function and Arg widget (expected %1.)", QString(expected) ) ;
2994 }
2995 
2996 #include "scriptbuilder.moc"
ScriptBuilder::slotRa
void slotRa()
Definition: scriptbuilder.cpp:2073
ScriptBuilder::~ScriptBuilder
~ScriptBuilder()
Definition: scriptbuilder.cpp:554
ScriptBuilder::slotNew
void slotNew()
Definition: scriptbuilder.cpp:949
ScriptFunction::numArgs
int numArgs() const
Definition: scriptfunction.h:57
ScriptFunction::argVal
QString argVal(unsigned int n) const
Definition: scriptfunction.h:46
LocationDialog
Dialog for changing the geographic location of the observer.
Definition: locationdialog.h:57
ScriptBuilder::slotCopyFunction
void slotCopyFunction()
Definition: scriptbuilder.cpp:1391
ScriptBuilder::ScriptBuilder
ScriptBuilder(QWidget *parent)
Definition: scriptbuilder.cpp:130
ScriptNameWidget
Definition: scriptbuilder.h:54
ScriptBuilder::slotArgFindObject
void slotArgFindObject()
Definition: scriptbuilder.cpp:2060
ScriptBuilder::slotChangeColor
void slotChangeColor()
Definition: scriptbuilder.cpp:2409
ScriptFunction::isClockFunction
bool isClockFunction() const
Definition: scriptfunction.h:53
ScriptNameDialog::ScriptNameDialog
ScriptNameDialog(QWidget *p)
Definition: scriptbuilder.cpp:107
ScriptBuilder::slotArgWidget
void slotArgWidget()
Definition: scriptbuilder.cpp:1510
QWidget
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
ScriptBuilderUI
Definition: scriptbuilder.h:75
ScriptBuilder::slotExportImage
void slotExportImage()
Definition: scriptbuilder.cpp:2363
ScriptBuilder::slotMoveFunctionDown
void slotMoveFunctionDown()
Definition: scriptbuilder.cpp:1492
ScriptBuilder::slotOpen
void slotOpen()
Definition: scriptbuilder.cpp:966
ScriptBuilder::slotTracking
void slotTracking()
Definition: scriptbuilder.cpp:2241
ScriptBuilder::saveWarning
void saveWarning()
Definition: scriptbuilder.cpp:1092
KDialog
ScriptFunction::setValid
void setValid(bool b)
Definition: scriptfunction.h:49
ScriptBuilder::parseFunction
bool parseFunction(QString fn_name, QStringList &fn)
Definition: scriptbuilder.cpp:1270
KStars
This is the main window for KStars.
Definition: kstars.h:94
ScriptFunction::valid
bool valid() const
Definition: scriptfunction.h:50
OptionsTreeView::resizeColumns
void resizeColumns()
Definition: scriptbuilder.cpp:68
ScriptNameWidget::ScriptNameWidget
ScriptNameWidget(QWidget *p)
Definition: scriptbuilder.cpp:103
OptionsTreeView::~OptionsTreeView
~OptionsTreeView()
Definition: scriptbuilder.cpp:64
ScriptBuilder::slotChangeCountry
void slotChangeCountry()
Definition: scriptbuilder.cpp:2313
ScriptBuilder::slotClose
void slotClose()
Definition: scriptbuilder.cpp:2438
ScriptBuilder::slotViewOption
void slotViewOption()
Definition: scriptbuilder.cpp:2254
NaN::f
const float f
Definition: nan.h:36
ScriptBuilder::slotZoom
void slotZoom()
Definition: scriptbuilder.cpp:2346
ScriptFunction::setArg
void setArg(unsigned int n, QString newVal)
Definition: scriptfunction.h:55
ScriptBuilder::slotSave
void slotSave()
Definition: scriptbuilder.cpp:1011
timestepbox.h
locationdialog.h
ScriptBuilder::slotWaitFor
void slotWaitFor()
Definition: scriptbuilder.cpp:2200
ScriptBuilder::slotChangeTime
void slotChangeTime()
Definition: scriptbuilder.cpp:2183
KStarsDateTime::currentDateTime
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
Definition: kstarsdatetime.cpp:67
ScriptBuilder::slotAz
void slotAz()
Definition: scriptbuilder.cpp:2121
ScriptFunction::name
QString name() const
Definition: scriptfunction.h:41
ScriptBuilder::slotRunScript
void slotRunScript()
Definition: scriptbuilder.cpp:1108
skymap.h
i18nc
i18nc("string from libindi, used in the config dialog","100x")
ScriptFunction::prototype
QString prototype() const
Definition: scriptfunction.cpp:142
ScriptBuilder::slotWaitForKey
void slotWaitForKey()
Definition: scriptbuilder.cpp:2220
ScriptBuilder::slotShowDoc
void slotShowDoc()
Definition: scriptbuilder.cpp:1931
ScriptBuilder::slotRemoveFunction
void slotRemoveFunction()
Definition: scriptbuilder.cpp:1406
dms
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:42
dms::Hours
double Hours() const
Definition: dms.h:125
OptionsTreeViewWidget
Definition: scriptbuilder.h:36
ScriptBuilder::writeScript
void writeScript(QTextStream &ostream)
Definition: scriptbuilder.cpp:1158
ScriptFunction::INDIProperty
QString INDIProperty() const
Definition: scriptfunction.h:62
ScriptFunction::setINDIProperty
void setINDIProperty(QString prop)
Definition: scriptfunction.h:61
scriptbuilder.h
QTextStream
ScriptBuilder::slotChangeCity
void slotChangeCity()
Definition: scriptbuilder.cpp:2273
ScriptBuilder::slotMoveFunctionUp
void slotMoveFunctionUp()
Definition: scriptbuilder.cpp:1474
finddialog.h
NaN::d
const double d
Definition: nan.h:35
ScriptBuilder::slotChangeDate
void slotChangeDate()
Definition: scriptbuilder.cpp:2166
NaN::ld
const long double ld
Definition: nan.h:37
ScriptBuilder::slotDec
void slotDec()
Definition: scriptbuilder.cpp:2097
ScriptBuilder::slotAlt
void slotAlt()
Definition: scriptbuilder.cpp:2143
ScriptBuilder::slotFindCity
void slotFindCity()
Definition: scriptbuilder.cpp:1976
ScriptFunction::scriptLine
QString scriptLine() const
Definition: scriptfunction.cpp:183
ScriptFunction
Jason Harris.
Definition: scriptfunction.h:27
OptionsTreeViewWidget::OptionsTreeViewWidget
OptionsTreeViewWidget(QWidget *p)
Definition: scriptbuilder.cpp:50
kstarsdatetime.h
ScriptBuilder::setUnsavedChanges
void setUnsavedChanges(bool b=true)
Definition: scriptbuilder.cpp:1384
scriptfunction.h
ScriptBuilderUI::ScriptBuilderUI
ScriptBuilderUI(QWidget *p)
Definition: scriptbuilder.cpp:126
ScriptBuilder::slotTimeScale
void slotTimeScale()
Definition: scriptbuilder.cpp:2333
ScriptBuilder::slotLoadColorScheme
void slotLoadColorScheme()
Definition: scriptbuilder.cpp:2425
kstarsdata.h
ScriptBuilder::slotPrintImage
void slotPrintImage()
Definition: scriptbuilder.cpp:2378
dmsbox.h
ScriptBuilder::slotLookToward
void slotLookToward()
Definition: scriptbuilder.cpp:2047
ScriptBuilder::slotChangeProvince
void slotChangeProvince()
Definition: scriptbuilder.cpp:2293
QFrame
ScriptBuilder::slotAddFunction
void slotAddFunction()
Definition: scriptbuilder.cpp:1428
ScriptBuilder::slotFindObject
void slotFindObject()
Definition: scriptbuilder.cpp:2005
kstars.h
ScriptBuilder::readScript
void readScript(QTextStream &istream)
Definition: scriptbuilder.cpp:1212
OptionsTreeView::OptionsTreeView
OptionsTreeView(QWidget *p)
Definition: scriptbuilder.cpp:54
ScriptBuilder::slotSaveAs
void slotSaveAs()
Definition: scriptbuilder.cpp:1086
ScriptBuilder::slotChangeColorName
void slotChangeColorName()
Definition: scriptbuilder.cpp:2392
ScriptBuilder::slotShowOptions
void slotShowOptions()
Definition: scriptbuilder.cpp:2037
ScriptNameDialog::~ScriptNameDialog
~ScriptNameDialog()
Definition: scriptbuilder.cpp:118
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal