View | Details | Raw Unified | Return to bug 60415
Collapse All | Expand All

(-)a/CMakeLists.txt (+5 lines)
Lines 235-240 if (BUILD_KCM_TOUCHPAD_X11) Link Here
235
    )
235
    )
236
endif()
236
endif()
237
237
238
find_package(ICU COMPONENTS i18n uc)
239
set_package_properties(ICU PROPERTIES
240
    PURPOSE "Retrieving timezone info"
241
    TYPE REQUIRED
242
)
238
243
239
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
244
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
240
add_feature_info("XCB-XKB" XCB_XKB_FOUND "Required for building kcm/keyboard")
245
add_feature_info("XCB-XKB" XCB_XKB_FOUND "Required for building kcm/keyboard")
(-)a/kcms/dateandtime/CMakeLists.txt (-5 / +3 lines)
Lines 2-8 Link Here
2
add_definitions(-DTRANSLATION_DOMAIN=\"kcmkclock\")
2
add_definitions(-DTRANSLATION_DOMAIN=\"kcmkclock\")
3
########### next target ###############
3
########### next target ###############
4
4
5
set(kcm_clock_PART_SRCS dtime.cpp main.cpp)
5
set(kcm_clock_PART_SRCS dtime.cpp main.cpp k4timezonewidget.cpp)
6
6
7
ki18n_wrap_ui(kcm_clock_PART_SRCS dateandtime.ui)
7
ki18n_wrap_ui(kcm_clock_PART_SRCS dateandtime.ui)
8
8
Lines 11-22 qt_add_dbus_interface(kcm_clock_PART_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/timedated1 Link Here
11
add_library(kcm_clock MODULE ${kcm_clock_PART_SRCS})
11
add_library(kcm_clock MODULE ${kcm_clock_PART_SRCS})
12
kcmutils_generate_desktop_file(kcm_clock)
12
kcmutils_generate_desktop_file(kcm_clock)
13
13
14
add_subdirectory( ui )
15
16
target_link_libraries(kcm_clock
14
target_link_libraries(kcm_clock
17
    Qt::DBus
15
    Qt::DBus
18
    Qt::Quick
19
    Qt::QuickWidgets
20
    KF6::ItemViews
16
    KF6::ItemViews
21
    KF6::GuiAddons
17
    KF6::GuiAddons
22
    KF6::KCMUtils
18
    KF6::KCMUtils
Lines 25-29 target_link_libraries(kcm_clock Link Here
25
    KF6::KIOCore
21
    KF6::KIOCore
26
    KF6::KIOWidgets
22
    KF6::KIOWidgets
27
    KF6::Svg
23
    KF6::Svg
24
    ICU::i18n
25
    ICU::uc
28
)
26
)
29
install(TARGETS kcm_clock  DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/kcms/systemsettings_qwidgets )
27
install(TARGETS kcm_clock  DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/kcms/systemsettings_qwidgets )
(-)a/kcms/dateandtime/dateandtime.ui (-4 / +54 lines)
Lines 135-150 Link Here
135
       </item>
135
       </item>
136
      </layout>
136
      </layout>
137
     </widget>
137
     </widget>
138
     <widget class="QQuickWidget" name="timezoneViewer">
138
     <widget class="QWidget" name="tab_2">
139
      <attribute name="title">
139
      <attribute name="title">
140
       <string>Time Zone</string>
140
       <string>Time Zone</string>
141
      </attribute>
141
      </attribute>
142
      <layout class="QVBoxLayout" name="verticalLayout">
143
       <item>
144
        <widget class="QLabel" name="label">
145
         <property name="text">
146
          <string>To change the local time zone, select your area from the list below.</string>
147
         </property>
148
        </widget>
149
       </item>
150
       <item>
151
        <spacer name="verticalSpacer_2">
152
         <property name="orientation">
153
          <enum>Qt::Orientation::Vertical</enum>
154
         </property>
155
         <property name="sizeType">
156
          <enum>QSizePolicy::Policy::Fixed</enum>
157
         </property>
158
         <property name="sizeHint" stdset="0">
159
          <size>
160
           <width>20</width>
161
           <height>5</height>
162
          </size>
163
         </property>
164
        </spacer>
165
       </item>
166
       <item>
167
        <widget class="QLabel" name="m_local">
168
         <property name="text">
169
          <string>Current local time zone:</string>
170
         </property>
171
        </widget>
172
       </item>
173
       <item>
174
        <widget class="KTreeWidgetSearchLine" name="tzonesearch">
175
         <property name="enabled">
176
          <bool>true</bool>
177
         </property>
178
         <property name="placeholderText">
179
          <string>Search…</string>
180
         </property>
181
        </widget>
182
       </item>
183
       <item>
184
        <widget class="K4TimeZoneWidget" name="tzonelist"/>
185
       </item>
186
      </layout>
142
     </widget>
187
     </widget>
143
    </widget>
188
    </widget>
144
   </item>
189
   </item>
145
  </layout>
190
  </layout>
146
 </widget>
191
 </widget>
147
 <customwidgets>
192
 <customwidgets>
193
  <customwidget>
194
   <class>K4TimeZoneWidget</class>
195
   <extends>QTreeWidget</extends>
196
   <header>k4timezonewidget.h</header>
197
  </customwidget>
148
  <customwidget>
198
  <customwidget>
149
   <class>KDatePicker</class>
199
   <class>KDatePicker</class>
150
   <extends>QFrame</extends>
200
   <extends>QFrame</extends>
Lines 156-164 Link Here
156
   <header>kseparator.h</header>
206
   <header>kseparator.h</header>
157
  </customwidget>
207
  </customwidget>
158
  <customwidget>
208
  <customwidget>
159
   <class>QQuickWidget</class>
209
   <class>KTreeWidgetSearchLine</class>
160
   <extends>QWidget</extends>
210
   <extends>QLineEdit</extends>
161
   <header location="global">QtQuickWidgets/QQuickWidget</header>
211
   <header>ktreewidgetsearchline.h</header>
162
  </customwidget>
212
  </customwidget>
163
 </customwidgets>
213
 </customwidgets>
164
 <resources/>
214
 <resources/>
(-)a/kcms/dateandtime/dtime.cpp (-13 / +29 lines)
Lines 18-24 Link Here
18
#include <QGroupBox>
18
#include <QGroupBox>
19
#include <QPainter>
19
#include <QPainter>
20
#include <QPushButton>
20
#include <QPushButton>
21
#include <QQmlEngine>
21
#include <QSignalBlocker>
22
#include <QTimeEdit>
22
#include <QTimeEdit>
23
23
24
#include <KConfig>
24
#include <KConfig>
Lines 30-40 Link Here
30
#include <QDebug>
30
#include <QDebug>
31
#include <QGridLayout>
31
#include <QGridLayout>
32
#include <QHBoxLayout>
32
#include <QHBoxLayout>
33
#include <QQmlContext>
34
#include <QVBoxLayout>
33
#include <QVBoxLayout>
35
34
36
#include <KLocalizedString>
35
#include <KLocalizedString>
37
#include <KLocalizedContext>
38
#include <KSvg/Svg>
36
#include <KSvg/Svg>
39
37
40
#include "timedated_interface.h"
38
#include "timedated_interface.h"
Lines 82-102 Dtime::Dtime(QWidget *parent) Link Here
82
80
83
    tabWidget->tabBar()->setExpanding(true);
81
    tabWidget->tabBar()->setExpanding(true);
84
82
85
    auto engine = timezoneViewer->engine();
83
    // Timezone
86
    engine->rootContext()->setContextObject(new KLocalizedContext(engine));
84
    connect(tzonelist, &K4TimeZoneWidget::itemSelectionChanged, this, [this]() {
87
85
        const QStringList selectedZones(tzonelist->selection());
88
    timezoneViewer->rootContext()->setContextProperty("DTime", this);
86
        setSelectedTimeZone(selectedZones.isEmpty() ? QString() : selectedZones.constFirst());
89
    timezoneViewer->setSource(QUrl("qrc:/kcm/kcm_clock/main.qml"));
87
    });
90
    timezoneViewer->resize(QSize(500, 600));
88
    tzonesearch->setTreeWidget(tzonelist);
91
    timezoneViewer->setResizeMode(QQuickWidget::SizeRootObjectToView);
92
    timezoneViewer->setClearColor(Qt::transparent);
93
    timezoneViewer->setAttribute(Qt::WA_AlwaysStackOnTop);
94
}
89
}
95
90
96
void Dtime::currentZone()
91
void Dtime::currentZone()
97
{
92
{
98
    QTimeZone localZone = QTimeZone::systemTimeZone();
93
    QTimeZone localZone = QTimeZone::systemTimeZone();
99
    setSelectedTimeZone(localZone.id());
94
    const auto continentCity = localZone.id().split('/');
95
    // Use the translation catalog of the digitalclock applet until there is a standard API for city/continent names.
96
    const char *domain = "plasma_applet_org.kde.plasma.digitalclock.mo";
97
    QString displayName = i18nd(domain, continentCity[0]);
98
    if (continentCity.size() > 1) {
99
        displayName += '/' + i18nd(domain, continentCity[1]);
100
    }
101
    const QString abbreviation = localZone.abbreviation(QDateTime::currentDateTime());
102
    if (abbreviation.isEmpty()) {
103
        m_local->setText(i18nc("%1 is name of time zone", "Current local time zone: %1", displayName));
104
    } else {
105
        m_local->setText(i18nc("%1 is name of time zone, %2 is its abbreviation", "Current local time zone: %1 (%2)", displayName, abbreviation));
106
    }
100
}
107
}
101
108
102
void Dtime::set_time()
109
void Dtime::set_time()
Lines 148-153 void Dtime::load() Link Here
148
    // Timezone
155
    // Timezone
149
    currentZone();
156
    currentZone();
150
157
158
    setSelectedTimeZone(currentTimeZone);
151
    Q_EMIT timeChanged(false);
159
    Q_EMIT timeChanged(false);
152
}
160
}
153
161
Lines 163-168 void Dtime::setSelectedTimeZone(QString selectedTimeZone) Link Here
163
    }
171
    }
164
172
165
    m_selectedTimeZone = selectedTimeZone;
173
    m_selectedTimeZone = selectedTimeZone;
174
175
    const QSignalBlocker blocker(tzonelist);
176
    if (selectedTimeZone.isEmpty()) {
177
        tzonelist->clearSelection();
178
    } else {
179
        tzonelist->setSelected(selectedTimeZone, true);
180
    }
181
166
    Q_EMIT selectedTimeZoneChanged(true);
182
    Q_EMIT selectedTimeZoneChanged(true);
167
}
183
}
168
184
(-)a/kcms/dateandtime/k4timezonewidget.cpp (+262 lines)
Line 0 Link Here
1
/*
2
    Copyright (C) 2005, S.R.Haque <srhaque@iee.org>.
3
    Copyright (C) 2009, David Faure <faure@kde.org>
4
    This file is part of the KDE project
5
6
    This library is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Library General Public
8
    License version 2, as published by the Free Software Foundation.
9
10
    This library is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
    Library General Public License for more details.
14
15
    You should have received a copy of the GNU Library General Public License
16
    along with this library; see the file COPYING.LIB.  If not, write to
17
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
    Boston, MA 02110-1301, USA.
19
*/
20
21
#include "k4timezonewidget.h"
22
23
#include <algorithm>
24
#include <memory>
25
26
#include <KCountry>
27
#include <KCountryFlagEmojiIconEngine>
28
#include <KLocalizedString>
29
30
#include <QDebug>
31
#include <QFile>
32
#include <QPixmap>
33
#include <QTimeZone>
34
35
#include <unicode/localebuilder.h>
36
#include <unicode/tznames.h>
37
#include <unicode/unistr.h>
38
39
class Q_DECL_HIDDEN K4TimeZoneWidget::Private
40
{
41
public:
42
    Private()
43
        : itemsCheckable(false)
44
        , singleSelection(true)
45
    {
46
    }
47
48
    enum Columns {
49
        CityColumn = 0,
50
        RegionColumn,
51
        CommentColumn,
52
    };
53
54
    enum Roles {
55
        ZoneRole = Qt::UserRole + 0xF3A3CB1,
56
    };
57
58
    bool itemsCheckable;
59
    bool singleSelection;
60
};
61
62
static bool localeLessThan(const QString &a, const QString &b)
63
{
64
    return QString::localeAwareCompare(a, b) < 0;
65
}
66
67
K4TimeZoneWidget::K4TimeZoneWidget(QWidget *parent)
68
    : QTreeWidget(parent)
69
    , d(new K4TimeZoneWidget::Private)
70
{
71
    // If the user did not provide a timezone database, we'll use the system default.
72
    setRootIsDecorated(false);
73
    setHeaderLabels(QStringList() << i18nc("Define an area in the time zone, like a town area", "Area") << i18nc("Time zone", "Region") << i18n("Comment"));
74
75
    const auto locale = icu::Locale(QLocale::system().name().toLatin1());
76
    UErrorCode error = U_ZERO_ERROR;
77
    std::unique_ptr<icu::TimeZoneNames> tzNames(icu::TimeZoneNames::createInstance(locale, error));
78
    if (!U_SUCCESS(error)) {
79
        qWarning() << "failed to create timezone names" << u_errorName(error);
80
        return;
81
    };
82
    icu::UnicodeString result;
83
84
    const auto timezones = QTimeZone::availableTimeZoneIds();
85
86
    struct TimeZoneInfo {
87
        QTimeZone zone;
88
        QString region;
89
        QString city;
90
    };
91
92
    std::vector<TimeZoneInfo> zones;
93
    zones.reserve(timezones.size());
94
    for (const auto &id : timezones) {
95
        const int separator = id.lastIndexOf('/');
96
        // Make up the localized key that will be used for sorting.
97
        // Example: Asia/Tokyo -> key = "i18n(Tokyo)|i18n(Asia)|Asia/Tokyo"
98
        // The zone name is appended to ensure unicity even with equal translations (#174918)
99
        // since there is no  API continent names, we use the translation catalog of the digitalclock applet which contain these
100
        const char *domain = "plasma_applet_org.kde.plasma.digitalclock.mo";
101
        const QString continent = separator > 0 ? i18nd(domain, id.left(separator)) : QString();
102
        const icu::UnicodeString &exemplarCity = tzNames->getExemplarLocationName(icu::UnicodeString::fromUTF8(icu::StringPiece(id.data(), id.size())), result);
103
        zones.push_back(
104
            {QTimeZone(id), continent, exemplarCity.isBogus() ? QString::fromLatin1(id) : QString::fromUtf16(exemplarCity.getBuffer(), exemplarCity.length())});
105
    }
106
    std::sort(zones.begin(), zones.end(), [](const TimeZoneInfo &left, const TimeZoneInfo &right) {
107
        if (auto result = QString::localeAwareCompare(left.city, right.city); result != 0) {
108
            return result < 0;
109
        }
110
        if (auto result = QString::localeAwareCompare(left.region, right.region); result != 0) {
111
            return result < 0;
112
        }
113
        return QString::localeAwareCompare(left.zone.id(), right.zone.id()) < 0;
114
    });
115
116
    for (const auto &zoneInfo : zones) {
117
        const QTimeZone &zone = zoneInfo.zone;
118
        const QString tzName = zone.id();
119
        QString comment = zone.comment();
120
121
        if (!comment.isEmpty()) {
122
            comment = i18n(comment.toUtf8());
123
        }
124
125
        QTreeWidgetItem *listItem = new QTreeWidgetItem(this);
126
        listItem->setText(Private::CityColumn, zoneInfo.city);
127
        QString countryName = KCountry::fromQLocale(zone.territory()).name();
128
        if (countryName.isEmpty()) {
129
            countryName = QLocale::territoryToCode(zone.territory());
130
        }
131
        QString regionLabel = zoneInfo.region;
132
        if (!regionLabel.isEmpty() && !countryName.isEmpty()) {
133
            regionLabel += '/';
134
        }
135
        regionLabel += countryName;
136
137
        listItem->setText(Private::RegionColumn, regionLabel);
138
        listItem->setText(Private::CommentColumn, comment);
139
        listItem->setData(Private::CityColumn, Private::ZoneRole, tzName); // store complete path in custom role
140
141
        listItem->setIcon(Private::RegionColumn, QIcon(new KCountryFlagEmojiIconEngine(QLocale::territoryToCode(zone.territory()))));
142
    }
143
}
144
145
K4TimeZoneWidget::~K4TimeZoneWidget()
146
{
147
    delete d;
148
}
149
150
void K4TimeZoneWidget::setItemsCheckable(bool enable)
151
{
152
    d->itemsCheckable = enable;
153
    const int count = topLevelItemCount();
154
    for (int row = 0; row < count; ++row) {
155
        QTreeWidgetItem *listItem = topLevelItem(row);
156
        listItem->setCheckState(Private::CityColumn, Qt::Unchecked);
157
    }
158
    QTreeWidget::setSelectionMode(QAbstractItemView::NoSelection);
159
}
160
161
bool K4TimeZoneWidget::itemsCheckable() const
162
{
163
    return d->itemsCheckable;
164
}
165
166
QStringList K4TimeZoneWidget::selection() const
167
{
168
    QStringList selection;
169
170
    // Loop through all entries.
171
    // Do not use selectedItems() because it skips hidden items, making it
172
    // impossible to use a KTreeWidgetSearchLine.
173
    // There is no QTreeWidgetItemConstIterator, hence the const_cast :/
174
    QTreeWidgetItemIterator it(const_cast<K4TimeZoneWidget *>(this), d->itemsCheckable ? QTreeWidgetItemIterator::Checked : QTreeWidgetItemIterator::Selected);
175
    for (; *it; ++it) {
176
        selection.append((*it)->data(Private::CityColumn, Private::ZoneRole).toString());
177
    }
178
179
    return selection;
180
}
181
182
void K4TimeZoneWidget::setSelected(const QString &zone, bool selected)
183
{
184
    bool found = false;
185
186
    // The code was using findItems( zone, Qt::MatchExactly, Private::ZoneColumn )
187
    // previously, but the underlying model only has 3 columns, the "hidden" column
188
    // wasn't available in there.
189
190
    if (!d->itemsCheckable) {
191
        // Runtime compatibility for < 4.3 apps, which don't call the setMultiSelection reimplementation.
192
        d->singleSelection = (QTreeWidget::selectionMode() == QAbstractItemView::SingleSelection);
193
    }
194
195
    // Loop through all entries.
196
    const int rowCount = model()->rowCount(QModelIndex());
197
    for (int row = 0; row < rowCount; ++row) {
198
        const QModelIndex index = model()->index(row, Private::CityColumn);
199
        const QString tzName = index.data(Private::ZoneRole).toString();
200
        if (tzName == zone) {
201
            if (d->singleSelection && selected) {
202
                clearSelection();
203
            }
204
205
            if (d->itemsCheckable) {
206
                QTreeWidgetItem *listItem = itemFromIndex(index);
207
                listItem->setCheckState(Private::CityColumn, selected ? Qt::Checked : Qt::Unchecked);
208
            } else {
209
                selectionModel()->select(index,
210
                                         selected ? (QItemSelectionModel::Select | QItemSelectionModel::Rows)
211
                                                  : (QItemSelectionModel::Deselect | QItemSelectionModel::Rows));
212
            }
213
214
            // Ensure the selected item is visible as appropriate.
215
            scrollTo(index);
216
217
            found = true;
218
219
            if (d->singleSelection && selected) {
220
                break;
221
            }
222
        }
223
    }
224
225
    if (!found) {
226
        qDebug() << "No such zone: " << zone;
227
    }
228
}
229
230
void K4TimeZoneWidget::clearSelection()
231
{
232
    if (d->itemsCheckable) {
233
        // Un-select all items
234
        const int rowCount = model()->rowCount(QModelIndex());
235
        for (int row = 0; row < rowCount; ++row) {
236
            const QModelIndex index = model()->index(row, 0);
237
            QTreeWidgetItem *listItem = itemFromIndex(index);
238
            listItem->setCheckState(Private::CityColumn, Qt::Unchecked);
239
        }
240
    } else {
241
        QTreeWidget::clearSelection();
242
    }
243
}
244
245
void K4TimeZoneWidget::setSelectionMode(QAbstractItemView::SelectionMode mode)
246
{
247
    d->singleSelection = (mode == QAbstractItemView::SingleSelection);
248
    if (!d->itemsCheckable) {
249
        QTreeWidget::setSelectionMode(mode);
250
    }
251
}
252
253
QAbstractItemView::SelectionMode K4TimeZoneWidget::selectionMode() const
254
{
255
    if (d->itemsCheckable) {
256
        return d->singleSelection ? QTreeWidget::SingleSelection : QTreeWidget::MultiSelection;
257
    } else {
258
        return QTreeWidget::selectionMode();
259
    }
260
}
261
262
#include "moc_k4timezonewidget.cpp"
(-)a/kcms/dateandtime/k4timezonewidget.h (+139 lines)
Line 0 Link Here
1
/*
2
    Copyright (C) 2005, S.R.Haque <srhaque@iee.org>.
3
    This file is part of the KDE project
4
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Library General Public
7
    License version 2, as published by the Free Software Foundation.
8
9
    This library is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
    Library General Public License for more details.
13
14
    You should have received a copy of the GNU Library General Public License
15
    along with this library; see the file COPYING.LIB.  If not, write to
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
    Boston, MA 02110-1301, USA.
18
*/
19
20
#ifndef KTIMEZONEWIDGET_H
21
#define KTIMEZONEWIDGET_H
22
23
#include <QTreeWidget>
24
25
class KTimeZones;
26
27
/**
28
 * @brief A time zone selection widget.
29
 *
30
 * \b Detail:
31
 *
32
 * This class provides for selection of one or more time zones.
33
 *
34
 * \b Example:
35
 *
36
 * To use the class to implement a system timezone selection feature:
37
 * \code
38
 *
39
 *  // This adds a time zone widget to a dialog.
40
 *  m_timezones = new K4TimeZoneWidget(this);
41
 *  ...
42
 * \endcode
43
 *
44
 * To use the class to implement a multiple-choice custom time zone selector:
45
 * \code
46
 *
47
 *  m_timezones = new K4TimeZoneWidget( this, "Time zones", vcalendarTimezones );
48
 *  m_timezones->setSelectionMode( QTreeView::MultiSelection );
49
 *  ...
50
 * \endcode
51
 *
52
 * \image html ktimezonewidget.png "KDE Time Zone Widget"
53
 *
54
 * @author S.R.Haque <srhaque@iee.org>
55
 */
56
57
class K4TimeZoneWidget : public QTreeWidget
58
{
59
    Q_OBJECT
60
    Q_PROPERTY(bool itemsCheckable READ itemsCheckable WRITE setItemsCheckable)
61
    Q_PROPERTY(QAbstractItemView::SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
62
63
public:
64
    /**
65
     * Constructs a time zone selection widget.
66
     *
67
     * @param parent The parent widget.
68
     * @param timeZones The time zone database to use. If 0, the system time zone
69
     *                  database is used.
70
     */
71
    explicit K4TimeZoneWidget(QWidget *parent = nullptr);
72
73
    /**
74
     * Destroys the time zone selection widget.
75
     */
76
    ~K4TimeZoneWidget() override;
77
78
    /**
79
     * Makes all items show a checkbox, so that the user can select multiple
80
     * timezones by means of checking checkboxes, rather than via multi-selection.
81
     *
82
     * In "items checkable" mode, the selection(), setSelected() and clearSelection()
83
     * methods work on the check states rather than on selecting/unselecting.
84
     *
85
     * @since 4.4
86
     */
87
    void setItemsCheckable(bool enable);
88
    /**
89
     * @return true if setItemsCheckable(true) was called.
90
     * @since 4.4
91
     */
92
    bool itemsCheckable() const;
93
94
    /**
95
     * Allows to select multiple timezones. This is the same as
96
     * setSelectionMode(K4TimeZoneWidget::MultiSelection) normally,
97
     * but in "items checkable" mode, this is rather about allowing to
98
     * check multiple items. In that case, the actual QTreeWidget selection
99
     * mode remains unchanged.
100
     * @since 4.4
101
     */
102
    void setSelectionMode(QAbstractItemView::SelectionMode mode);
103
104
    /**
105
     * @return the selection mode set by setSelectionMode().
106
     * @since 4.4
107
     */
108
    QAbstractItemView::SelectionMode selectionMode() const;
109
110
    /**
111
     * Returns the currently selected time zones. See QTreeView::selectionChanged().
112
     *
113
     * @return a list of time zone names, in the format used by the database
114
     *         supplied to the {@link K4TimeZoneWidget() } constructor.
115
     */
116
    QStringList selection() const;
117
118
    /**
119
     * Select/deselect the named time zone.
120
     *
121
     * @param zone The time zone name to be selected. Ignored if not recognized!
122
     * @param selected The new selection state.
123
     */
124
    void setSelected(const QString &zone, bool selected);
125
126
    /**
127
     * Unselect all timezones.
128
     * This is the same as QTreeWidget::clearSelection, except in checkable items mode,
129
     * where items are all unchecked.
130
     * The overload is @since 4.4.
131
     */
132
    void clearSelection();
133
134
private:
135
    class Private;
136
    Private *const d;
137
};
138
139
#endif
(-)a/kcms/dateandtime/ui/CMakeLists.txt (-5 lines)
Lines 1-5 Link Here
1
qt_add_resources(
2
    kcm_clock "timezone_files"
3
    PREFIX "kcm/kcm_clock"
4
    FILES "main.qml"
5
)
(-)a/kcms/dateandtime/ui/main.qml (-24 lines)
Lines 1-24 Link Here
1
/*
2
 *   SPDX-FileCopyrightText: 2024 Niccolò Venerandi <niccolo@venerandi.com>
3
 *
4
 *   SPDX-License-Identifier: GPL-2.0-or-later
5
 */
6
7
import QtQuick
8
9
import org.kde.plasma.workspace.timezoneselector as TimeZone
10
11
TimeZone.TimezoneSelector {
12
    selectedTimeZone: DTime.selectedTimeZone
13
14
    Connections {
15
        target: DTime
16
        onSelectedTimeZoneChanged: {
17
            selectedTimeZone = DTime.selectedTimeZone
18
        }
19
    }
20
21
    onSelectedTimeZoneChanged: {
22
        DTime.selectedTimeZone = selectedTimeZone
23
    }
24
}
(-)a/po/ru/kcmkclock.po (-29 / +47 lines)
Lines 65-70 msgstr "Здесь вы можете изменить системную дат Link Here
65
msgid "Time Zone"
65
msgid "Time Zone"
66
msgstr "Часовой пояс"
66
msgstr "Часовой пояс"
67
67
68
#. i18n: ectx: property (text), widget (QLabel, label)
69
#: dateandtime.ui
70
#, kde-format
71
msgid "To change the local time zone, select your area from the list below."
72
msgstr "Для изменения часового пояса выберите свой регион из списка."
73
74
#. i18n: ectx: property (text), widget (QLabel, m_local)
75
#: dateandtime.ui
76
#, kde-format
77
msgid "Current local time zone:"
78
msgstr "Текущий часовой пояс:"
79
80
#. i18n: ectx: property (placeholderText), widget (KTreeWidgetSearchLine, tzonesearch)
81
#: dateandtime.ui
82
#, kde-format
83
msgid "Search…"
84
msgstr "Введите местоположение..."
85
86
#: dtime.cpp
87
#, kde-format
88
msgctxt "%1 is name of time zone"
89
msgid "Current local time zone: %1"
90
msgstr "Текущий часовой пояс: %1"
91
92
#: dtime.cpp
93
#, kde-format
94
msgctxt "%1 is name of time zone, %2 is its abbreviation"
95
msgid "Current local time zone: %1 (%2)"
96
msgstr "Текущий часовой пояс: %1 (%2)"
97
98
#: k4timezonewidget.cpp
99
#, kde-format
100
msgctxt "Define an area in the time zone, like a town area"
101
msgid "Area"
102
msgstr "Область"
103
104
#: k4timezonewidget.cpp
105
#, kde-format
106
msgctxt "Time zone"
107
msgid "Region"
108
msgstr "Регион"
109
110
#: k4timezonewidget.cpp
111
#, kde-format
112
msgid "Comment"
113
msgstr "Комментарий"
114
68
#: dtime.cpp:71
115
#: dtime.cpp:71
69
#, kde-format
116
#, kde-format
70
msgid ""
117
msgid ""
Lines 142-175 msgstr "Не удалось сменить часовой пояс" Link Here
142
#~ msgid "Unable to authenticate/execute the action: %1, %2"
189
#~ msgid "Unable to authenticate/execute the action: %1, %2"
143
#~ msgstr "Не удалось авторизоваться и выполнить действие: %1, %2"
190
#~ msgstr "Не удалось авторизоваться и выполнить действие: %1, %2"
144
191
145
#~ msgid "To change the local time zone, select your area from the list below."
146
#~ msgstr "Для изменения часового пояса выберите свой регион из списка."
147
148
#~ msgid "Current local time zone:"
149
#~ msgstr "Текущий часовой пояс:"
150
151
#~ msgid "Search…"
152
#~ msgstr "Введите местоположение..."
153
154
#~ msgctxt "%1 is name of time zone"
155
#~ msgid "Current local time zone: %1"
156
#~ msgstr "Текущий часовой пояс: %1"
157
158
#~ msgctxt "%1 is name of time zone, %2 is its abbreviation"
159
#~ msgid "Current local time zone: %1 (%2)"
160
#~ msgstr "Текущий часовой пояс: %1 (%2)"
161
162
#~ msgctxt "Define an area in the time zone, like a town area"
163
#~ msgid "Area"
164
#~ msgstr "Область"
165
166
#~ msgctxt "Time zone"
167
#~ msgid "Region"
168
#~ msgstr "Регион"
169
170
#~ msgid "Comment"
171
#~ msgstr "Комментарий"
172
173
#~ msgid "KDE Clock Control Module"
192
#~ msgid "KDE Clock Control Module"
174
#~ msgstr "Модуль настройки часов KDE"
193
#~ msgstr "Модуль настройки часов KDE"
175
194
176
- 

Return to bug 60415