camper/src/timelinedaymodel.h
jordi fita mas c49135247a Add TimelineDayRow and set it as header of timeline list
This is the equivalent control to Qt Quick Controls’ own DayOfWeekRow,
but for the number of each day in the visible range, instead of day of
the week.

Qt Quick Controls has this component written in C++, and also has a
separate, internal, model for the days in different formats, but i had
to implement the control in QML, because QtQuickControl is private.
However, as far as i understand, it is not much more than a container
for the delegate and the model that is used as a template.
2025-01-08 09:54:13 +01:00

39 lines
927 B
C++

#ifndef TIMELINEDAYMODEL_H
#define TIMELINEDAYMODEL_H
#include <QAbstractListModel>
#include <QtQmlIntegration>
class TimelineDayModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QDate fromDate READ fromDate WRITE setFromDate NOTIFY fromDateChanged)
Q_PROPERTY(QDate toDate READ toDate WRITE setToDate NOTIFY toDateChanged)
public:
explicit TimelineDayModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QDate fromDate() const;
void setFromDate(QDate date);
QDate toDate() const;
void setToDate(QDate date);
signals:
void fromDateChanged(QDate date);
void toDateChanged(QDate date);
private:
Q_DISABLE_COPY_MOVE(TimelineDayModel)
QDate m_fromDate;
QDate m_toDate;
};
#endif // TIMELINEDAYMODEL_H