Fluid
Loading...
Searching...
No Matches
yearselector.h
Go to the documentation of this file.
1/*
2 * This file is part of Fluid.
3 *
4 * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
5 *
6 * $BEGIN_LICENSE:MPL2$
7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 *
12 * $END_LICENSE$
13 */
14
15#pragma once
16
17#include <QDate>
18#include <QQuickItem>
19
20class YearModel;
21
22class YearSelector : public QQuickItem
23{
24 Q_OBJECT
25 Q_PROPERTY(YearModel *model READ model NOTIFY modelChanged FINAL)
26 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
27 Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL)
28 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
30 Q_PROPERTY(QDate from READ from WRITE setFrom RESET resetFrom NOTIFY fromChanged FINAL)
31 Q_PROPERTY(QDate to READ to WRITE setTo RESET resetTo NOTIFY toChanged FINAL)
32 Q_PROPERTY(int selectedYear READ selectedYear WRITE setSelectedYear NOTIFY selectedYearChanged FINAL)
33 QML_ELEMENT
34 Q_DISABLE_COPY(YearSelector)
35public:
36 explicit YearSelector(QQuickItem *parent = nullptr);
37
38 YearModel *model() const;
39
40 int count() const;
41
42 QQuickItem *contentItem() const;
43 void setContentItem(QQuickItem *item);
44
45 QQmlComponent *delegate() const;
46 void setDelegate(QQmlComponent *delegate);
47
48 int visibleItemCount() const;
51
52 QDate from() const;
53 void setFrom(const QDate &date);
54 void resetFrom();
55
56 QDate to() const;
57 void setTo(const QDate &date);
58 void resetTo();
59
60 int selectedYear() const;
61 void setSelectedYear(int year);
62
63Q_SIGNALS:
70 void toChanged();
72
73private:
74 YearModel *m_model = nullptr;
75 QDate m_from;
76 QDate m_to;
77 QQuickItem *m_contentItem = nullptr;
78 QQmlComponent *m_delegate = nullptr;
79 int m_visibleItemCount = 7;
80 int m_selectedYear;
81};
82
83QML_DECLARE_TYPE(YearSelector)
84
Definition yearmodel.h:22
Definition YearSelector.qml:19
void contentItemChanged()
YearModel * model
Definition yearselector.h:25
void setTo(const QDate &date)
Definition yearselector.cpp:120
QDate from
Definition yearselector.h:30
void setContentItem(QQuickItem *item)
Definition yearselector.cpp:45
void resetTo()
Definition yearselector.cpp:134
void delegateChanged()
int selectedYear
Definition yearselector.h:32
void resetFrom()
Definition yearselector.cpp:110
int count
Definition yearselector.h:26
QQmlComponent * delegate
Definition yearselector.h:28
void setDelegate(QQmlComponent *delegate)
Definition yearselector.cpp:63
void modelChanged()
void setFrom(const QDate &date)
Definition yearselector.cpp:96
QQuickItem * contentItem
Definition yearselector.h:27
int visibleItemCount
Definition yearselector.h:29
void setVisibleItemCount(int visibleItemCount)
Definition yearselector.cpp:77
void fromChanged()
QDate to
Definition yearselector.h:31
void visibleItemCountChanged()
void countChanged()
void selectedYearChanged()
void toChanged()
void setSelectedYear(int year)
Definition yearselector.cpp:144
void resetVisibleItemCount()
Definition yearselector.cpp:86