Question about way of adding timezones support to clock

Rafał Miłecki zajec5 at gmail.com
Mon Mar 17 13:12:40 CET 2008


2008/3/17, Sebastian Kuegler <sebas at kde.org>:
>  > Currently we use
>  > dataEngine("time")->connectSource(timezone, ...);
>  > and we don't care about time in timezone anymore. It is given to us by
>  > timer and "data" argument in
>  > void Clock::dataUpdated(const QString& source, const
>  > Plasma::DataEngine::Data &data);
>  >
>  > My idea is to change every "timezone" argument to hard-coded string
>  > "Local". That would still allow me to reveice timer's calling
>  > "dataUpdated" so I won't need to create my own timer. The bad side of
>  > this idea is that I'll have to manage timezones myself (I can't use
>  > other sources from dataEngine("time").
>  >
>  > So as result:
>  > 1) I connect "Local" source from dataEngine("time")
>  > 2) In dataUpdate I use local time and QDataTime for getting time for
>  > choosen timezones
>  >
>  > Is my idea acceptable? Or could it be resolved in other, better way?
>  > It's may first time using DataEngine and I am new in C++ and
>  > developing KDE so I'm not really sure of that.
>
>
> Why don't you just connect to the dataSource for all the timezones you want?
>  The requests should be bundled by the DataEngine anyway, and you get nice and
>  clean data out of the DataEngine that way.

Unfortunately, requests aren't bundled. I made little test: connected
two timezones to my object and then in void Clock::dataUpdated(...) I
put:

kDebug() << "source: " << source << " ; data: " << data;

The result was:

plasma(7067) Clock::dataUpdated: source:  "Local"  ; data:  QHash(
("Timezone Continent", QVariant(QString, "Europe") )
( "Timezone" ,  QVariant(QString, "Europe/Warsaw") )
( "Time" ,  QVariant(QTime, QTime("13:05:12") ) )
( "Date" ,  QVariant(QDate, QDate("pon. mar 17 2008") ) )
( "Timezone City" ,  QVariant(QString, "Warsaw") )
)

plasma(7067) Clock::dataUpdated: source:  "Atlantic/St_Helena"  ; data:  QHash(
("Timezone Continent", QVariant(QString, "Atlantic") )
( "Timezone" ,  QVariant(QString, "Atlantic/St_Helena") )
( "Time" ,  QVariant(QTime, QTime("12:05:12") ) )
( "Date" ,  QVariant(QDate, QDate("pon. mar 17 2008") ) )
( "Timezone City" ,  QVariant(QString, "St_Helena") )
)

plasma(7067) Clock::dataUpdated: source:  "Local"  ; data:  QHash(
("Timezone Continent", QVariant(QString, "Europe") )
( "Timezone" ,  QVariant(QString, "Europe/Warsaw") )
( "Time" ,  QVariant(QTime, QTime("13:05:13") ) )
( "Date" ,  QVariant(QDate, QDate("pon. mar 17 2008") ) ) ( "Timezone
City" ,  QVariant(QString, "Warsaw") ) )

plasma(7067) Clock::dataUpdated: source:  "Atlantic/St_Helena"  ; data:  QHash(
("Timezone Continent", QVariant(QString, "Atlantic") )
( "Timezone" ,  QVariant(QString, "Atlantic/St_Helena") )
( "Time" ,  QVariant(QTime, QTime("12:05:13") ) )
( "Date" ,  QVariant(QDate, QDate("pon. mar 17 2008") ) )
( "Timezone City" ,  QVariant(QString, "St_Helena") )
)

So function dataUpdated is called twice what doesn't allow me to
prepare tooltip without workarounds.

-- 
Rafał Miłecki


More information about the Panel-devel mailing list