Commit 503ff22f authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Week and Day view convergence bits

Running Calindori on a device with a wide screen (e.g. a desktop computer) the
incidences of each week/day are displayed in row. On not-so-wide screens
(e.g. a mobile device) the incidences of each week/day are displayed in a
column view.
parent c13b8017
Pipeline #28894 passed with stage
in 8 minutes and 21 seconds
......@@ -177,13 +177,17 @@ Kirigami.GlobalDrawer {
Component {
id: dayView
DayPage {}
DayPage {
wideScreen: root.wideScreen
}
}
Component {
id: weekView
WeekPage {}
WeekPage {
wideScreen: root.wideScreen
}
}
Component {
......
......@@ -8,6 +8,10 @@ import QtQuick 2.7
import org.kde.kirigami 2.0 as Kirigami
Kirigami.ScrollablePage {
id: root
property bool wideScreen
title: dayView.selectedDate.toLocaleDateString(Qt.locale(), Locale.LongFormat)
actions {
......@@ -51,6 +55,7 @@ Kirigami.ScrollablePage {
id: dayView
cal: localCalendar
wideScreen: root.wideScreen
onSelectedDateChanged: {
if (pageStack.depth > 1) {
......
......@@ -15,6 +15,7 @@ ListView {
property date selectedDate: new Date()
property var cal
property bool wideScreen
signal nextDay
signal previousDay
......@@ -91,10 +92,12 @@ ListView {
font.pointSize: Kirigami.Units.fontMetrics.font.pointSize * 1.5
text: model.index < 10 ? "0" + model.index : model.index
Layout.minimumWidth: Kirigami.Units.gridUnit * 2
Layout.minimumHeight: Kirigami.Units.gridUnit * 3
}
ColumnLayout {
spacing: 0
GridLayout {
columns: root.wideScreen ? -1 : 1
rows: root.wideScreen ? 1 : -1
Repeater {
model: IncidenceModel {
......@@ -106,7 +109,7 @@ ListView {
IncidenceItemDelegate {
itemBackgroundColor: hourListItem.incidenceColor
label: "%1 %2".arg(model.type == 0 ? model.displayStartEndTime : (model.displayDueTime || model.displayStartTime)).arg(model.summary)
label: "%1\n%2: %3".arg(model.type == 0 ? model.displayStartEndTime : (model.displayDueTime || model.displayStartTime)).arg(model.displayType).arg(model.summary)
Layout.fillWidth: true
onClicked: pageStack.push(incidencePage, { incidence: model })
......
......@@ -10,18 +10,11 @@ import org.kde.kirigami 2.0 as Kirigami
Kirigami.BasicListItem {
property alias itemBackgroundColor: backgroundRectangle.color
leftPadding: Kirigami.Units.smallSpacing
leftPadding: Kirigami.Units.smallSpacing
reserveSpaceForIcon: false
clip: true
background: Rectangle {
id: backgroundRectangle
Kirigami.Separator {
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
}
}
......@@ -46,8 +46,8 @@ Kirigami.ScrollablePage {
id: listView
anchors.fill: parent
model: incidenceModel
spacing: Kirigami.Units.largeSpacing
section {
property: incidenceType == 0 ? "displayStartDate" : "displayDueDate"
......@@ -62,6 +62,8 @@ Kirigami.ScrollablePage {
reserveSpaceForIcon: false
label: "%1\t%2".arg(model.allday ? i18n("All day") : (incidenceType == 0 ? model.displayStartEndTime : model.displayDueTime) ).arg(model.summary)
topPadding: Kirigami.Units.gridUnit
bottomPadding: Kirigami.Units.gridUnit
onClicked: pageStack.push(incidencePage, { incidence: model })
}
......
......@@ -8,7 +8,10 @@ import QtQuick 2.7
import org.kde.kirigami 2.0 as Kirigami
Kirigami.ScrollablePage {
id: root
property alias startDate: weekView.startDate
property bool wideScreen
title: weekView.selectedDate.toLocaleDateString(Qt.locale(), Locale.LongFormat)
......@@ -53,6 +56,7 @@ Kirigami.ScrollablePage {
id: weekView
cal: localCalendar
wideScreen: root.wideScreen
onSelectedWeekDateChanged: {
if (pageStack.depth > 1) {
......
......@@ -18,6 +18,7 @@ ListView {
property date selectedWeekDate: new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() - startDate.getDay() + (startDate.getDay() >= fstDayOfWeek ? fstDayOfWeek : fstDayOfWeek-7), startDate.getHours(), 0)
property date selectedDate: startDate
property var cal
property bool wideScreen
signal nextWeek
signal previousWeek
......@@ -91,10 +92,12 @@ ListView {
font.pointSize: Kirigami.Units.fontMetrics.font.pointSize * 1.5
text: Qt.locale().dayName(model.index + fstDayOfWeek, Locale.NarrowFormat)
Layout.minimumWidth: Kirigami.Units.gridUnit * 3
Layout.minimumHeight: Kirigami.Units.gridUnit * 3
}
ColumnLayout {
spacing: 0
GridLayout {
columns: wideScreen ? -1 : 1
rows: wideScreen ? 1 : -1
Repeater {
model: IncidenceModel {
......@@ -105,7 +108,7 @@ ListView {
IncidenceItemDelegate {
itemBackgroundColor: dayListItem.incidenceColor
label: "%1 %2".arg(model.type == 0 ? model.displayStartEndTime : (model.displayDueTime || model.displayStartTime)).arg(model.summary)
label: "%1\n%2: %3".arg(model.type == 0 ? model.displayStartEndTime : (model.displayDueTime || model.displayStartTime)).arg(model.displayType).arg(model.summary)
Layout.fillWidth: true
onClicked: pageStack.push(incidencePage, { incidence: model })
......
......@@ -99,6 +99,7 @@ QHash<int, QByteArray> IncidenceModel::roleNames() const
{ DisplayDueTime, "displayDueTime" },
{ DisplayStartEndTime, "displayStartEndTime" },
{ DisplayStartTime, "displayStartTime" },
{ DisplayType, "displayType" },
{ Completed, "completed" },
{ IncidenceType, "type" },
{ Due, "due" },
......@@ -160,6 +161,15 @@ QVariant IncidenceModel::data(const QModelIndex& index, int role) const
return displayDueTime(row);
case DisplayStartTime:
return displayStartTime(row);
case DisplayType:
{
if (type == IncidenceBase::TypeEvent)
return i18n("Event");
else if (type == IncidenceBase::TypeTodo)
return i18n("Task");
else
return QString();
}
case Completed:
return (type == IncidenceBase::TypeTodo) ? m_incidences.at(row).dynamicCast<Todo>()->isCompleted() : false;
case IncidenceType:
......
......@@ -66,6 +66,7 @@ public:
DisplayDueDate,
DisplayDueTime,
DisplayStartTime,
DisplayType,
Due,
ValidStartDt,
ValidEndDt,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment