[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Sat Oct 29 03:08:54 CEST 2005
SVN commit 475376 by staikos:
fix compile on KDE < 3.5 and some more work on timezone settings - almost done
M +1 -0 Makefile.am
M +1 -1 kst2dplot.cpp
M +23 -4 kstsettings.cpp
M +4 -1 kstsettings.h
M +0 -6 kstsettingsdlg.ui
M +4 -0 kstsettingsdlg.ui.h
A ksttimezones.cpp [License: LGPL]
A ksttimezones.h [License: LGPL]
M +18 -5 ktimezonecombo.cpp
M +5 -2 ktimezonecombo.h
--- trunk/extragear/graphics/kst/kst/Makefile.am #475375:475376
@@ -203,6 +203,7 @@
kstsettings.cpp \
kstdoc.cpp \
kstviewwindow.cpp \
+ ksttimezones.cpp \
ktimezonecombo.cpp \
plotdialog.ui \
extensiondlg.ui \
--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #475375:475376
@@ -1333,7 +1333,7 @@
}
}
- dJD += double(KstSettings::globalSettings()->utcOffset) / 3600;
+ dJD += double(KstSettings::globalSettings()->utcOffset()) / 3600;
length = 0;
--- trunk/extragear/graphics/kst/kst/kstsettings.cpp #475375:475376
@@ -20,11 +20,13 @@
#include <kemailsettings.h>
#include <kprinter.h>
#include <kstaticdeleter.h>
+#include <ktimezones.h>
// application specific includes
#include "kstsettings.h"
KstSettings::KstSettings() {
+ _lastOffset = 0;
plotUpdateTimer = 200;
plotFontSize = 12;
backgroundColor = QColor(255, 255, 255); // white
@@ -54,7 +56,7 @@
emailEncryption = EMailEncryptionNone;
emailAuthentication = EMailAuthenticationPLAIN;
- utcOffset = 0;
+ timezone = "UTC";
setPrintingDefaults();
}
@@ -74,7 +76,7 @@
showQuickStart = x.showQuickStart;
curveColorSequencePalette = x.curveColorSequencePalette;
- utcOffset = x.utcOffset;
+ timezone = x.timezone;
xMajor = x.xMajor;
yMajor = x.yMajor;
@@ -155,7 +157,7 @@
cfg.writeEntry("Prompt on Window Close", promptWindowClose);
cfg.writeEntry("Show QuickStart", showQuickStart);
cfg.writeEntry("Curve Color Sequence", curveColorSequencePalette);
- cfg.writeEntry("UTC Offset", utcOffset);
+ cfg.writeEntry("Timezone", timezone);
cfg.setGroup("Grid Lines");
cfg.writeEntry("X Major", xMajor);
@@ -222,7 +224,7 @@
promptWindowClose = cfg.readBoolEntry("Prompt on Window Close", true);
showQuickStart = cfg.readBoolEntry("Show QuickStart", true);
curveColorSequencePalette = cfg.readEntry("Curve Color Sequence", "Kst Colors");
- utcOffset = cfg.readNumEntry("UTC Offset", 0);
+ timezone = cfg.readEntry("Timezone", "UTC");
cfg.setGroup("Grid Lines");
xMajor = cfg.readBoolEntry("X Major", false);
@@ -282,6 +284,7 @@
cfg.checkUpdate("kstrcmisc1.1", "kstrcmisc11.upd");
}
+
void KstSettings::setPrintingDefaults() {
printing.pageSize = QString::number((int)KPrinter::Letter);
printing.orientation = "Landscape";
@@ -298,4 +301,20 @@
}
+int KstSettings::utcOffset() {
+ if (_lastTZ == timezone) {
+ return _lastOffset;
+ }
+ KTimezones db;
+ const KTimezones::ZoneMap zones = db.allZones();
+ for (KTimezones::ZoneMap::ConstIterator it = zones.begin(); it != zones.end(); ++it) {
+ if ((*it)->name() == timezone) {
+ _lastTZ = timezone;
+ return (_lastOffset = (*it)->offset());
+ }
+ }
+ _lastTZ = QString::null;
+ return (_lastOffset = 0);
+}
+
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstsettings.h #475375:475376
@@ -85,7 +85,8 @@
EMailEncryption emailEncryption;
EMailAuthentication emailAuthentication;
- int utcOffset;
+ int utcOffset();
+ QString timezone;
struct PrintingMonochrome {
QString enhanceReadability;
@@ -111,6 +112,8 @@
private:
static KstSettings *_self;
+ int _lastOffset;
+ QString _lastTZ;
};
#endif
--- trunk/extragear/graphics/kst/kst/kstsettingsdlg.ui #475375:475376
@@ -1209,12 +1209,6 @@
<receiver>KstSettingsDlg</receiver>
<slot>setDirty()</slot>
</connection>
- <connection>
- <sender>_tz</sender>
- <signal>textChanged(const QString&)</signal>
- <receiver>KstSettingsDlg</receiver>
- <slot>setDirty()</slot>
- </connection>
</connections>
<tabstops>
<tabstop>_timer</tabstop>
--- trunk/extragear/graphics/kst/kst/kstsettingsdlg.ui.h #475375:475376
@@ -59,6 +59,8 @@
_buttonGroupEncryption->setButton((int)settings->emailEncryption);
_buttonGroupAuthentication->setButton((int)settings->emailAuthentication);
+ _tz->setTimezone(settings->timezone);
+
int index = -1;
int i;
@@ -131,6 +133,8 @@
s.emailSMTPPort = _kIntSpinBoxEMailPort->value();
s.emailRequiresAuthentication = _checkBoxAuthentication->isChecked();
+ s.timezone = _tz->tzName();
+
int value = _buttonGroupEncryption->id(_buttonGroupEncryption->selected());
if (value >= 0 && value < EMailEncryptionMAXIMUM) {
s.emailEncryption = (EMailEncryption)value;
--- trunk/extragear/graphics/kst/kst/ktimezonecombo.cpp #475375:475376
@@ -23,27 +23,29 @@
#include <qmemarray.h>
#include <klocale.h>
-#include <ktimezones.h>
+#include "ksttimezones.h"
class KTimezoneCombo::Private {
public:
QMemArray<int> _offsets;
+ QStringList _names;
};
-KTimezoneCombo::KTimezoneCombo(QWidget *parent, const char *name, KTimezones *db)
+KTimezoneCombo::KTimezoneCombo(QWidget *parent, const char *name, KstTimezones *db)
: KComboBox(parent, name), d(new Private) {
bool userDb = db != 0L;
if (!userDb) {
- db = new KTimezones;
+ db = new KstTimezones;
}
insertItem("UTC");
- const KTimezones::ZoneMap zones = db->allZones();
+ const KstTimezones::ZoneMap zones = db->allZones();
d->_offsets.resize(zones.count());
d->_offsets[0] = 0;
+ d->_names += "UTC";
int i = 0;
- for (KTimezones::ZoneMap::ConstIterator it = zones.begin(); it != zones.end(); ++it) {
+ for (KstTimezones::ZoneMap::ConstIterator it = zones.begin(); it != zones.end(); ++it) {
int offset = (*it)->offset();
d->_offsets[++i] = offset;
int hours = offset / 3600;
@@ -67,6 +69,7 @@
offnum += QString::number(minutes);
if ((*it)->name() != "UTC") {
insertItem(i18n("%3 (UTC%1%2)").arg(negative ? '-' : '+').arg(offnum).arg((*it)->name()));
+ d->_names += (*it)->name();
}
}
@@ -87,5 +90,15 @@
}
+const QString& KTimezoneCombo::tzName() const {
+ return d->_names[currentItem()];
+}
+
+
+void KTimezoneCombo::setTimezone(const QString& tz) {
+
+}
+
+
#include "ktimezonecombo.moc"
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/ktimezonecombo.h #475375:475376
@@ -24,17 +24,20 @@
#include <kcombobox.h>
#include <qstring.h>
-class KTimezones;
+class KstTimezones;
class KTimezoneCombo : public KComboBox {
Q_OBJECT
public:
- KTimezoneCombo(QWidget *parent = 0L, const char *name = 0L, KTimezones *db = 0L);
+ KTimezoneCombo(QWidget *parent = 0L, const char *name = 0L, KstTimezones *db = 0L);
virtual ~KTimezoneCombo();
// returns the offset from UTC in seconds
int offset() const;
+ const QString& tzName() const;
+ void setTimezone(const QString& tz);
+
private:
class Private;
Private *d;
More information about the Kst
mailing list