aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/calendar/qquickweeknumbercolumn.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-09-25 18:07:32 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-10-03 11:33:06 +0000
commit15693121bcb5214a30e823c59e9683fb8a536318 (patch)
tree60889ad41b2be181d75ecbe54563b617169da2fd /src/imports/calendar/qquickweeknumbercolumn.cpp
parent3ac0236c501eefcb832da5e68b604ca59eec8b5d (diff)
Calendar: validate month & year ranges
Fixes also all Calendar types to use 0-based month. Change-Id: Iee3cafc00e0338b8076fbb3fe195b8491752cbc1 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports/calendar/qquickweeknumbercolumn.cpp')
-rw-r--r--src/imports/calendar/qquickweeknumbercolumn.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/imports/calendar/qquickweeknumbercolumn.cpp b/src/imports/calendar/qquickweeknumbercolumn.cpp
index 21540607..34e4bd52 100644
--- a/src/imports/calendar/qquickweeknumbercolumn.cpp
+++ b/src/imports/calendar/qquickweeknumbercolumn.cpp
@@ -38,6 +38,7 @@
#include "qquickweeknumbermodel_p.h"
#include <QtLabsTemplates/private/qquickcontrol_p_p.h>
+#include <QtQml/qqmlinfo.h>
QT_BEGIN_NAMESPACE
@@ -108,23 +109,33 @@ QQuickWeekNumberColumn::QQuickWeekNumberColumn(QQuickItem *parent) :
\qmlproperty int Qt.labs.calendar::WeekNumberColumn::month
This property holds the number of the month that the week numbers are calculated for.
+
+ The value must be in the range from \c 0 (January) to \c 11 (December). The default
+ value is the current month.
*/
int QQuickWeekNumberColumn::month() const
{
Q_D(const QQuickWeekNumberColumn);
- return d->model->month();
+ return d->model->month() - 1;
}
void QQuickWeekNumberColumn::setMonth(int month)
{
Q_D(QQuickWeekNumberColumn);
- d->model->setMonth(month);
+ if (month < 0 || month > 11) {
+ qmlInfo(this) << "month " << month << " is out of range [0...11]";
+ return;
+ }
+ d->model->setMonth(month + 1);
}
/*!
\qmlproperty int Qt.labs.calendar::WeekNumberColumn::year
This property holds the number of the year that the week numbers are calculated for.
+
+ The value must be in the range from \c -271820 to \c 275759. The default
+ value is the current year.
*/
int QQuickWeekNumberColumn::year() const
{
@@ -135,6 +146,10 @@ int QQuickWeekNumberColumn::year() const
void QQuickWeekNumberColumn::setYear(int year)
{
Q_D(QQuickWeekNumberColumn);
+ if (year < -271820 || year > 275759) {
+ qmlInfo(this) << "year " << year << " is out of range [-271820...275759]";
+ return;
+ }
d->model->setYear(year);
}