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

Jason Harris kstars at 30doradus.org
Wed Dec 20 14:22:13 CET 2006


SVN commit 615148 by harris:

Simplifying Julian Day calc module.  Removed Compute/Clear buttons; 
editing any of the three methods of showing the date automatically 
updates the other two.

TODO: this change exposed a bug in ExtDateEdit, it has a badly 
constructed Signal/Slot connection.

CCMAIL: kstars-devel at kde.org



 M  +11 -36    modcalcjd.cpp  
 M  +3 -8      modcalcjd.h  
 M  +84 -204   modcalcjd.ui  


--- trunk/KDE/kdeedu/kstars/kstars/tools/modcalcjd.cpp #615147:615148
@@ -34,53 +34,40 @@
 
     // signals and slots connections
     connect(NowButton, SIGNAL(clicked()), this, SLOT(showCurrentTime()));
-    connect(Clear, SIGNAL(clicked()), this, SLOT(slotClearTime()));
-    connect(Compute, SIGNAL(clicked()), this, SLOT(slotComputeTime()));
-
-	showCurrentTime();
-	show();
+    connect( DateTimeBox, SIGNAL(valueChanged(ExtDateTime)), this, SLOT(slotUpdateCalendar()) );
+    connect( JDBox, SIGNAL(editingFinished()), this, SLOT(slotUpdateJD()) );
+    connect( ModJDBox, SIGNAL(editingFinished()), this, SLOT(slotUpdateModJD()) );
+    showCurrentTime();
+    slotUpdateCalendar();
+    show();
 }
 
 modCalcJD::~modCalcJD(void)
 {
 }
 
-void modCalcJD::slotComputeTime (void)
+void modCalcJD::slotUpdateCalendar()
 {
-	
-	if(DateRadio->isChecked()) {
-		computeFromCalendar();
-	} else if (JdRadio->isChecked()) {
-		JDBox->setFocus();
-		computeFromJd();
-	} else if (MjdRadio->isChecked()) {
-		ModJDBox->setFocus();
-		computeFromMjd();
-	}
-}
-
-void modCalcJD::computeFromCalendar (void)
-{
 	long double julianDay, modjulianDay;
 	
-	julianDay = getDateTime().djd();
+	julianDay = KStarsDateTime(DateTimeBox->dateTime()).djd();
 	showJd( julianDay );
 
 	modjulianDay = julianDay - MJD0;
 	showMjd(modjulianDay);
 }
 
-void modCalcJD::computeFromMjd (void)
+void modCalcJD::slotUpdateModJD()
 {
 	long double julianDay, modjulianDay;
 
 	modjulianDay = KGlobal::locale()->readNumber( ModJDBox->text() );
 	julianDay = MJD0 + modjulianDay;
 	showJd( julianDay );
-	computeFromJd();
+	DateTimeBox->setDateTime( KStarsDateTime( julianDay ) );
 }
 
-void modCalcJD::computeFromJd (void)
+void modCalcJD::slotUpdateJD()
 {
 	long double julianDay, modjulianDay;
 	julianDay = KGlobal::locale()->readNumber( JDBox->text() );
@@ -93,24 +80,12 @@
 }
 
 
-void modCalcJD::slotClearTime (void)
-{
-	JDBox->setText (QString());
-	ModJDBox->setText (QString());
-	DateTimeBox->setDateTime( ExtDateTime::currentDateTime() );
-}
-
 void modCalcJD::showCurrentTime (void)
 {
 	KStarsDateTime dt = KStarsDateTime::currentDateTime();
 	DateTimeBox->setDateTime( dt );
 }
 
-KStarsDateTime modCalcJD::getDateTime (void)
-{
-	return KStarsDateTime( DateTimeBox->dateTime() );
-}
-
 void modCalcJD::showJd(long double julianDay)
 {
 	JDBox->setText(KGlobal::locale()->formatNumber( (double)julianDay, 5 ) );
--- trunk/KDE/kdeedu/kstars/kstars/tools/modcalcjd.h #615147:615148
@@ -42,15 +42,10 @@
 	modCalcJD(QWidget *p);
 	~modCalcJD();
 	
-	void computeFromCalendar (void);
-	void computeFromMjd (void);
-	void computeFromJd (void);
-	KStarsDateTime getDateTime (void);
-
 public slots:
-		
-	void slotComputeTime(void);
-	void slotClearTime(void);
+       	void slotUpdateCalendar();
+	void slotUpdateModJD();
+	void slotUpdateJD();
 	void showCurrentTime(void);
 
 private:
--- trunk/KDE/kdeedu/kstars/kstars/tools/modcalcjd.ui #615147:615148
@@ -1,15 +1,12 @@
 <ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
  <class>modCalcJdDlg</class>
  <widget class="QWidget" name="modCalcJdDlg" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>549</width>
-    <height>432</height>
+    <width>470</width>
+    <height>284</height>
    </rect>
   </property>
   <property name="windowTitle" >
@@ -23,66 +20,6 @@
     <number>6</number>
    </property>
    <item>
-    <widget class="QGroupBox" name="groupBox" >
-     <property name="title" >
-      <string>Select Input Parameter</string>
-     </property>
-     <layout class="QHBoxLayout" >
-      <property name="margin" >
-       <number>8</number>
-      </property>
-      <property name="spacing" >
-       <number>6</number>
-      </property>
-      <item>
-       <widget class="QRadioButton" name="DateRadio" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>5</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="text" >
-         <string>Date</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QRadioButton" name="JdRadio" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>5</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="text" >
-         <string>Julian day</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QRadioButton" name="MjdRadio" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>5</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="text" >
-         <string>Modified Julian day</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>
@@ -97,102 +34,107 @@
        </property>
        <property name="sizeHint" >
         <size>
-         <width>40</width>
+         <width>22</width>
          <height>20</height>
         </size>
        </property>
       </spacer>
      </item>
      <item>
-      <widget class="KPushButton" name="NowButton" >
-       <property name="text" >
-        <string>Current Date</string>
+      <layout class="QGridLayout" >
+       <property name="margin" >
+        <number>0</number>
        </property>
-      </widget>
+       <property name="spacing" >
+        <number>6</number>
+       </property>
+       <item row="2" column="1" >
+        <widget class="KLineEdit" name="ModJDBox" />
+       </item>
+       <item row="0" column="1" >
+        <widget class="ExtDateTimeEdit" name="DateTimeBox" >
+         <property name="sizePolicy" >
+          <sizepolicy>
+           <hsizetype>7</hsizetype>
+           <vsizetype>0</vsizetype>
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="frameShape" >
+          <enum>QFrame::StyledPanel</enum>
+         </property>
+         <property name="frameShadow" >
+          <enum>QFrame::Raised</enum>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" >
+        <widget class="QLabel" name="label_2" >
+         <property name="text" >
+          <string>Julian day:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="0" >
+        <widget class="QLabel" name="label" >
+         <property name="text" >
+          <string>Date and time:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" >
+        <widget class="QLabel" name="label_3" >
+         <property name="text" >
+          <string>Modified Julian day:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1" >
+        <widget class="KLineEdit" name="JDBox" />
+       </item>
+      </layout>
      </item>
      <item>
       <spacer>
        <property name="orientation" >
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeType" >
-        <enum>QSizePolicy::Expanding</enum>
-       </property>
        <property name="sizeHint" >
         <size>
-         <width>20</width>
-         <height>25</height>
+         <width>23</width>
+         <height>20</height>
         </size>
        </property>
       </spacer>
      </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
      <item>
-      <widget class="KPushButton" name="Compute" >
-       <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>5</hsizetype>
-         <vsizetype>5</vsizetype>
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="minimumSize" >
-        <size>
-         <width>0</width>
-         <height>25</height>
-        </size>
-       </property>
-       <property name="maximumSize" >
-        <size>
-         <width>32767</width>
-         <height>30</height>
-        </size>
-       </property>
-       <property name="text" >
-        <string>Convert</string>
-       </property>
-      </widget>
-     </item>
-     <item>
       <spacer>
        <property name="orientation" >
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeType" >
-        <enum>QSizePolicy::Expanding</enum>
-       </property>
        <property name="sizeHint" >
         <size>
-         <width>21</width>
-         <height>25</height>
+         <width>59</width>
+         <height>30</height>
         </size>
        </property>
       </spacer>
      </item>
      <item>
-      <widget class="KPushButton" name="Clear" >
-       <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>5</hsizetype>
-         <vsizetype>5</vsizetype>
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="minimumSize" >
-        <size>
-         <width>0</width>
-         <height>25</height>
-        </size>
-       </property>
-       <property name="maximumSize" >
-        <size>
-         <width>32767</width>
-         <height>30</height>
-        </size>
-       </property>
+      <widget class="KPushButton" name="NowButton" >
        <property name="text" >
-        <string>Clear</string>
+        <string>Current Date</string>
        </property>
       </widget>
      </item>
@@ -206,8 +148,8 @@
        </property>
        <property name="sizeHint" >
         <size>
-         <width>31</width>
-         <height>25</height>
+         <width>60</width>
+         <height>30</height>
         </size>
        </property>
       </spacer>
@@ -215,104 +157,42 @@
     </layout>
    </item>
    <item>
-    <widget class="QGroupBox" name="groupBox_2" >
-     <property name="title" >
-      <string>Date Conversions</string>
-     </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
-       <number>8</number>
-      </property>
-      <property name="spacing" >
-       <number>6</number>
-      </property>
-      <item row="1" column="0" >
-       <widget class="QLabel" name="label_2" >
-        <property name="text" >
-         <string>Julian day:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0" >
-       <widget class="QLabel" name="label_3" >
-        <property name="text" >
-         <string>Modified Julian day:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1" >
-       <widget class="KLineEdit" name="ModJDBox" />
-      </item>
-      <item row="1" column="1" >
-       <widget class="KLineEdit" name="JDBox" />
-      </item>
-      <item row="0" column="1" >
-       <widget class="ExtDateTimeEdit" name="DateTimeBox" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>7</hsizetype>
-          <vsizetype>0</vsizetype>
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="frameShape" >
-         <enum>QFrame::StyledPanel</enum>
-        </property>
-        <property name="frameShadow" >
-         <enum>QFrame::Raised</enum>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="0" >
-       <widget class="QLabel" name="label" >
-        <property name="text" >
-         <string>Date and time:</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
     <spacer>
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
      <property name="sizeHint" >
       <size>
-       <width>20</width>
-       <height>40</height>
+       <width>411</width>
+       <height>71</height>
       </size>
      </property>
     </spacer>
    </item>
   </layout>
  </widget>
- <pixmapfunction></pixmapfunction>
  <customwidgets>
   <customwidget>
    <class>ExtDateTimeEdit</class>
-   <extends></extends>
-   <header>libkdeedu/extdate/extdatetimeedit.h</header>
-   <container>0</container>
-   <pixmap></pixmap>
+   <extends>QFrame</extends>
+   <header>extdatetimeedit.h</header>
   </customwidget>
   <customwidget>
    <class>KPushButton</class>
-   <extends></extends>
+   <extends>QPushButton</extends>
    <header>kpushbutton.h</header>
-   <container>0</container>
-   <pixmap></pixmap>
   </customwidget>
   <customwidget>
    <class>KLineEdit</class>
-   <extends></extends>
+   <extends>QLineEdit</extends>
    <header>klineedit.h</header>
-   <container>0</container>
-   <pixmap></pixmap>
   </customwidget>
  </customwidgets>
+ <tabstops>
+  <tabstop>JDBox</tabstop>
+  <tabstop>ModJDBox</tabstop>
+  <tabstop>NowButton</tabstop>
+ </tabstops>
  <resources/>
  <connections/>
 </ui>


More information about the Kstars-devel mailing list