Compare commits
No commits in common. "8677051303b410608c363b8221b8fa77e61b7e19" and "ff27ea89d92dca420ad7435c7a99883d5f7b445f" have entirely different histories.
8677051303
...
ff27ea89d9
|
@ -213,9 +213,7 @@ Control {
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
required property bool isWeekend
|
color: "transparent"
|
||||||
|
|
||||||
color: isWeekend ? palette.alternateBase : "transparent"
|
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: control.dayWidth
|
width: control.dayWidth
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,7 @@ Control {
|
||||||
model: model
|
model: model
|
||||||
|
|
||||||
delegate: Label {
|
delegate: Label {
|
||||||
id: delegate
|
|
||||||
|
|
||||||
required property string display
|
required property string display
|
||||||
required property bool isWeekend
|
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
@ -27,10 +24,6 @@ Control {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
width: control.dayWidth
|
width: control.dayWidth
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
color: delegate.isWeekend ? delegate.palette.alternateBase : "transparent"
|
|
||||||
}
|
|
||||||
|
|
||||||
Separator {
|
Separator {
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
|
@ -25,20 +25,11 @@ QVariant TimelineDayModel::data(const QModelIndex &index, int role) const
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return QString::number(date.day());
|
return QString::number(date.day());
|
||||||
case WeekendRole:
|
|
||||||
return date.dayOfWeek() > 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> TimelineDayModel::roleNames() const
|
|
||||||
{
|
|
||||||
QHash<int, QByteArray> roles = QAbstractListModel::roleNames();
|
|
||||||
roles[WeekendRole] = "isWeekend";
|
|
||||||
return roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDate TimelineDayModel::fromDate() const
|
QDate TimelineDayModel::fromDate() const
|
||||||
{
|
{
|
||||||
return m_fromDate;
|
return m_fromDate;
|
||||||
|
|
|
@ -13,15 +13,10 @@ class TimelineDayModel : public QAbstractListModel
|
||||||
Q_PROPERTY(QDate toDate READ toDate WRITE setToDate NOTIFY toDateChanged)
|
Q_PROPERTY(QDate toDate READ toDate WRITE setToDate NOTIFY toDateChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Role {
|
|
||||||
WeekendRole = Qt::UserRole,
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit TimelineDayModel(QObject *parent = nullptr);
|
explicit TimelineDayModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
|
||||||
|
|
||||||
QDate fromDate() const;
|
QDate fromDate() const;
|
||||||
void setFromDate(QDate date);
|
void setFromDate(QDate date);
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct TimelineView::Item
|
||||||
, day(day)
|
, day(day)
|
||||||
{
|
{
|
||||||
item->setParentItem(&view);
|
item->setParentItem(&view);
|
||||||
item->setPosition(QPointF(day * view.dayWidth() + view.dayWidth() / 2, 0.0));
|
item->setPosition(QPointF(day * view.dayWidth(), 0.0));
|
||||||
item->setSize(QSizeF(len * view.dayWidth(), view.height()));
|
item->setSize(QSizeF(len * view.dayWidth(), view.height()));
|
||||||
item->setVisible(true);
|
item->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue