[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/kstars/kstars/widgets
From: Alexey Khudyakov <alexey.skladnoy () gmail ! com>
Date: 2009-10-30 19:18:47
Message-ID: 1256930327.904138.2925.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1042815 by khudyakov:
* Add some documentation for InfoBoxWidget class
* Refactor code in the InfoBox class. Get rid of function for resizing of QList
M +11 -20 infoboxwidget.cpp
M +15 -4 infoboxwidget.h
--- trunk/KDE/kdeedu/kstars/kstars/widgets/infoboxwidget.cpp #1042814:1042815
@@ -33,14 +33,6 @@
// Padding
const int padX = 6;
const int padY = 2;
-
- // Resize QStringList. For some reason. QList doesn't have resize.
- void resizeList(QStringList& list, int n) {
- while( list.size() > n )
- list.removeLast();
- while( list.size() < n )
- list.append( QString() );
- }
}
@@ -83,12 +75,12 @@
void InfoBoxWidget::slotTimeChanged() {
KStarsData* data = KStarsData::Instance();
- resizeList(m_strings, 3);
- m_strings[0] =
+ m_strings.clear();
+ m_strings <<
i18nc( "Local Time", "LT: " ) +
KGlobal::locale()->formatTime( data->lt().time(), true ) + " " +
KGlobal::locale()->formatDate( data->lt().date() );
- m_strings[1] =
+ m_strings <<
i18nc( "Universal Time", "UT: " ) +
KGlobal::locale()->formatTime( data->ut().time(), true ) + " " +
KGlobal::locale()->formatDate( data->ut().date() );
@@ -99,7 +91,7 @@
//thousands-place separators
QString JDString = QString::number( data->ut().djd(), 'f', 2 );
JDString.replace( '.', KGlobal::locale()->decimalSymbol() );
- m_strings[2] =
+ m_strings <<
i18nc( "Sidereal Time", "ST: " ) + STString +
i18nc( "Julian Day", "JD: " ) + JDString;
updateSize();
@@ -109,15 +101,14 @@
void InfoBoxWidget::slotGeoChanged() {
KStarsData* data = KStarsData::Instance();
- resizeList(m_strings, 2);
-
QString name = data->geo()->translatedName() + ", ";
if ( ! data->geo()->province().isEmpty() )
name += data->geo()->translatedProvince() + ", ";
name += data->geo()->translatedCountry();
- m_strings[0] = name;
- m_strings[1] =
+ m_strings.clear();
+ m_strings << name;
+ m_strings <<
i18nc( "Longitude", "Long:" ) + ' ' +
KGlobal::locale()->formatNumber( data->geo()->lng()->Degrees(),3) + " " +
i18nc( "Latitude", "Lat:" ) + ' ' +
@@ -135,12 +126,12 @@
}
void InfoBoxWidget::setPoint(QString name, SkyPoint* p) {
- resizeList(m_strings, 3);
- m_strings[0] = name;
- m_strings[1] =
+ m_strings.clear();
+ m_strings << name;
+ m_strings <<
i18nc( "Right Ascension", "RA" ) + ": " + p->ra()->toHMSString() + " " +
i18nc( "Declination", "Dec" ) + ": " + p->dec()->toDMSString(true);
- m_strings[2] =
+ m_strings <<
i18nc( "Azimuth", "Az" ) + ": " + p->az()->toDMSString(true) + " " +
i18nc( "Altitude", "Alt" ) + ": " + p->alt()->toDMSString(true);
updateSize();
--- trunk/KDE/kdeedu/kstars/kstars/widgets/infoboxwidget.h #1042814:1042815
@@ -32,6 +32,7 @@
{
Q_OBJECT
public:
+
InfoBoxes(QWidget* parent = 0) : QWidget(parent) {}
virtual ~InfoBoxes();
@@ -43,19 +44,26 @@
QList<InfoBoxWidget*> m_boxes;
};
-
+/** Small optianally transparent box for display of text messages. */
class InfoBoxWidget : public QWidget
{
Q_OBJECT
public:
+ /** Create one infobox. */
InfoBoxWidget(bool shade, QPoint pos, QStringList str = QStringList(), QWidget* parent = 0);
+ /** Destructor */
virtual ~InfoBoxWidget();
+ /** Check whether box is shaded. In this case only one line is shown. */
bool shaded() const { return m_shaded; }
public slots:
+ /** Set information about time. Data is taken from KStarsData. */
void slotTimeChanged();
+ /** Set information about location. Data is taken from KStarsData. */
void slotGeoChanged();
+ /** Set information about object. */
void slotObjectChanged(SkyObject* obj);
+ /** Set information about pointing. */
void slotPointChanged(SkyPoint* p);
protected:
virtual void resizeEvent(QResizeEvent * event);
@@ -65,11 +73,14 @@
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
private:
+ /** Uset to set information about object. */
void setPoint(QString name, SkyPoint* p);
+ /** Recalculate size of widet */
void updateSize();
- QStringList m_strings;
- bool m_grabbed;
- bool m_shaded;
+
+ QStringList m_strings; // list of string to show
+ bool m_grabbed; // True if widget is dragged around
+ bool m_shaded; // True if widget if shaded
};
#endif /* INFOBOXWIDGET_H_ */
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic