2 * timezonecombo.cpp - time zone selection combo box
4 * Copyright © 2006,2008,2009,2011 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "timezonecombo.h"
22 #include <ksystemtimezone.h>
23 #include <KLocalizedString>
26 TimeZoneCombo::TimeZoneCombo(QWidget
* parent
)
29 QString utc
= KTimeZone::utc().name();
30 addItem(utc
); // put UTC at start of list
32 const KTimeZones::ZoneMap zones
= KSystemTimeZones::zones();
33 KTimeZones::ZoneMap::ConstIterator end
= zones
.constEnd();
34 for (KTimeZones::ZoneMap::ConstIterator it
= zones
.constBegin(); it
!= end
; ++it
)
37 mZoneNames
<< it
.key();
38 addItem(i18n(it
.key().toUtf8()).replace(QLatin1Char('_'), QLatin1Char(' ')));
42 KTimeZone
TimeZoneCombo::timeZone() const
44 return KSystemTimeZones::zone(mZoneNames
[currentIndex()]);
47 void TimeZoneCombo::setTimeZone(const KTimeZone
& tz
)
51 int index
= mZoneNames
.indexOf(tz
.name());
53 setCurrentIndex(index
);