[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-workspace] applets/digital-clock/package/contents/ui: [digital-clock] Adapt the Agenda part
From: Martin Klapetek <mklapetek () kde ! org>
Date: 2015-11-16 21:03:45
Message-ID: E1ZyQwD-0003Li-6R () scm ! kde ! org
[Download RAW message or body]
Git commit 7232b798d557fb8d785827143aa576b24e790acc by Martin Klapetek.
Committed on 16/11/2015 at 20:51.
Pushed by mklapetek into branch 'master'.
[digital-clock] Adapt the Agenda part to latest applet updates
M +65 -59 applets/digital-clock/package/contents/ui/CalendarView.qml
http://commits.kde.org/plasma-workspace/7232b798d557fb8d785827143aa576b24e790acc
diff --git a/applets/digital-clock/package/contents/ui/CalendarView.qml \
b/applets/digital-clock/package/contents/ui/CalendarView.qml index ebc54a9..73425df \
100644
--- a/applets/digital-clock/package/contents/ui/CalendarView.qml
+++ b/applets/digital-clock/package/contents/ui/CalendarView.qml
@@ -28,7 +28,7 @@ Item {
Layout.minimumHeight: _minimumHeight
// The "sensible" values
-property int _minimumWidth: _minimumHeight * 1.5 + (monthView.showWeekNumbers ? \
Math.round(_minimumHeight * 1.75) : Math.round(_minimumHeight * 1.5)) + property \
int _minimumWidth: _minimumHeight * 1.5 + (monthView.showWeekNumbers ? \
Math.round(_minimumHeight * 1.75) : Math.round(_minimumHeight * 1.5)) property int \
_minimumHeight: units.gridUnit * 14 Layout.preferredWidth: _minimumWidth
Layout.preferredHeight: _minimumHeight * 1.5
@@ -50,13 +50,11 @@ property int _minimumWidth: _minimumHeight * 1.5 + \
(monthView.showWeekNumbers ? // clear all the selections when the plasmoid is hiding
monthView.date = null;
monthView.resetToToday();
- agenda.day = null;
}
}
Item {
id: agenda
- property QtObject day
width: avWidth
anchors {
@@ -68,25 +66,35 @@ property int _minimumWidth: _minimumHeight * 1.5 + \
(monthView.showWeekNumbers ? bottomMargin: spacing
}
- Rectangle { anchors.fill: parent; color: "orange"; opacity: 0.2; visible: \
debug; }
-
function dateString(format) {
- var d;
- if (agenda.day != undefined) {
- var day = agenda.day;
- d = new Date(day.yearNumber, day.monthNumber-1, day.dayNumber);
- } else {
- d = new Date();
- }
- var o = Qt.formatDate(d, format);
- return o;
+ return Qt.formatDate(monthView.currentDate, format);
}
Connections {
target: monthView
- onDateChanged: {
- if (monthView.date != null) {
- agenda.day = monthView.date;
+
+ onCurrentDateChanged: {
+ // Apparently this is needed because this is a simple QList being
+ // returned and if the list for the current day has 1 event and the
+ // user clicks some other date which also has 1 event, QML sees the
+ // sizes match and does not update the labels with the content.
+ // Resetting the model to null first clears it and then correct data
+ // are displayed.
+ holidaysList.model = null;
+ holidaysList.model = \
monthView.daysModel.eventsForDate(monthView.currentDate); + }
+ }
+
+ Connections {
+ target: monthView.daysModel
+
+ onAgendaUpdated: {
+ // Checks if the dates are the same, comparing the date objects
+ // directly won't work and this does a simple integer subtracting
+ // so should be fastest. One of the JS weirdness.
+ if (updatedDate - monthView.currentDate === 0) {
+ holidaysList.model = null;
+ holidaysList.model = \
monthView.daysModel.eventsForDate(monthView.currentDate); }
}
}
@@ -98,7 +106,7 @@ property int _minimumWidth: _minimumHeight * 1.5 + \
(monthView.showWeekNumbers ? font.pixelSize: height
font.weight: Font.Light
text: agenda.dateString("dd")
- opacity: 0.5
+ opacity: 0.6
}
PlasmaExtras.Heading {
@@ -122,65 +130,65 @@ property int _minimumWidth: _minimumHeight * 1.5 + \
(monthView.showWeekNumbers ? leftMargin: spacing / 2
}
elide: Text.ElideRight
- text: Qt.locale().standaloneMonthName(agenda.day == null ? new \
Date().getMonth() : agenda.day.monthNumber - 1) + text: \
Qt.locale().standaloneMonthName(monthView.currentDate.getMonth()) + \
agenda.dateString(" yyyy") }
ListView {
- id: eventList
+ id: holidaysList
anchors {
+ top: dateHeading.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
- top: parent.top
- topMargin: monthView.cellHeight + dayHeading.height
}
- // Time slots shown
- model: [ 8, 10, 12, 14, 16, 18 ]
-
delegate: Item {
- height: monthView.cellHeight
- width: parent.width
- Rectangle {
- height: monthView.borderWidth
- color: theme.textColor
- opacity: monthView.borderOpacity
- anchors {
- left: parent.left
- right: parent.right
- top: parent.top
- leftMargin: spacing
- rightMargin: spacing
+ id: eventItem
+ width: holidaysList.width
+ height: eventTitle.paintedHeight
+ property bool hasTime: {
+ var startIsMidnight = modelData.startDateTime.getHours() == 0
+ && modelData.startDateTime.getMinutes() == 0;
+
+ var endIsMidnight = modelData.endDateTime.getHours() == 0
+ && modelData.endDateTime.getMinutes() == 0;
+
+ var sameDay = modelData.startDateTime.getDate() == \
modelData.endDateTime.getDate() + && \
modelData.startDateTime.getDay() == modelData.endDateTime.getDay() +
+ if (startIsMidnight && endIsMidnight && sameDay) {
+ return false
}
+
+ return true;
}
PlasmaComponents.Label {
- id: hourLabel
- height: paintedHeight
- font.pixelSize: monthView.cellHeight / 3
- opacity: 0.5
- anchors {
- right: minuteLabel.left
- verticalCenter: parent.verticalCenter
+ text: {
+ if (modelData.startDateTime - modelData.endDateTime === 0) {
+ return Qt.formatTime(modelData.startDateTime);
+ } else {
+ return Qt.formatTime(modelData.startDateTime) + " - " + \
Qt.formatTime(modelData.endDateTime); + }
}
- text: modelData
+ visible: eventItem.hasTime
}
PlasmaComponents.Label {
- id: minuteLabel
- x: units.largeSpacing*2
-
- height: paintedHeight
- font.pixelSize: hourLabel.paintedHeight / 2
- opacity: hourLabel.opacity
- anchors {
- top: hourLabel.top
- }
- text: "00"
+ id: eventTitle
+ width: eventItem.hasTime ? parent.width * 0.7 : parent.width
+ anchors.right: parent.right
+ text: modelData.title
}
}
- }
+ section.property: "modelData.eventType"
+ section.delegate: PlasmaExtras.Heading {
+ level: 3
+ elide: Text.ElideRight
+ text: section
+ }
+ }
}
Item {
id: cal
@@ -189,9 +197,7 @@ property int _minimumWidth: _minimumHeight * 1.5 + \
(monthView.showWeekNumbers ? top: parent.top
right: parent.right
bottom: parent.bottom
- rightMargin: spacing
- topMargin: spacing
- bottomMargin: spacing
+ margins: spacing
}
PlasmaCalendar.MonthView {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic