summaryrefslogtreecommitdiffstats
path: root/src/timedatesettings
diff options
context:
space:
mode:
Diffstat (limited to 'src/timedatesettings')
-rw-r--r--src/timedatesettings/systemtime.cpp128
-rw-r--r--src/timedatesettings/systemtime.h70
-rw-r--r--src/timedatesettings/systemtime_p.h95
-rw-r--r--src/timedatesettings/timedated.xml30
-rw-r--r--src/timedatesettings/timedatesettings.pro22
-rw-r--r--src/timedatesettings/timezonefiltermodel.cpp118
-rw-r--r--src/timedatesettings/timezonefiltermodel.h69
-rw-r--r--src/timedatesettings/timezonemodel.cpp244
-rw-r--r--src/timedatesettings/timezonemodel.h94
9 files changed, 0 insertions, 870 deletions
diff --git a/src/timedatesettings/systemtime.cpp b/src/timedatesettings/systemtime.cpp
deleted file mode 100644
index 9382fd9..0000000
--- a/src/timedatesettings/systemtime.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "systemtime.h"
-#include "systemtime_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \module QtTimeDateSettings
- \qtvariable timedatesettings
- \ingroup qtdevice-utilities-cpp-modules
- \ingroup modules
- \title Qt Time and Date Settings C++ Classes
- \brief Provides functionality for controlling time and date settings.
-
- To use classes from this module, add this directive into the C++ files:
-
- \code
- #include <QtTimeDateSettings>
- \endcode
-
- To link against the corresponding C++ libraries, add the following to your
- qmake project file:
-
- \code
- QT += timedatesettings
- \endcode
-*/
-
-/*!
- \class SystemTime
- \inmodule QtTimeDateSettings
- \inheaderfile systemtime.h
- \brief The SystemTime class manages the system date and time.
-*/
-
-/*!
- \property SystemTime::timeZone
- \brief Holds the current time zone string.
-*/
-
-/*!
- \property SystemTime::ntp
-
- Holds whether the system time is synchronized using NTP (Network
- Time Protocol).
-*/
-
-/*!
- \property SystemTime::time
- \brief Holds the current date and time.
-*/
-
-SystemTime::SystemTime(QObject *parent) :
- QObject(parent)
- ,d_ptr(new SystemTimePrivate(this))
-{
- QTimer *secTimer = new QTimer(this);
- connect(secTimer, &QTimer::timeout, this, &SystemTime::timeChanged);
- secTimer->setInterval(1001);
- secTimer->setSingleShot(false);
- secTimer->start();
-}
-
-bool SystemTime::ntp() const
-{
- const Q_D(SystemTime);
- return d->ntp();
-}
-
-void SystemTime::setNtp(const bool aNtp)
-{
- Q_D(SystemTime);
- d->setNtp(aNtp);
-}
-
-void SystemTime::setTime(const QDateTime& aTime)
-{
- Q_D(SystemTime);
- d->setTime(aTime.toMSecsSinceEpoch()*1000);
- emit timeChanged();
-}
-
-QString SystemTime::timeZone() const
-{
- Q_D(const SystemTime);
- return d->timeZone();
-}
-
-void SystemTime::setTimeZone(const QString& aTimeZone)
-{
- Q_D(SystemTime);
- d->setTimeZone(aTimeZone);
- emit timeZoneChanged();
-}
-
-QDateTime SystemTime::time() const
-{
- return QDateTime::currentDateTime();
-}
-
-QT_END_NAMESPACE
diff --git a/src/timedatesettings/systemtime.h b/src/timedatesettings/systemtime.h
deleted file mode 100644
index bcb46df..0000000
--- a/src/timedatesettings/systemtime.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef SYSTEMTIME_H
-#define SYSTEMTIME_H
-
-#include <QObject>
-#include <QTime>
-
-QT_BEGIN_NAMESPACE
-
-class SystemTimePrivate;
-
-class Q_DECL_EXPORT SystemTime : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString timeZone READ timeZone WRITE setTimeZone NOTIFY timeZoneChanged)
- Q_PROPERTY(bool ntp READ ntp WRITE setNtp NOTIFY ntpChanged)
- Q_PROPERTY(QDateTime time READ time WRITE setTime NOTIFY timeChanged)
-public:
- explicit SystemTime(QObject *parent = Q_NULLPTR);
- bool ntp() const;
- void setNtp(const bool aNtp);
- void setTime(const QDateTime& aTime);
- QString timeZone() const;
- QDateTime time() const;
- void setTimeZone(const QString& aTimeZone);
-
-Q_SIGNALS:
- void timeZoneChanged();
- void ntpChanged();
- void timeChanged();
-
-public Q_SLOTS:
-
-protected:
- SystemTimePrivate *d_ptr;
-
- Q_DISABLE_COPY(SystemTime)
- Q_DECLARE_PRIVATE(SystemTime)
-};
-
-QT_END_NAMESPACE
-
-#endif // SYSTEMTIME_H
diff --git a/src/timedatesettings/systemtime_p.h b/src/timedatesettings/systemtime_p.h
deleted file mode 100644
index b294598..0000000
--- a/src/timedatesettings/systemtime_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef SYSTEMTIME_P_H
-#define SYSTEMTIME_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "systemtime.h"
-#include "timedated_interface.h"
-
-QT_BEGIN_NAMESPACE
-
-class SystemTimePrivate
-{
- Q_DECLARE_PUBLIC(SystemTime)
-public:
- SystemTimePrivate(SystemTime *qq)
- :q_ptr(qq)
- {
- m_timeInterface = new OrgFreedesktopTimedate1Interface(QStringLiteral("org.freedesktop.timedate1"),
- QStringLiteral("/org/freedesktop/timedate1"),
- QDBusConnection::systemBus(), qq);
-
- }
-
- bool ntp() const {
- if (m_timeInterface)
- return m_timeInterface->nTP();
- return false;
- }
-
- void setNtp(bool val) {
- if (m_timeInterface)
- m_timeInterface->SetNTP(val, true).waitForFinished();
- }
-
- QString timeZone() const {
- if (m_timeInterface)
- return m_timeInterface->timezone();
- return QString();
- }
-
- void setTimeZone(const QString& aTimeZone) {
- if (m_timeInterface)
- m_timeInterface->SetTimezone(aTimeZone, true);
- }
-
- void setTime(qlonglong usecsSinceEpoch) {
- if (m_timeInterface)
- m_timeInterface->SetTime(usecsSinceEpoch, false, true);
- }
-
-private:
- OrgFreedesktopTimedate1Interface *m_timeInterface;
- SystemTime *q_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // SYSTEMTIME_P_H
diff --git a/src/timedatesettings/timedated.xml b/src/timedatesettings/timedated.xml
deleted file mode 100644
index 95bafb8..0000000
--- a/src/timedatesettings/timedated.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<node name="/Service" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
-<node>
- <interface name="org.freedesktop.timedate1">
- <property name="Timezone" type="s" access="read"/>
- <property name="LocalRTC" type="b" access="read"/>
- <property name="CanNTP" type="b" access="read"/>
- <property name="NTP" type="b" access="read"/>
- <method name="SetTime">
- <arg name="usec_utc" type="x" direction="in"/>
- <arg name="relative" type="b" direction="in"/>
- <arg name="user_interaction" type="b" direction="in"/>
- </method>
- <method name="SetTimezone">
- <arg name="timezone" type="s" direction="in"/>
- <arg name="user_interaction" type="b" direction="in"/>
- </method>
- <method name="SetLocalRTC">
- <arg name="local_rtc" type="b" direction="in"/>
- <arg name="fix_system" type="b" direction="in"/>
- <arg name="user_interaction" type="b" direction="in"/>
- </method>
- <method name="SetNTP">
- <arg name="use_ntp" type="b" direction="in"/>
- <arg name="user_interaction" type="b" direction="in"/>
- </method>
- </interface>
-</node>
-
-
diff --git a/src/timedatesettings/timedatesettings.pro b/src/timedatesettings/timedatesettings.pro
deleted file mode 100644
index 6c35777..0000000
--- a/src/timedatesettings/timedatesettings.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-load(qt_build_config)
-
-TARGET = QtTimeDateSettings
-VERSION = 1.0
-
-QT = core dbus
-
-MODULE = timedatesettings
-load(qt_module)
-
-DBUS_INTERFACES = timedated.xml
-
-SOURCES += systemtime.cpp \
- timezonemodel.cpp \
- timezonefiltermodel.cpp
-
-HEADERS += \
- systemtime.h \
- systemtime_p.h \
- timezonemodel.h \
- timezonefiltermodel.h
-
diff --git a/src/timedatesettings/timezonefiltermodel.cpp b/src/timedatesettings/timezonefiltermodel.cpp
deleted file mode 100644
index b566624..0000000
--- a/src/timedatesettings/timezonefiltermodel.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "timezonemodel.h"
-#include "timezonefiltermodel.h"
-
-QT_BEGIN_NAMESPACE
-
-TimezoneFilterModel::TimezoneFilterModel(QObject* parent)
- :QSortFilterProxyModel(parent)
-{
- connect(this, &TimezoneFilterModel::filterChanged, this, &TimezoneFilterModel::invalidate);
- TimezoneModel* timezoneModel = new TimezoneModel(this);
- setSourceModel(timezoneModel);
-}
-
-TimezoneFilterModel::~TimezoneFilterModel()
-{
-
-}
-
-QString TimezoneFilterModel::filter() const
-{
- return m_filter;
-}
-
-void TimezoneFilterModel::setFilter(const QString& aFilter)
-{
- m_filter = aFilter;
- emit filterChanged();
-}
-
-bool TimezoneFilterModel::filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const
-{
- bool ret = false;
- if (this->sourceModel())
- {
- QModelIndex index = this->sourceModel()->index( source_row, 0, source_parent );
- if (index.isValid())
- {
- QVariant nameRole = index.data(TimezoneModel::Name);
- if (nameRole.isValid())
- {
- QString name = nameRole.toString();
- if (name.contains(m_filter, Qt::CaseInsensitive)) {
- ret = true;
- }
- }
- QVariant countryRole = index.data(TimezoneModel::Country);
- if (ret == false && countryRole.isValid())
- {
- QString country = countryRole.toString();
- if (country.contains(m_filter, Qt::CaseInsensitive)) {
- ret = true;
- }
- }
- }
- }
- return ret;
-}
-
-QVariant TimezoneFilterModel::itemFromRow(const int row) const
-{
- QModelIndex idx = index(row, 0);
- QModelIndex mapped = mapToSource(idx);
- if (mapped.isValid())
- {
- QVariant nameRole = mapped.data(TimezoneModel::Name);
- if (nameRole.isValid())
- {
- return nameRole;
- }
- }
- return QVariant();
-}
-
-int TimezoneFilterModel::indexForTimezone(const QString &timezone) const
-{
- TimezoneModel *model = qobject_cast<TimezoneModel *>(sourceModel());
- QList<TimezoneItem *> data = model->getModel();
- int row = 0;
- foreach (TimezoneItem *item, data) {
- if (item->id() == timezone) {
- QModelIndex mapped = mapFromSource(model->index(row));
- return mapped.row();
- }
- row++;
- }
-
- return -1;
-}
-
-QT_END_NAMESPACE
diff --git a/src/timedatesettings/timezonefiltermodel.h b/src/timedatesettings/timezonefiltermodel.h
deleted file mode 100644
index ead5eb0..0000000
--- a/src/timedatesettings/timezonefiltermodel.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TIMEZONEFILTERMODEL_H
-#define TIMEZONEFILTERMODEL_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QSortFilterProxyModel>
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECL_EXPORT TimezoneFilterModel : public QSortFilterProxyModel
-{
- Q_OBJECT
- Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
-public:
- explicit TimezoneFilterModel(QObject* parent);
- virtual ~TimezoneFilterModel();
- bool filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const override;
- QString filter() const;
- void setFilter(const QString& aFilter);
- Q_INVOKABLE QVariant itemFromRow(const int row) const;
- Q_INVOKABLE int indexForTimezone(const QString &timezone) const;
-Q_SIGNALS:
- void filterChanged();
- void selectedIndexChanged();
-private:
- QString m_filter;
-
-};
-
-QT_END_NAMESPACE
-
-#endif // TIMEZONEFILTERMODEL_H
diff --git a/src/timedatesettings/timezonemodel.cpp b/src/timedatesettings/timezonemodel.cpp
deleted file mode 100644
index d30f22e..0000000
--- a/src/timedatesettings/timezonemodel.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QLocale>
-#include <QFuture>
-#include <QFutureWatcher>
-#include <QThread>
-#include <QtConcurrent/QtConcurrentRun>
-#include "timezonemodel.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class TimezoneItem
- \inmodule QtTimeDateSettings
- \inheaderfile timezonemodel.h
- \brief The TimezoneItem class represents a time zone.
-*/
-
-/*!
- \property TimezoneItem::id
- \brief Holds the IANA time zone ID.
-
- \sa QTimeZone::id(), {IANA Time Zone IDs}
-*/
-
-/*!
- \property TimezoneItem::name
- \brief Holds the localized display name of the time zone.
-
- \sa QTimeZone::displayName()
-*/
-
-/*!
- \property TimezoneItem::country
- \brief Holds the name of the country for the time zone.
-
- \sa QTimeZone::country()
-*/
-
-/*!
- Creates a time zone item with the IANA time zone ID \a id and parent
- \a parent.
-*/
-TimezoneItem::TimezoneItem(const QByteArray& id, QObject *parent)
- :QObject(parent)
-{
- QTimeZone tz = QTimeZone(id);
- m_name = tz.displayName(QTimeZone::StandardTime);
- m_country = QLocale::countryToString(tz.country());
- m_id = QString::fromUtf8(id);
-}
-
-/*!
- Returns the localized display name of the time zone.
-
- \sa QTimeZone::displayName()
-*/
-QString TimezoneItem::name() const
-{
- return m_name;
-}
-
-/*!
- Returns the name of the country for the time zone.
-
- \sa QTimeZone::country()
-*/
-QString TimezoneItem::country() const
-{
- return m_country;
-}
-
-/*!
- Returns the IANA time zone ID.
-
- \sa QTimeZone::id(), {IANA Time Zone IDs}
-*/
-QString TimezoneItem::id() const
-{
- return m_id;
-}
-
-/*!
- \class TimezoneModel
- \inmodule QtTimeDateSettings
- \inheaderfile timezonemodel.h
- \brief The TimezoneModel class provides a model for the available time
- zones.
-
- This class can be used as the model in a view that lists the available time
- zones.
-*/
-
-/*!
- \enum TimezoneModel::Roles
-
- This enum type holds information about a time zone.
-
- \value Name
- Localized display name of the time zone
- \value Country
- Name of the country for the time zone
- \value Id
- IANA time zone ID
-*/
-
-/*!
- \fn QList<TimezoneItem *> TimezoneModel::getModel() const
-
- Returns the time zone model for a time zone item.
-*/
-
-/*!
- \fn TimezoneModel::ready()
-
- This signal is emitted when the model is ready.
-*/
-
-/*!
- Creates a new time zone model with the parent \a parent.
-*/
-TimezoneModel::TimezoneModel(QObject *parent)
- : QAbstractListModel(parent)
-{
- m_roleNames.insert(Qt::UserRole, "modelData");
- m_roleNames.insert(Country, "country");
- m_roleNames.insert(Name, "name");
- m_roleNames.insert(Id, "id");
-
-
- QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this);
- QFuture<void> future = QtConcurrent::run(TimezoneModel::generateModel, this);
- watcher->setFuture(future);
- connect(watcher, SIGNAL(finished()), this, SIGNAL(ready()));
-}
-
-/*!
- Creates the time zone model \a model.
-*/
-void TimezoneModel::generateModel(TimezoneModel* model)
-{
- QList<QByteArray> ids = QTimeZone::availableTimeZoneIds();
- foreach (QByteArray id, ids) {
- TimezoneItem *zone = new TimezoneItem(id);
- zone->moveToThread(model->thread());
- QMetaObject::invokeMethod(model, "addNewItem", Q_ARG( QObject*, qobject_cast<QObject*>(zone)));
- }
-}
-
-/*!
- Adds the time zone item \a item to the time zone model.
-*/
-void TimezoneModel::addNewItem(QObject* item)
-{
- beginInsertRows(QModelIndex(), m_items.count(), m_items.count());
- TimezoneItem* newItem = qobject_cast<TimezoneItem*>(item);
- if (newItem)
- m_items.append(newItem);
- endInsertRows();
-}
-
-/*!
- Deletes the time zone model.
-*/
-TimezoneModel::~TimezoneModel()
-{
- qDeleteAll(m_items);
-}
-
-/*!
- Returns an array of the names of the roles in the model.
-*/
-QHash<int, QByteArray> TimezoneModel::roleNames() const
-{
- return m_roleNames;
-}
-
-/*!
- Returns the number of rows in the model with the parent \a parent.
-*/
-int TimezoneModel::rowCount(const QModelIndex & parent) const
-{
- Q_UNUSED(parent);
- return m_items.count();
-}
-
-/*!
- Returns the data at the index \a index in the model for the type of data
- specified by \a role.
-*/
-QVariant TimezoneModel::data(const QModelIndex & index, int role) const
-{
- if (!index.isValid()) return QVariant();
-
- TimezoneItem *item = m_items[index.row()];
-
- switch (role) {
- case Qt::UserRole:
- return QVariant::fromValue(static_cast<QObject*>(item));
- break;
- case Name:
- return item->id();
- break;
- case Country:
- return item->country();
- break;
- case Id:
- return item->id();
- break;
- case Qt::DisplayRole:
- return item->id();
- break;
- default:
- return QVariant();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/timedatesettings/timezonemodel.h b/src/timedatesettings/timezonemodel.h
deleted file mode 100644
index 6684472..0000000
--- a/src/timedatesettings/timezonemodel.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Device Utilities module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TIMEZONEMODEL_H
-#define TIMEZONEMODEL_H
-
-#include <QObject>
-#include <QAbstractListModel>
-#include <QTimeZone>
-#include <QMutex>
-
-QT_BEGIN_NAMESPACE
-
-class TimezoneItem : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString id READ id CONSTANT)
- Q_PROPERTY(QString name READ name CONSTANT)
- Q_PROPERTY(QString country READ country CONSTANT)
-public:
- explicit TimezoneItem(const QByteArray& id, QObject *parent = Q_NULLPTR);
- QString name() const;
- QString country() const;
- QString id() const;
-
-private:
- QString m_name;
- QString m_country;
- QString m_id;
-};
-
-class Q_DECL_EXPORT TimezoneModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- explicit TimezoneModel(QObject *parent = Q_NULLPTR);
- virtual ~TimezoneModel();
- // from QAbstractItemModel
- int rowCount(const QModelIndex & parent = QModelIndex()) const;
- QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
- QHash<int, QByteArray> roleNames() const;
- QList<TimezoneItem *> getModel() const
- {
- return m_items;
- }
-
- enum Roles {
- Name = Qt::UserRole + 1,
- Country,
- Id
- };
-
- static void generateModel(TimezoneModel* model);
-
-Q_SIGNALS:
- void ready();
-
-private Q_SLOTS:
- void addNewItem(QObject* item);
-
-private:
- QList<TimezoneItem*> m_items;
- QHash<int, QByteArray> m_roleNames;
-};
-
-QT_END_NAMESPACE
-
-#endif // TIMEZONEMODEL_H