diff --git a/src/ReservationsTimeline.qml b/src/ReservationsTimeline.qml index 7abc4fb..2870e1f 100644 --- a/src/ReservationsTimeline.qml +++ b/src/ReservationsTimeline.qml @@ -213,7 +213,9 @@ Control { Repeater { delegate: Rectangle { - color: "transparent" + required property bool isWeekend + + color: isWeekend ? palette.alternateBase : "transparent" height: parent.height width: control.dayWidth diff --git a/src/TimelineDayRow.qml b/src/TimelineDayRow.qml index ce4dea1..c8b8606 100644 --- a/src/TimelineDayRow.qml +++ b/src/TimelineDayRow.qml @@ -14,7 +14,10 @@ Control { model: model delegate: Label { + id: delegate + required property string display + required property bool isWeekend anchors.bottom: parent.bottom anchors.top: parent.top @@ -24,6 +27,10 @@ Control { verticalAlignment: Text.AlignVCenter width: control.dayWidth + background: Rectangle { + color: delegate.isWeekend ? delegate.palette.alternateBase : "transparent" + } + Separator { anchors.bottom: parent.bottom anchors.right: parent.right diff --git a/src/timelinedaymodel.cpp b/src/timelinedaymodel.cpp index 21758c6..140d34f 100644 --- a/src/timelinedaymodel.cpp +++ b/src/timelinedaymodel.cpp @@ -25,11 +25,20 @@ QVariant TimelineDayModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: return QString::number(date.day()); + case WeekendRole: + return date.dayOfWeek() > 5; } return {}; } +QHash TimelineDayModel::roleNames() const +{ + QHash roles = QAbstractListModel::roleNames(); + roles[WeekendRole] = "isWeekend"; + return roles; +} + QDate TimelineDayModel::fromDate() const { return m_fromDate; diff --git a/src/timelinedaymodel.h b/src/timelinedaymodel.h index 09a6c1c..25d9033 100644 --- a/src/timelinedaymodel.h +++ b/src/timelinedaymodel.h @@ -13,10 +13,15 @@ class TimelineDayModel : public QAbstractListModel Q_PROPERTY(QDate toDate READ toDate WRITE setToDate NOTIFY toDateChanged) public: + enum Role { + WeekendRole = Qt::UserRole, + }; + explicit TimelineDayModel(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash roleNames() const override; QDate fromDate() const; void setFromDate(QDate date);