[prev in list] [next in list] [prev in thread] [next in thread]
List: kstars-devel
Subject: Re: [Kstars-devel] Astrocalc refactoring
From: Khudyakov Alexey <alexey.skladnoy () gmail ! com>
Date: 2009-05-19 11:32:07
Message-ID: 200905191532.07806.alexey.skladnoy () gmail ! com
[Download RAW message or body]
On Tuesday 19 May 2009 12:03:19 Akarsh Simha wrote:
> Ah okay.
>
> I'll merge patch 4 + patch 5 tomorrow. Thanks :)
>
Please apply this patch instead of 5. This is its further refinement
* Unneeded data fields are removed
* Documentation improved
* Unneeded forward class declarations and includes are removed
["astrocalc_clean_refactor.patch" (text/x-patch)]
# HG changeset patch
# User Alexey Khudyakov <alexey.skladnoy@gmail.com>
# Date 1242732263 -14400
# Node ID b218bc0ccf3abc6233317daa202f3ef5b0221de2
# Parent 2e71a0c3d17c023eb9d9fbfb41197a1dd25d6370
[mq]: astrocalc_clean_refactor
diff -r 2e71a0c3d17c -r b218bc0ccf3a kstars/tools/astrocalc.cpp
--- a/kstars/tools/astrocalc.cpp Tue May 19 11:57:13 2009 +0400
+++ b/kstars/tools/astrocalc.cpp Tue May 19 15:24:23 2009 +0400
@@ -20,6 +20,7 @@
#include <QSplitter>
#include <QStackedWidget>
#include <QTreeWidget>
+#include <QTreeWidgetItem>
#include <KTextEdit>
#include <klocale.h>
#include <ktextedit.h>
@@ -40,12 +41,9 @@
#include "conjunctions.h"
AstroCalc::AstroCalc( QWidget* parent ) :
- KDialog( parent ), JDFrame(0), GeodCoordFrame(0),
- GalFrame(0), SidFrame(0), AppFrame(0),
- DayFrame(0), AltAzFrame(0), PlanetsFrame(0), EquinoxFrame(0),
- EclFrame(0), AngDistFrame(0)
+ KDialog( parent )
{
- // Long list of messages
+ // List of messages. Maybe there is better place for it...
QString message =
i18n("<QT>"
"<H2>KStars Astrocalculator</H2>"
@@ -117,6 +115,7 @@
setCaption( i18n("Calculator") );
setButtons( KDialog::Close );
+ // Create navigation panel
navigationPanel = new QTreeWidget(split);
navigationPanel->setColumnCount(1);
navigationPanel->setHeaderLabels( QStringList(i18n("Calculator modules")) );
@@ -125,64 +124,63 @@
//but I wasn't able to make it work
navigationPanel->setMinimumWidth( 200 );
- // Load icons
- QIcon jdIcon = QIcon ("jd.png");
- QIcon geodIcon = QIcon ("geodetic.png");
- QIcon solarIcon = QIcon ("geodetic.png");
- QIcon sunsetIcon = QIcon ("sunset.png");
- QIcon timeIcon = QIcon ("sunclock.png");
-
- //Populate widget stack
acStack = new QStackedWidget( split );
splashScreen = new KTextEdit( message, acStack );
splashScreen->setReadOnly( true );
acStack->addWidget( splashScreen );
- JDFrame = addToStack<modCalcJD>();
- GeodCoordFrame = addToStack<modCalcGeodCoord>();
- GalFrame = addToStack<modCalcGalCoord>();
- SidFrame = addToStack<modCalcSidTime>();
- AppFrame = addToStack<modCalcApCoord>();
- DayFrame = addToStack<modCalcDayLength>();
-
- AltAzFrame = addToStack<modCalcAltAz>();
- PlanetsFrame = addToStack<modCalcPlanets>();
- EquinoxFrame = addToStack<modCalcEquinox>();
- EclFrame = addToStack<modCalcEclCoords>();
- AngDistFrame = addToStack<modCalcAngDist>();
- VlsrFrame = addToStack<modCalcVlsr>();
- ConjunctFrame = addToStack<ConjunctionsTool>();
-
- acStack->setCurrentWidget( splashScreen );
-
- //Populate the tree widget
+ // Load icons
+ QIcon jdIcon = QIcon ("jd.png");
+ QIcon geodIcon = QIcon ("geodetic.png");
+ QIcon solarIcon = QIcon ("geodetic.png");
+ // QIcon sunsetIcon = QIcon ("sunset.png"); // Its usage is commented out.
+ QIcon timeIcon = QIcon ("sunclock.png");
+
+ /* Populate the tree widget and widget stack */
+ // Time-related entries
QTreeWidgetItem * timeItem = addTreeTopItem(navigationPanel, i18n("Time \
Calculators"), messageTime); timeItem->setIcon(0,timeIcon);
- QTreeWidgetItem * jdItem = addTreeItem(timeItem, i18n("Julian Day"), JDFrame );
+ QTreeWidgetItem * jdItem = addTreeItem(timeItem, i18n("Julian Day"),
+ addToStack<modCalcJD>());
jdItem->setIcon(0,jdIcon);
- addTreeItem(timeItem, i18n("Sidereal Time"), SidFrame );
- addTreeItem(timeItem, i18n("Almanac"), DayFrame );
- addTreeItem(timeItem, i18n("Equinoxes & Solstices"), EquinoxFrame );
- // dayItem->setIcon(0,sunsetIcon);
+ addTreeItem(timeItem, i18n("Sidereal Time"),
+ addToStack<modCalcSidTime>());
+ addTreeItem(timeItem, i18n("Almanac"),
+ addToStack<modCalcDayLength>());
+ addTreeItem(timeItem, i18n("Equinoxes & Solstices"),
+ addToStack<modCalcEquinox>());
+ // dayItem->setIcon(0,sunsetIcon);
+ // Coordinate-related entries
QTreeWidgetItem * coordItem = addTreeTopItem(navigationPanel, i18n("Coordinate \
Converters"), messageCoord);
- addTreeItem(coordItem, i18n("Equatorial/Galactic"), GalFrame);
- addTreeItem(coordItem, i18n("Apparent Coordinates"), AppFrame);
- addTreeItem(coordItem, i18n("Horizontal Coordinates"), AltAzFrame);
- addTreeItem(coordItem, i18n("Ecliptic Coordinates"), EclFrame);
- addTreeItem(coordItem, i18n("Angular Distance"), AngDistFrame);
- addTreeItem(coordItem, i18n("Geodetic Coordinates"), GeodCoordFrame);
- addTreeItem(coordItem, i18n("LSR Velocity"), VlsrFrame);
+ addTreeItem(coordItem, i18n("Equatorial/Galactic"),
+ addToStack<modCalcGalCoord>());
+ addTreeItem(coordItem, i18n("Apparent Coordinates"),
+ addToStack<modCalcApCoord>());
+ addTreeItem(coordItem, i18n("Horizontal Coordinates"),
+ addToStack<modCalcAltAz>());
+ addTreeItem(coordItem, i18n("Ecliptic Coordinates"),
+ addToStack<modCalcEclCoords>());
+ addTreeItem(coordItem, i18n("Angular Distance"),
+ addToStack<modCalcAngDist>());
+ addTreeItem(coordItem, i18n("Geodetic Coordinates"),
+ addToStack<modCalcGeodCoord>());
+ addTreeItem(coordItem, i18n("LSR Velocity"),
+ addToStack<modCalcVlsr>());
+ // Solar System related entries
QTreeWidgetItem * solarItem = addTreeTopItem(navigationPanel, i18n("Solar \
System"), messageSolar); solarItem->setIcon(0,solarIcon);
- addTreeItem(solarItem, i18n("Planets Coordinates"), PlanetsFrame);
- addTreeItem(solarItem, i18n("Conjunctions"), ConjunctFrame);
-
+ addTreeItem(solarItem, i18n("Planets Coordinates"),
+ addToStack<modCalcPlanets>());
+ addTreeItem(solarItem, i18n("Conjunctions"),
+ addToStack<ConjunctionsTool>());
+
+ acStack->setCurrentWidget( splashScreen );
connect(navigationPanel, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
SLOT(slotItemSelection(QTreeWidgetItem *)));
}
diff -r 2e71a0c3d17c -r b218bc0ccf3a kstars/tools/astrocalc.h
--- a/kstars/tools/astrocalc.h Tue May 19 11:57:13 2009 +0400
+++ b/kstars/tools/astrocalc.h Tue May 19 15:24:23 2009 +0400
@@ -18,29 +18,16 @@
#ifndef ASTROCALC_H_
#define ASTROCALC_H_
-#include <QTreeWidgetItem>
#include <QMap>
+#include <QString>
#include <kdialog.h>
-#include "dms.h"
class QSplitter;
-class QString;
class QStackedWidget;
+class QTreeWidget;
+class QTreeWidgetItem;
class KTextEdit;
-class modCalcJD;
-class modCalcGeodCoord;
-class modCalcGalCoord;
-class modCalcSidTime;
-class modCalcApCoord;
-class modCalcDayLength;
-class modCalcAltAz;
-class modCalcEquinox;
-class modCalcPlanets;
-class modCalcEclCoords;
-class modCalcAngDist;
-class modCalcVlsr;
-class ConjunctionsTool;
/** Astrocalc is the base class for the KStars astronomical calculator
* @author: Pablo de Vicente
@@ -59,56 +46,36 @@
/**@returns suggested size of calculator window. */
QSize sizeHint() const;
public slots:
- /** Determine which item is selected in the navigation panel
- * Generate the corresponding calculator module.
- */
+ /** Display calculator module or help text based on item selected.
+ */
void slotItemSelection(QTreeWidgetItem *it);
private:
/** Create widget of type T and put it to widget stack. Widget must
- * have construtor of type T(QWidget*) */
+ * have construtor of type T(QWidget*). Returns constructed widget. */
template<typename T>
inline T* addToStack();
- /** Add top level item to navigation panel.
- title - name of item
- html - string to be displayed in splash screen
+ /** Add top level item to navigation panel. At the same time adds item to \
htmlTable + @param title name of item
+ @param html string to be displayed in splash screen
*/
QTreeWidgetItem* addTreeTopItem(QTreeWidget* parent, QString title, QString \
html);
- /** Add item to navigation panel.
- title - name of item
- widget - widget to be selected on click
+ /** Add item to navigation panel. At the same time adds item to dispatchTable
+ @param title name of item
+ @param widget widget to be selected on click
*/
QTreeWidgetItem* addTreeItem(QTreeWidgetItem* parent, QString title, QWidget* \
widget);
- /** Lookup table for help texts */
+ /** Lookup table for help texts. Maps navpanel item name to help text. */
QMap<QString, QString> htmlTable;
- /** Lookup table for widgets */
+ /** Lookup table for widgets. Maps navpanel item name to widget to be displayed. \
*/ QMap<QString, QWidget*> dispatchTable;
QSplitter *split;
QTreeWidget *navigationPanel;
- QString previousElection;
-
- enum typeOfPanel {GenText, TimeText, GeoText, SolarText, CoordText, JD, SidTime, \
DayLength, Equinox, GeoCoord, Galactic, Apparent, AltAz, Planets, Ecliptic, AngDist, \
Vlsr};
- typeOfPanel rightPanel;
-
- QStringList ItemTitles;
QStackedWidget *acStack;
KTextEdit *splashScreen;
- modCalcJD *JDFrame;
- modCalcGeodCoord *GeodCoordFrame;
- modCalcGalCoord *GalFrame;
- modCalcSidTime *SidFrame;
- modCalcApCoord *AppFrame;
- modCalcDayLength *DayFrame;
- modCalcAltAz *AltAzFrame;
- modCalcPlanets *PlanetsFrame;
- modCalcEquinox *EquinoxFrame;
- modCalcEclCoords *EclFrame;
- modCalcAngDist *AngDistFrame;
- modCalcVlsr *VlsrFrame;
- ConjunctionsTool *ConjunctFrame;
};
#endif
_______________________________________________
Kstars-devel mailing list
Kstars-devel@kde.org
https://mail.kde.org/mailman/listinfo/kstars-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic