SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / kalarm / lib / timezonecombo.cpp
blobb8011e6cbff0d4881cc6723f559554dc8dfb026d
1 /*
2 * timezonecombo.cpp - time zone selection combo box
3 * Program: kalarm
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)
27 : ComboBox(parent)
29 QString utc = KTimeZone::utc().name();
30 addItem(utc); // put UTC at start of list
31 mZoneNames << utc;
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)
35 if (it.key() != utc)
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)
49 if (!tz.isValid())
50 return;
51 int index = mZoneNames.indexOf(tz.name());
52 if (index >= 0)
53 setCurrentIndex(index);
56 // vim: et sw=4: