diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-09-07 16:18:52 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-09-08 11:39:57 +0000 |
commit | 6eca2e4238ba40db3f6156e6c4ee6435f4d5128e (patch) | |
tree | 4ede6f278284d30954fd00f1d1b0ac7417d10e0b /src/calendar | |
parent | 58605b099b2ea6c9927877e93502fcde89c95a1c (diff) |
Calendar: merge C++ lib to the QML plugin
Change-Id: I7eeb0335fd88002c85f93136fc71dfb394788421
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/calendar')
-rw-r--r-- | src/calendar/calendar.pri | 19 | ||||
-rw-r--r-- | src/calendar/calendar.pro | 14 | ||||
-rw-r--r-- | src/calendar/qquickcalendarmodel.cpp | 195 | ||||
-rw-r--r-- | src/calendar/qquickcalendarmodel_p.h | 109 | ||||
-rw-r--r-- | src/calendar/qquickcalendarview.cpp | 310 | ||||
-rw-r--r-- | src/calendar/qquickcalendarview_p.h | 124 | ||||
-rw-r--r-- | src/calendar/qquickdayofweekmodel.cpp | 123 | ||||
-rw-r--r-- | src/calendar/qquickdayofweekmodel_p.h | 96 | ||||
-rw-r--r-- | src/calendar/qquickdayofweekrow.cpp | 143 | ||||
-rw-r--r-- | src/calendar/qquickdayofweekrow_p.h | 97 | ||||
-rw-r--r-- | src/calendar/qquickmonthmodel.cpp | 226 | ||||
-rw-r--r-- | src/calendar/qquickmonthmodel_p.h | 115 | ||||
-rw-r--r-- | src/calendar/qquickweeknumbercolumn.cpp | 169 | ||||
-rw-r--r-- | src/calendar/qquickweeknumbercolumn_p.h | 107 | ||||
-rw-r--r-- | src/calendar/qquickweeknumbermodel.cpp | 182 | ||||
-rw-r--r-- | src/calendar/qquickweeknumbermodel_p.h | 104 | ||||
-rw-r--r-- | src/calendar/qtquickcalendarglobal_p.h | 67 |
17 files changed, 0 insertions, 2200 deletions
diff --git a/src/calendar/calendar.pri b/src/calendar/calendar.pri deleted file mode 100644 index 1e1f4107..00000000 --- a/src/calendar/calendar.pri +++ /dev/null @@ -1,19 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qquickcalendarmodel_p.h \ - $$PWD/qquickcalendarview_p.h \ - $$PWD/qquickdayofweekmodel_p.h \ - $$PWD/qquickdayofweekrow_p.h \ - $$PWD/qquickmonthmodel_p.h \ - $$PWD/qquickweeknumbercolumn_p.h \ - $$PWD/qquickweeknumbermodel_p.h - -SOURCES += \ - $$PWD/qquickcalendarmodel.cpp \ - $$PWD/qquickcalendarview.cpp \ - $$PWD/qquickdayofweekmodel.cpp \ - $$PWD/qquickdayofweekrow.cpp \ - $$PWD/qquickmonthmodel.cpp \ - $$PWD/qquickweeknumbercolumn.cpp \ - $$PWD/qquickweeknumbermodel.cpp diff --git a/src/calendar/calendar.pro b/src/calendar/calendar.pro deleted file mode 100644 index b357b504..00000000 --- a/src/calendar/calendar.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = QtQuickCalendar -MODULE = quickcalendar2 -CONFIG += internal_module - -QT += quick -QT += core-private gui-private qml-private quick-private quickcontrols2-private - -DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII - -HEADERS += \ - $$PWD/qtquickcalendarglobal_p.h - -include(calendar.pri) -load(qt_module) diff --git a/src/calendar/qquickcalendarmodel.cpp b/src/calendar/qquickcalendarmodel.cpp deleted file mode 100644 index c1386ed0..00000000 --- a/src/calendar/qquickcalendarmodel.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickcalendarmodel_p.h" - -#include <QtCore/private/qabstractitemmodel_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickCalendarModelPrivate : public QAbstractItemModelPrivate -{ - Q_DECLARE_PUBLIC(QQuickCalendarModel) - -public: - QQuickCalendarModelPrivate() : complete(false), - from(1,1,1), to(275759, 9, 25), count(0) - { - } - - static int getCount(const QDate& from, const QDate &to); - - void populate(const QDate &from, const QDate &to, bool force = false); - - bool complete; - QDate from; - QDate to; - int count; -}; - -int QQuickCalendarModelPrivate::getCount(const QDate& from, const QDate &to) -{ - QDate f(from.year(), from.month(), 1); - QDate t(to.year(), to.month(), to.daysInMonth()); - QDate r = QDate(1, 1, 1).addDays(f.daysTo(t)); - int years = r.year() - 1; - int months = r.month() - 1; - return 12 * years + months + (r.day() / t.day()); -} - -void QQuickCalendarModelPrivate::populate(const QDate &f, const QDate &t, bool force) -{ - Q_Q(QQuickCalendarModel); - if (!force && f == from && t == to) - return; - - int c = getCount(from, to); - if (c != count) { - q->beginResetModel(); - count = c; - q->endResetModel(); - emit q->countChanged(); - } else { - emit q->dataChanged(q->index(0, 0), q->index(c - 1, 0)); - } -} - -QQuickCalendarModel::QQuickCalendarModel(QObject *parent) : - QAbstractListModel(*(new QQuickCalendarModelPrivate), parent) -{ -} - -QDate QQuickCalendarModel::from() const -{ - Q_D(const QQuickCalendarModel); - return d->from; -} - -void QQuickCalendarModel::setFrom(const QDate &from) -{ - Q_D(QQuickCalendarModel); - if (d->from != from) { - if (d->complete) - d->populate(from, d->to); - d->from = from; - emit fromChanged(); - } -} - -QDate QQuickCalendarModel::to() const -{ - Q_D(const QQuickCalendarModel); - return d->to; -} - -void QQuickCalendarModel::setTo(const QDate &to) -{ - Q_D(QQuickCalendarModel); - if (d->to != to) { - if (d->complete) - d->populate(d->from, to); - d->to = to; - emit fromChanged(); - } -} - -int QQuickCalendarModel::monthAt(int index) const -{ - Q_D(const QQuickCalendarModel); - return d->from.addMonths(index).month(); -} - -int QQuickCalendarModel::yearAt(int index) const -{ - Q_D(const QQuickCalendarModel); - return d->from.addMonths(index).year(); -} - -int QQuickCalendarModel::indexOf(const QDate &date) const -{ - return indexOf(date.year(), date.month()); -} - -int QQuickCalendarModel::indexOf(int year, int month) const -{ - Q_D(const QQuickCalendarModel); - return d->getCount(d->from, QDate(year, month, 1)) - 1; -} - -QVariant QQuickCalendarModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QQuickCalendarModel); - if (index.isValid() && index.row() < d->count) { - switch (role) { - case MonthRole: - return monthAt(index.row()); - case YearRole: - return yearAt(index.row()); - default: - break; - } - } - return QVariant(); -} - -int QQuickCalendarModel::rowCount(const QModelIndex &parent) const -{ - Q_D(const QQuickCalendarModel); - if (!parent.isValid()) - return d->count; - return 0; -} - -QHash<int, QByteArray> QQuickCalendarModel::roleNames() const -{ - QHash<int, QByteArray> roles; - roles[MonthRole] = QByteArrayLiteral("month"); - roles[YearRole] = QByteArrayLiteral("year"); - return roles; -} - -void QQuickCalendarModel::classBegin() -{ -} - -void QQuickCalendarModel::componentComplete() -{ - Q_D(QQuickCalendarModel); - d->complete = true; - d->populate(d->from, d->to, true); -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickcalendarmodel_p.h b/src/calendar/qquickcalendarmodel_p.h deleted file mode 100644 index 429026ee..00000000 --- a/src/calendar/qquickcalendarmodel_p.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKCALENDARMODEL_P_H -#define QQUICKCALENDARMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qabstractitemmodel.h> -#include <QtCore/qdatetime.h> -#include <QtQml/qqmlparserstatus.h> -#include <QtQuickCalendar/private/qtquickcalendarglobal_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickCalendarModelPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickCalendarModel : public QAbstractListModel, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QDate from READ from WRITE setFrom NOTIFY fromChanged FINAL) - Q_PROPERTY(QDate to READ to WRITE setTo NOTIFY toChanged FINAL) - Q_PROPERTY(int count READ rowCount NOTIFY countChanged) - -public: - explicit QQuickCalendarModel(QObject *parent = Q_NULLPTR); - - QDate from() const; - void setFrom(const QDate &from); - - QDate to() const; - void setTo(const QDate &to); - - Q_INVOKABLE int monthAt(int index) const; - Q_INVOKABLE int yearAt(int index) const; - Q_INVOKABLE int indexOf(const QDate &date) const; - Q_INVOKABLE int indexOf(int year, int month) const; - - enum { - MonthRole, - YearRole - }; - - QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - -Q_SIGNALS: - void fromChanged(); - void toChanged(); - void countChanged(); - -protected: - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickCalendarModel) - Q_DECLARE_PRIVATE(QQuickCalendarModel) -}; - -Q_DECLARE_TYPEINFO(QQuickCalendarModel, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKCALENDARMODEL_P_H diff --git a/src/calendar/qquickcalendarview.cpp b/src/calendar/qquickcalendarview.cpp deleted file mode 100644 index bdc67d43..00000000 --- a/src/calendar/qquickcalendarview.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickcalendarview_p.h" -#include "qquickmonthmodel_p.h" - -#include <QtGui/qstylehints.h> -#include <QtGui/qguiapplication.h> -#include <QtQuickControls/private/qquickcontrol_p_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickCalendarViewPrivate : public QQuickControlPrivate -{ - Q_DECLARE_PUBLIC(QQuickCalendarView) - -public: - QQuickCalendarViewPrivate() : pressTimer(0), pressedItem(Q_NULLPTR), model(Q_NULLPTR), delegate(Q_NULLPTR) { } - - void resizeItems(); - - QQuickItem *cellAt(const QPoint &pos) const; - QDate dateOf(QQuickItem *cell) const; - - void updatePress(const QPoint &pos); - void clearPress(bool clicked); - - static void setContextProperty(QQuickItem *item, const QString &name, const QVariant &value); - - QString title; - QVariant source; - QDate pressedDate; - int pressTimer; - QQuickItem *pressedItem; - QQuickMonthModel *model; - QQmlComponent *delegate; -}; - -void QQuickCalendarViewPrivate::resizeItems() -{ - if (!contentItem) - return; - - QSizeF itemSize; - itemSize.setWidth((contentItem->width() - 6 * spacing) / 7); - itemSize.setHeight((contentItem->height() - 5 * spacing) / 6); - - foreach (QQuickItem *item, contentItem->childItems()) - item->setSize(itemSize); -} - -QQuickItem *QQuickCalendarViewPrivate::cellAt(const QPoint &pos) const -{ - Q_Q(const QQuickCalendarView); - if (contentItem) { - QPointF mapped = q->mapToItem(contentItem, pos); - return contentItem->childAt(mapped.x(), mapped.y()); - } - return Q_NULLPTR; -} - -QDate QQuickCalendarViewPrivate::dateOf(QQuickItem *cell) const -{ - if (contentItem) - return model->dateAt(contentItem->childItems().indexOf(cell)); - return QDate(); -} - -void QQuickCalendarViewPrivate::updatePress(const QPoint &pos) -{ - Q_Q(QQuickCalendarView); - clearPress(false); - pressedItem = cellAt(pos); - setContextProperty(pressedItem, QStringLiteral("pressed"), true); - pressedDate = dateOf(pressedItem); - if (pressedDate.isValid()) - emit q->pressed(pressedDate); -} - -void QQuickCalendarViewPrivate::clearPress(bool clicked) -{ - Q_Q(QQuickCalendarView); - setContextProperty(pressedItem, QStringLiteral("pressed"), false); - if (pressedDate.isValid()) { - emit q->released(pressedDate); - if (clicked) - emit q->clicked(pressedDate); - } - pressedDate = QDate(); - pressedItem = Q_NULLPTR; -} - -void QQuickCalendarViewPrivate::setContextProperty(QQuickItem *item, const QString &name, const QVariant &value) -{ - QQmlContext *context = qmlContext(item); - if (context && context->isValid()) { - context = context->parentContext(); - if (context && context->isValid()) - context->setContextProperty(name, value); - } -} - -QQuickCalendarView::QQuickCalendarView(QQuickItem *parent) : - QQuickControl(*(new QQuickCalendarViewPrivate), parent) -{ - Q_D(QQuickCalendarView); - setFlag(ItemIsFocusScope); - setActiveFocusOnTab(true); - setAcceptedMouseButtons(Qt::LeftButton); - - d->model = new QQuickMonthModel(this); - d->source = QVariant::fromValue(d->model); - connect(d->model, &QQuickMonthModel::monthChanged, this, &QQuickCalendarView::monthChanged); - connect(d->model, &QQuickMonthModel::yearChanged, this, &QQuickCalendarView::yearChanged); - connect(d->model, &QQuickMonthModel::localeChanged, this, &QQuickCalendarView::localeChanged); - connect(d->model, &QQuickMonthModel::titleChanged, this, &QQuickCalendarView::titleChanged); -} - -int QQuickCalendarView::month() const -{ - Q_D(const QQuickCalendarView); - return d->model->month(); -} - -void QQuickCalendarView::setMonth(int month) -{ - Q_D(QQuickCalendarView); - d->model->setMonth(month); -} - -int QQuickCalendarView::year() const -{ - Q_D(const QQuickCalendarView); - return d->model->year(); -} - -void QQuickCalendarView::setYear(int year) -{ - Q_D(QQuickCalendarView); - d->model->setYear(year); -} - -QLocale QQuickCalendarView::locale() const -{ - Q_D(const QQuickCalendarView); - return d->model->locale(); -} - -void QQuickCalendarView::setLocale(const QLocale &locale) -{ - Q_D(QQuickCalendarView); - d->model->setLocale(locale); -} - -QVariant QQuickCalendarView::source() const -{ - Q_D(const QQuickCalendarView); - return d->source; -} - -void QQuickCalendarView::setSource(const QVariant &source) -{ - Q_D(QQuickCalendarView); - if (d->source != source) { - d->source = source; - emit sourceChanged(); - } -} - -QString QQuickCalendarView::title() const -{ - Q_D(const QQuickCalendarView); - if (d->title.isNull()) - return d->model->title(); - return d->title; -} - -void QQuickCalendarView::setTitle(const QString &title) -{ - Q_D(QQuickCalendarView); - if (d->title != title) { - d->title = title; - emit titleChanged(); - } -} - -QQmlComponent *QQuickCalendarView::delegate() const -{ - Q_D(const QQuickCalendarView); - return d->delegate; -} - -void QQuickCalendarView::setDelegate(QQmlComponent *delegate) -{ - Q_D(QQuickCalendarView); - if (d->delegate != delegate) { - d->delegate = delegate; - emit delegateChanged(); - } -} - -void QQuickCalendarView::componentComplete() -{ - Q_D(QQuickCalendarView); - QQuickControl::componentComplete(); - if (d->contentItem) { - foreach (QQuickItem *child, d->contentItem->childItems()) { - if (!QQuickItemPrivate::get(child)->isTransparentForPositioner()) - d->setContextProperty(child, QStringLiteral("pressed"), false); - } - } - d->resizeItems(); -} - -void QQuickCalendarView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QQuickCalendarView); - QQuickControl::geometryChanged(newGeometry, oldGeometry); - if (isComponentComplete()) - d->resizeItems(); -} - -void QQuickCalendarView::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) -{ - Q_D(QQuickCalendarView); - QQuickControl::paddingChange(newPadding, oldPadding); - if (isComponentComplete()) - d->resizeItems(); -} - -void QQuickCalendarView::updatePolish() -{ - Q_D(QQuickCalendarView); - QQuickControl::updatePolish(); - d->resizeItems(); -} - -void QQuickCalendarView::mousePressEvent(QMouseEvent *event) -{ - Q_D(QQuickCalendarView); - d->updatePress(event->pos()); - if (d->pressedDate.isValid()) - d->pressTimer = startTimer(qGuiApp->styleHints()->mousePressAndHoldInterval()); - event->accept(); -} - -void QQuickCalendarView::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickCalendarView); - d->updatePress(event->pos()); - event->accept(); -} - -void QQuickCalendarView::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QQuickCalendarView); - d->clearPress(true); - event->accept(); -} - -void QQuickCalendarView::mouseUngrabEvent() -{ - Q_D(QQuickCalendarView); - d->clearPress(false); -} - -void QQuickCalendarView::timerEvent(QTimerEvent *event) -{ - Q_D(QQuickCalendarView); - if (event->timerId() == d->pressTimer) { - if (d->pressedDate.isValid()) - emit pressAndHold(d->pressedDate); - killTimer(d->pressTimer); - } -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickcalendarview_p.h b/src/calendar/qquickcalendarview_p.h deleted file mode 100644 index b116738b..00000000 --- a/src/calendar/qquickcalendarview_p.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKCALENDARVIEW_P_H -#define QQUICKCALENDARVIEW_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickCalendar/private/qtquickcalendarglobal_p.h> -#include <QtQuickControls/private/qquickcontrol_p.h> - -QT_BEGIN_NAMESPACE - -class QQmlComponent; -class QQuickCalendarViewPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickCalendarView : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) - Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) - Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) - -public: - explicit QQuickCalendarView(QQuickItem *parent = Q_NULLPTR); - - int month() const; - void setMonth(int month); - - int year() const; - void setYear(int year); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - QVariant source() const; - void setSource(const QVariant &source); - - QString title() const; - void setTitle(const QString &title); - - QQmlComponent *delegate() const; - void setDelegate(QQmlComponent *delegate); - -Q_SIGNALS: - void monthChanged(); - void yearChanged(); - void localeChanged(); - void sourceChanged(); - void titleChanged(); - void delegateChanged(); - - void pressed(const QDate &date); - void released(const QDate &date); - void clicked(const QDate &date); - void pressAndHold(const QDate &date); - -protected: - void componentComplete() Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE; - void updatePolish() Q_DECL_OVERRIDE; - - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickCalendarView) - Q_DECLARE_PRIVATE(QQuickCalendarView) -}; - -Q_DECLARE_TYPEINFO(QQuickCalendarView, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKCALENDARVIEW_P_H diff --git a/src/calendar/qquickdayofweekmodel.cpp b/src/calendar/qquickdayofweekmodel.cpp deleted file mode 100644 index 7f75f784..00000000 --- a/src/calendar/qquickdayofweekmodel.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickdayofweekmodel_p.h" - -#include <QtCore/private/qabstractitemmodel_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickDayOfWeekModelPrivate : public QAbstractItemModelPrivate -{ - Q_DECLARE_PUBLIC(QQuickDayOfWeekModel) - -public: - QLocale locale; -}; - -QQuickDayOfWeekModel::QQuickDayOfWeekModel(QObject *parent) : - QAbstractListModel(*(new QQuickDayOfWeekModelPrivate), parent) -{ -} - -QLocale QQuickDayOfWeekModel::locale() const -{ - Q_D(const QQuickDayOfWeekModel); - return d->locale; -} - -void QQuickDayOfWeekModel::setLocale(const QLocale &locale) -{ - Q_D(QQuickDayOfWeekModel); - if (d->locale != locale) { - bool changed = d->locale.firstDayOfWeek() != locale.firstDayOfWeek(); - d->locale = locale; - emit localeChanged(); - if (changed) - emit dataChanged(index(0, 0), index(6, 0)); - } -} - -int QQuickDayOfWeekModel::dayAt(int index) const -{ - Q_D(const QQuickDayOfWeekModel); - int day = d->locale.firstDayOfWeek() + index; - if (day > 7) - day -= 7; - if (day == 7) - day = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date - return day; -} - -QVariant QQuickDayOfWeekModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QQuickDayOfWeekModel); - if (index.isValid() && index.row() < 7) { - int day = dayAt(index.row()); - switch (role) { - case DayRole: - return day; - case LongNameRole: - return d->locale.standaloneDayName(day == 0 ? Qt::Sunday : day, QLocale::LongFormat); - case ShortNameRole: - return d->locale.standaloneDayName(day == 0 ? Qt::Sunday : day, QLocale::ShortFormat); - case NarrowNameRole: - return d->locale.standaloneDayName(day == 0 ? Qt::Sunday : day, QLocale::NarrowFormat); - default: - break; - } - } - return QVariant(); -} - -int QQuickDayOfWeekModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - return 7; -} - -QHash<int, QByteArray> QQuickDayOfWeekModel::roleNames() const -{ - QHash<int, QByteArray> roles; - roles[DayRole] = QByteArrayLiteral("day"); - roles[LongNameRole] = QByteArrayLiteral("longName"); - roles[ShortNameRole] = QByteArrayLiteral("shortName"); - roles[NarrowNameRole] = QByteArrayLiteral("narrowName"); - return roles; -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickdayofweekmodel_p.h b/src/calendar/qquickdayofweekmodel_p.h deleted file mode 100644 index d5aaeffe..00000000 --- a/src/calendar/qquickdayofweekmodel_p.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKDAYOFWEEKMODEL_P_H -#define QQUICKDAYOFWEEKMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qabstractitemmodel.h> -#include <QtCore/qlocale.h> -#include <QtQuickCalendar/private/qtquickcalendarglobal_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickDayOfWeekModelPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickDayOfWeekModel : public QAbstractListModel -{ - Q_OBJECT - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(int count READ rowCount CONSTANT FINAL) - -public: - explicit QQuickDayOfWeekModel(QObject *parent = Q_NULLPTR); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - Q_INVOKABLE int dayAt(int index) const; - - enum { - DayRole = Qt::UserRole + 1, - LongNameRole, - ShortNameRole, - NarrowNameRole - }; - - QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - -Q_SIGNALS: - void localeChanged(); - -private: - Q_DISABLE_COPY(QQuickDayOfWeekModel) - Q_DECLARE_PRIVATE(QQuickDayOfWeekModel) -}; - -Q_DECLARE_TYPEINFO(QQuickDayOfWeekModel, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKDAYOFWEEKMODEL_P_H diff --git a/src/calendar/qquickdayofweekrow.cpp b/src/calendar/qquickdayofweekrow.cpp deleted file mode 100644 index e4b42302..00000000 --- a/src/calendar/qquickdayofweekrow.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickdayofweekrow_p.h" -#include "qquickdayofweekmodel_p.h" - -#include <QtQuickControls/private/qquickcontrol_p_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickDayOfWeekRowPrivate : public QQuickControlPrivate -{ -public: - QQuickDayOfWeekRowPrivate() : delegate(Q_NULLPTR), model(Q_NULLPTR) { } - - void resizeItems(); - - QVariant source; - QQmlComponent *delegate; - QQuickDayOfWeekModel *model; -}; - -void QQuickDayOfWeekRowPrivate::resizeItems() -{ - if (!contentItem) - return; - - QSizeF itemSize; - itemSize.setWidth((contentItem->width() - 6 * spacing) / 7); - itemSize.setHeight(contentItem->height()); - - foreach (QQuickItem *item, contentItem->childItems()) - item->setSize(itemSize); -} - -QQuickDayOfWeekRow::QQuickDayOfWeekRow(QQuickItem *parent) : - QQuickControl(*(new QQuickDayOfWeekRowPrivate), parent) -{ - Q_D(QQuickDayOfWeekRow); - d->model = new QQuickDayOfWeekModel(this); - d->source = QVariant::fromValue(d->model); - connect(d->model, &QQuickDayOfWeekModel::localeChanged, this, &QQuickDayOfWeekRow::localeChanged); -} - -QLocale QQuickDayOfWeekRow::locale() const -{ - Q_D(const QQuickDayOfWeekRow); - return d->model->locale(); -} - -void QQuickDayOfWeekRow::setLocale(const QLocale &locale) -{ - Q_D(QQuickDayOfWeekRow); - d->model->setLocale(locale); -} - -QVariant QQuickDayOfWeekRow::source() const -{ - Q_D(const QQuickDayOfWeekRow); - return d->source; -} - -void QQuickDayOfWeekRow::setSource(const QVariant &source) -{ - Q_D(QQuickDayOfWeekRow); - if (d->source != source) { - d->source = source; - emit sourceChanged(); - } -} - -QQmlComponent *QQuickDayOfWeekRow::delegate() const -{ - Q_D(const QQuickDayOfWeekRow); - return d->delegate; -} - -void QQuickDayOfWeekRow::setDelegate(QQmlComponent *delegate) -{ - Q_D(QQuickDayOfWeekRow); - if (d->delegate != delegate) { - d->delegate = delegate; - emit delegateChanged(); - } -} - -void QQuickDayOfWeekRow::componentComplete() -{ - Q_D(QQuickDayOfWeekRow); - QQuickControl::componentComplete(); - d->resizeItems(); -} - -void QQuickDayOfWeekRow::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QQuickDayOfWeekRow); - QQuickControl::geometryChanged(newGeometry, oldGeometry); - if (isComponentComplete()) - d->resizeItems(); -} - -void QQuickDayOfWeekRow::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) -{ - Q_D(QQuickDayOfWeekRow); - QQuickControl::paddingChange(newPadding, oldPadding); - if (isComponentComplete()) - d->resizeItems(); -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickdayofweekrow_p.h b/src/calendar/qquickdayofweekrow_p.h deleted file mode 100644 index a364fc70..00000000 --- a/src/calendar/qquickdayofweekrow_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKDAYOFWEEKROW_P_H -#define QQUICKDAYOFWEEKROW_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickCalendar/private/qtquickcalendarglobal_p.h> -#include <QtQuickControls/private/qquickcontrol_p.h> - -QT_BEGIN_NAMESPACE - -class QQmlComponent; -class QQuickDayOfWeekRowPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickDayOfWeekRow : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) - Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) - -public: - explicit QQuickDayOfWeekRow(QQuickItem *parent = Q_NULLPTR); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - QVariant source() const; - void setSource(const QVariant &source); - - QQmlComponent *delegate() const; - void setDelegate(QQmlComponent *delegate); - -Q_SIGNALS: - void localeChanged(); - void sourceChanged(); - void delegateChanged(); - -protected: - void componentComplete() Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickDayOfWeekRow) - Q_DECLARE_PRIVATE(QQuickDayOfWeekRow) -}; - -Q_DECLARE_TYPEINFO(QQuickDayOfWeekRow, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKDAYOFWEEKROW_P_H diff --git a/src/calendar/qquickmonthmodel.cpp b/src/calendar/qquickmonthmodel.cpp deleted file mode 100644 index 064712ca..00000000 --- a/src/calendar/qquickmonthmodel.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickmonthmodel_p.h" - -#include <QtCore/private/qabstractitemmodel_p.h> - -namespace { - static const int daysInAWeek = 7; - static const int weeksOnACalendarMonth = 6; - static const int daysOnACalendarMonth = daysInAWeek * weeksOnACalendarMonth; -} - -QT_BEGIN_NAMESPACE - -class QQuickMonthModelPrivate : public QAbstractItemModelPrivate -{ - Q_DECLARE_PUBLIC(QQuickMonthModel) - -public: - QQuickMonthModelPrivate() : dates(daysOnACalendarMonth) - { - today = QDate::currentDate(); - month = today.month(); - year = today.year(); - } - - bool populate(int month, int year, const QLocale &locale, bool force = false); - - int month; - int year; - QString title; - QLocale locale; - QVector<QDate> dates; - QDate today; -}; - -bool QQuickMonthModelPrivate::populate(int m, int y, const QLocale &l, bool force) -{ - Q_Q(QQuickMonthModel); - if (!force && m == month && y == year && l.firstDayOfWeek() == locale.firstDayOfWeek()) - return false; - - // The actual first (1st) day of the month. - QDate firstDayOfMonthDate(y, m, 1); - int difference = ((firstDayOfMonthDate.dayOfWeek() - l.firstDayOfWeek()) + 7) % 7; - // The first day to display should never be the 1st of the month, as we want some days from - // the previous month to be visible. - if (difference == 0) - difference += 7; - QDate firstDateToDisplay = firstDayOfMonthDate.addDays(-difference); - - today = QDate::currentDate(); - for (int i = 0; i < daysOnACalendarMonth; ++i) - dates[i] = firstDateToDisplay.addDays(i); - - q->setTitle(l.standaloneMonthName(m) + QStringLiteral(" ") + QString::number(y)); - - return true; -} - -QQuickMonthModel::QQuickMonthModel(QObject *parent) : - QAbstractListModel(*(new QQuickMonthModelPrivate), parent) -{ - Q_D(QQuickMonthModel); - d->populate(d->month, d->year, d->locale, true); -} - -int QQuickMonthModel::month() const -{ - Q_D(const QQuickMonthModel); - return d->month; -} - -void QQuickMonthModel::setMonth(int month) -{ - Q_D(QQuickMonthModel); - if (d->month != month) { - if (d->populate(month, d->year, d->locale)) - emit dataChanged(index(0, 0), index(daysOnACalendarMonth - 1, 0)); - d->month = month; - emit monthChanged(); - } -} - -int QQuickMonthModel::year() const -{ - Q_D(const QQuickMonthModel); - return d->year; -} - -void QQuickMonthModel::setYear(int year) -{ - Q_D(QQuickMonthModel); - if (d->year != year) { - if (d->populate(d->month, year, d->locale)) - emit dataChanged(index(0, 0), index(daysOnACalendarMonth - 1, 0)); - d->year = year; - emit yearChanged(); - } -} - -QLocale QQuickMonthModel::locale() const -{ - Q_D(const QQuickMonthModel); - return d->locale; -} - -void QQuickMonthModel::setLocale(const QLocale &locale) -{ - Q_D(QQuickMonthModel); - if (d->locale != locale) { - if (d->populate(d->month, d->year, locale)) - emit dataChanged(index(0, 0), index(daysOnACalendarMonth - 1, 0)); - d->locale = locale; - emit localeChanged(); - } -} - -QString QQuickMonthModel::title() const -{ - Q_D(const QQuickMonthModel); - return d->title; -} - -void QQuickMonthModel::setTitle(const QString &title) -{ - Q_D(QQuickMonthModel); - if (d->title != title) { - d->title = title; - emit titleChanged(); - } -} - -QDate QQuickMonthModel::dateAt(int index) const -{ - Q_D(const QQuickMonthModel); - return d->dates.value(index); -} - -int QQuickMonthModel::indexOf(const QDate &date) const -{ - Q_D(const QQuickMonthModel); - if (date < d->dates.first() || date > d->dates.last()) - return -1; - return qMax(qint64(0), d->dates.first().daysTo(date)); -} - -QVariant QQuickMonthModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QQuickMonthModel); - if (index.isValid() && index.row() < daysOnACalendarMonth) { - const QDate date = d->dates.at(index.row()); - switch (role) { - case DateRole: - return date; - case DayRole: - return date.day(); - case TodayRole: - return date == d->today; - case WeekNumberRole: - return date.weekNumber(); - case MonthRole: - return date.month(); - case YearRole: - return date.year(); - default: - break; - } - } - return QVariant(); -} - -int QQuickMonthModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - return daysOnACalendarMonth; -} - -QHash<int, QByteArray> QQuickMonthModel::roleNames() const -{ - QHash<int, QByteArray> roles; - roles[DateRole] = QByteArrayLiteral("date"); - roles[DayRole] = QByteArrayLiteral("day"); - roles[TodayRole] = QByteArrayLiteral("today"); - roles[WeekNumberRole] = QByteArrayLiteral("weekNumber"); - roles[MonthRole] = QByteArrayLiteral("month"); - roles[YearRole] = QByteArrayLiteral("year"); - return roles; -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickmonthmodel_p.h b/src/calendar/qquickmonthmodel_p.h deleted file mode 100644 index 3cebac24..00000000 --- a/src/calendar/qquickmonthmodel_p.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKMONTHMODEL_P_H -#define QQUICKMONTHMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qabstractitemmodel.h> -#include <QtCore/qdatetime.h> -#include <QtCore/qlocale.h> -#include <QtQuickCalendar/private/qtquickcalendarglobal_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickMonthModelPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickMonthModel : public QAbstractListModel -{ - Q_OBJECT - Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) - Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) - Q_PROPERTY(int count READ rowCount CONSTANT FINAL) - -public: - explicit QQuickMonthModel(QObject *parent = Q_NULLPTR); - - int month() const; - void setMonth(int month); - - int year() const; - void setYear(int year); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - QString title() const; - void setTitle(const QString &title); - - Q_INVOKABLE QDate dateAt(int index) const; - Q_INVOKABLE int indexOf(const QDate &date) const; - - enum { - DateRole = Qt::UserRole + 1, - DayRole, - TodayRole, - WeekNumberRole, - MonthRole, - YearRole - }; - - QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - -Q_SIGNALS: - void monthChanged(); - void yearChanged(); - void localeChanged(); - void titleChanged(); - -private: - Q_DISABLE_COPY(QQuickMonthModel) - Q_DECLARE_PRIVATE(QQuickMonthModel) -}; - -Q_DECLARE_TYPEINFO(QQuickMonthModel, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKMONTHMODEL_P_H diff --git a/src/calendar/qquickweeknumbercolumn.cpp b/src/calendar/qquickweeknumbercolumn.cpp deleted file mode 100644 index 56c4af97..00000000 --- a/src/calendar/qquickweeknumbercolumn.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickweeknumbercolumn_p.h" -#include "qquickweeknumbermodel_p.h" - -#include <QtQuickControls/private/qquickcontrol_p_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickWeekNumberColumnPrivate : public QQuickControlPrivate -{ -public: - QQuickWeekNumberColumnPrivate() : delegate(Q_NULLPTR), model(Q_NULLPTR) { } - - void resizeItems(); - - QVariant source; - QQmlComponent *delegate; - QQuickWeekNumberModel *model; -}; - -void QQuickWeekNumberColumnPrivate::resizeItems() -{ - if (!contentItem) - return; - - QSizeF itemSize; - itemSize.setWidth(contentItem->width()); - itemSize.setHeight((contentItem->height() - 5 * spacing) / 6); - - foreach (QQuickItem *item, contentItem->childItems()) - item->setSize(itemSize); -} - -QQuickWeekNumberColumn::QQuickWeekNumberColumn(QQuickItem *parent) : - QQuickControl(*(new QQuickWeekNumberColumnPrivate), parent) -{ - Q_D(QQuickWeekNumberColumn); - d->model = new QQuickWeekNumberModel(this); - d->source = QVariant::fromValue(d->model); - connect(d->model, &QQuickWeekNumberModel::monthChanged, this, &QQuickWeekNumberColumn::monthChanged); - connect(d->model, &QQuickWeekNumberModel::yearChanged, this, &QQuickWeekNumberColumn::yearChanged); - connect(d->model, &QQuickWeekNumberModel::localeChanged, this, &QQuickWeekNumberColumn::localeChanged); -} - -int QQuickWeekNumberColumn::month() const -{ - Q_D(const QQuickWeekNumberColumn); - return d->model->month(); -} - -void QQuickWeekNumberColumn::setMonth(int month) -{ - Q_D(QQuickWeekNumberColumn); - d->model->setMonth(month); -} - -int QQuickWeekNumberColumn::year() const -{ - Q_D(const QQuickWeekNumberColumn); - return d->model->year(); -} - -void QQuickWeekNumberColumn::setYear(int year) -{ - Q_D(QQuickWeekNumberColumn); - d->model->setYear(year); -} - -QLocale QQuickWeekNumberColumn::locale() const -{ - Q_D(const QQuickWeekNumberColumn); - return d->model->locale(); -} - -void QQuickWeekNumberColumn::setLocale(const QLocale &locale) -{ - Q_D(QQuickWeekNumberColumn); - d->model->setLocale(locale); -} - -QVariant QQuickWeekNumberColumn::source() const -{ - Q_D(const QQuickWeekNumberColumn); - return d->source; -} - -void QQuickWeekNumberColumn::setSource(const QVariant &source) -{ - Q_D(QQuickWeekNumberColumn); - if (d->source != source) { - d->source = source; - emit sourceChanged(); - } -} - -QQmlComponent *QQuickWeekNumberColumn::delegate() const -{ - Q_D(const QQuickWeekNumberColumn); - return d->delegate; -} - -void QQuickWeekNumberColumn::setDelegate(QQmlComponent *delegate) -{ - Q_D(QQuickWeekNumberColumn); - if (d->delegate != delegate) { - d->delegate = delegate; - emit delegateChanged(); - } -} - -void QQuickWeekNumberColumn::componentComplete() -{ - Q_D(QQuickWeekNumberColumn); - QQuickControl::componentComplete(); - d->resizeItems(); -} - -void QQuickWeekNumberColumn::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QQuickWeekNumberColumn); - QQuickControl::geometryChanged(newGeometry, oldGeometry); - if (isComponentComplete()) - d->resizeItems(); -} - -void QQuickWeekNumberColumn::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) -{ - Q_D(QQuickWeekNumberColumn); - QQuickControl::paddingChange(newPadding, oldPadding); - if (isComponentComplete()) - d->resizeItems(); -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickweeknumbercolumn_p.h b/src/calendar/qquickweeknumbercolumn_p.h deleted file mode 100644 index 022fe5e2..00000000 --- a/src/calendar/qquickweeknumbercolumn_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKWEEKNUMBERCOLUMN_P_H -#define QQUICKWEEKNUMBERCOLUMN_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickCalendar/private/qtquickcalendarglobal_p.h> -#include <QtQuickControls/private/qquickcontrol_p.h> - -QT_BEGIN_NAMESPACE - -class QQmlComponent; -class QQuickWeekNumberColumnPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickWeekNumberColumn : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) - Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) - Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) - -public: - explicit QQuickWeekNumberColumn(QQuickItem *parent = Q_NULLPTR); - - int month() const; - void setMonth(int month); - - int year() const; - void setYear(int year); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - QVariant source() const; - void setSource(const QVariant &source); - - QQmlComponent *delegate() const; - void setDelegate(QQmlComponent *delegate); - -Q_SIGNALS: - void monthChanged(); - void yearChanged(); - void localeChanged(); - void sourceChanged(); - void delegateChanged(); - -protected: - void componentComplete() Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickWeekNumberColumn) - Q_DECLARE_PRIVATE(QQuickWeekNumberColumn) -}; - -Q_DECLARE_TYPEINFO(QQuickWeekNumberColumn, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKWEEKNUMBERCOLUMN_P_H diff --git a/src/calendar/qquickweeknumbermodel.cpp b/src/calendar/qquickweeknumbermodel.cpp deleted file mode 100644 index 34d66202..00000000 --- a/src/calendar/qquickweeknumbermodel.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickweeknumbermodel_p.h" - -#include <QtCore/private/qabstractitemmodel_p.h> -#include <QtCore/qdatetime.h> - -QT_BEGIN_NAMESPACE - -class QQuickWeekNumberModelPrivate : public QAbstractItemModelPrivate -{ - Q_DECLARE_PUBLIC(QQuickWeekNumberModel) - -public: - QQuickWeekNumberModelPrivate() - { - QDate date = QDate::currentDate(); - month = date.month(); - year = date.year(); - first = calculateFirst(month, year, locale); - } - - void init(int month, int year, const QLocale &locale = QLocale()); - static int calculateFirst(int month, int year, const QLocale &locale); - - int month; - int year; - int first; - QLocale locale; -}; - -void QQuickWeekNumberModelPrivate::init(int m, int y, const QLocale &l) -{ - Q_Q(QQuickWeekNumberModel); - if (m == month && y == year && l.firstDayOfWeek() == locale.firstDayOfWeek()) - return; - - first = calculateFirst(m, y, l); - - emit q->dataChanged(q->index(0, 0), q->index(5, 0)); -} - -int QQuickWeekNumberModelPrivate::calculateFirst(int month, int year, const QLocale &locale) -{ - // The actual first (1st) day of the month. - QDate firstDayOfMonthDate(year, month, 1); - int difference = ((firstDayOfMonthDate.dayOfWeek() - locale.firstDayOfWeek()) + 7) % 7; - // The first day to display should never be the 1st of the month, as we want some days from - // the previous month to be visible. - if (difference == 0) - difference += 7; - return firstDayOfMonthDate.addDays(-difference).weekNumber(); -} - -QQuickWeekNumberModel::QQuickWeekNumberModel(QObject *parent) : - QAbstractListModel(*(new QQuickWeekNumberModelPrivate), parent) -{ -} - -int QQuickWeekNumberModel::month() const -{ - Q_D(const QQuickWeekNumberModel); - return d->month; -} - -void QQuickWeekNumberModel::setMonth(int month) -{ - Q_D(QQuickWeekNumberModel); - if (d->month != month) { - d->init(month, d->year, d->locale); - d->month = month; - emit monthChanged(); - } -} - -int QQuickWeekNumberModel::year() const -{ - Q_D(const QQuickWeekNumberModel); - return d->year; -} - -void QQuickWeekNumberModel::setYear(int year) -{ - Q_D(QQuickWeekNumberModel); - if (d->year != year) { - d->init(d->month, year, d->locale); - d->year = year; - emit yearChanged(); - } -} - -QLocale QQuickWeekNumberModel::locale() const -{ - Q_D(const QQuickWeekNumberModel); - return d->locale; -} - -void QQuickWeekNumberModel::setLocale(const QLocale &locale) -{ - Q_D(QQuickWeekNumberModel); - if (d->locale != locale) { - d->init(d->month, d->year, locale); - d->locale = locale; - emit localeChanged(); - } -} - -int QQuickWeekNumberModel::weekNumberAt(int index) const -{ - Q_D(const QQuickWeekNumberModel); - if (index < 0 || index > 5) - return -1; - return d->first + index; -} - -int QQuickWeekNumberModel::indexOf(int weekNumber) const -{ - Q_D(const QQuickWeekNumberModel); - if (weekNumber < d->first || weekNumber > d->first + 6) - return -1; - return weekNumber - d->first; -} - -QVariant QQuickWeekNumberModel::data(const QModelIndex &index, int role) const -{ - if (role == WeekNumberRole) { - int weekNumber = weekNumberAt(index.row()); - if (weekNumber != -1) - return weekNumber; - } - return QVariant(); -} - -int QQuickWeekNumberModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - return 6; -} - -QHash<int, QByteArray> QQuickWeekNumberModel::roleNames() const -{ - QHash<int, QByteArray> roles; - roles[WeekNumberRole] = QByteArrayLiteral("weekNumber"); - return roles; -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickweeknumbermodel_p.h b/src/calendar/qquickweeknumbermodel_p.h deleted file mode 100644 index b32a7e0b..00000000 --- a/src/calendar/qquickweeknumbermodel_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKWEEKNUMBERMODEL_P_H -#define QQUICKWEEKNUMBERMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qabstractitemmodel.h> -#include <QtCore/qlocale.h> -#include <QtQuickCalendar/private/qtquickcalendarglobal_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickWeekNumberModelPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickWeekNumberModel : public QAbstractListModel -{ - Q_OBJECT - Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) - Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(int count READ rowCount CONSTANT FINAL) - -public: - explicit QQuickWeekNumberModel(QObject *parent = Q_NULLPTR); - - int month() const; - void setMonth(int month); - - int year() const; - void setYear(int year); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - Q_INVOKABLE int weekNumberAt(int index) const; - Q_INVOKABLE int indexOf(int weekNumber) const; - - enum { - WeekNumberRole = Qt::UserRole + 1 - }; - - QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - -Q_SIGNALS: - void monthChanged(); - void yearChanged(); - void localeChanged(); - -private: - Q_DISABLE_COPY(QQuickWeekNumberModel) - Q_DECLARE_PRIVATE(QQuickWeekNumberModel) -}; - -Q_DECLARE_TYPEINFO(QQuickWeekNumberModel, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKWEEKNUMBERMODEL_P_H diff --git a/src/calendar/qtquickcalendarglobal_p.h b/src/calendar/qtquickcalendarglobal_p.h deleted file mode 100644 index d5da61f1..00000000 --- a/src/calendar/qtquickcalendarglobal_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTQUICKCALENDARGLOBAL_P_H -#define QTQUICKCALENDARGLOBAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qglobal.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_QUICKCALENDAR2_LIB) -# define Q_QUICKCALENDAR_EXPORT Q_DECL_EXPORT -# else -# define Q_QUICKCALENDAR_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_QUICKCALENDAR_EXPORT -#endif - -QT_END_NAMESPACE - -#endif // QTQUICKCALENDARGLOBAL_P_H |