Commit b522f1bc authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Event counter added to the month view header, the events-or-tasks-exist...

Event counter added to the month view header, the events-or-tasks-exist indicator also added to the day delegate. User interface simplified by merging Show/Add (event/task) contextual actions.
parent 54bdcb4b
......@@ -40,6 +40,7 @@ MonthView {
currentMonthName: plasmaCalendar.displayedDateMonthName
selectedDayTodosCount: todosCount(selectedDate)
selectedDayEventsCount: eventsCount(selectedDate)
daysModel: plasmaCalendar.daysModel
showHeader: true
showMonthName: true
......
......@@ -26,7 +26,7 @@ import org.kde.phone.calindori 0.1 as Calindori
Kirigami.Page {
id: root
property date eventDt
property date eventStartDt
property var calendar
signal editEvent(var modelData)
......
......@@ -156,42 +156,16 @@ Kirigami.ApplicationWindow {
contextualActions: [
Kirigami.Action {
iconName: "view-calendar-tasks"
text: "Show tasks"
onTriggered: {
if(localCalendar.todosCount(calendarMonthView.selectedDate) > 0) {
root.pageStack.push(todosView, { todoDt: calendarMonthView.selectedDate });
}
else {
showPassiveNotification (i18n("There is no task for the day selected"));
}
}
},
Kirigami.Action {
iconName: "resource-calendar-insert"
text: "Add task"
text: "Tasks"
onTriggered: root.pageStack.push(todoPage, { startdt: calendarMonthView.selectedDate} )
},
onTriggered: root.pageStack.push(todosView, { todoDt: calendarMonthView.selectedDate })
},
Kirigami.Action {
iconName: "view-calendar-events"
text: "Show events"
onTriggered: {
// if(localCalendar.eventsCount(calendarMonthView.selectedDate) > 0) { //TODO: Implement eventsCount
root.pageStack.push(eventsView, { eventDt: calendarMonthView.selectedDate });
// }
// else {
// showPassiveNotification (i18n("There is no event for the day selected"));
// }
}
},
Kirigami.Action {
iconName: "resource-calendar-insert"
text: "Add event"
text: "Events"
onTriggered: root.pageStack.push(eventEditor, { startdt: calendarMonthView.selectedDate} )
onTriggered: root.pageStack.push(eventsView, { eventStartDt: calendarMonthView.selectedDate })
}
]
}
......@@ -205,6 +179,10 @@ Kirigami.ApplicationWindow {
return localCalendar.todosCount(todosDate);
}
eventsCount: function (eventsDate) {
return localCalendar.eventsCount(eventsDate);
}
onSelectedDateChanged: {
if (root.pageStack.depth > 1) {
root.pageStack.pop(null);
......@@ -245,7 +223,7 @@ Kirigami.ApplicationWindow {
EventsView {
calendar: localCalendar
onEditEvent: root.pageStack.push(eventEditor, { startdt: modelData.dtstart, uid: modelData.uid, eventData: modelData })
onEditEvent: root.pageStack.push(eventEditor, { startdt: modelData.dtstart, uid: modelData.uid, eventData: modelData })
onEventsUpdated: root.refreshNeeded()
Connections {
......
......@@ -27,6 +27,7 @@ ColumnLayout {
property date headerDate
property int headerTodosCount
property int headerEventsCount
RowLayout {
id: selectedDayHeading
......@@ -55,8 +56,10 @@ ColumnLayout {
}
Controls2.Label {
text: (root.headerTodosCount > 0) ? i18np("%1 task for today", "%1 tasks for today",root.headerTodosCount) : ""
text: ((root.headerTodosCount > 0) ? i18np("%1 task", "%1 tasks",root.headerTodosCount) : "") +
((root.headerTodosCount > 0 && root.headerEventsCount > 0) ? " and " : "") +
((root.headerEventsCount > 0) ? i18np("%1 event", "%1 events",root.headerEventsCount) : "")
opacity: 0.6
}
}
......@@ -40,7 +40,7 @@ Rectangle {
property int delegateWidth
property date selectedDate
property bool highlight: (model.yearNumber == selectedDate.getFullYear()) && (model.monthNumber == selectedDate.getMonth() + 1) && (model.dayNumber == root.selectedDate.getDate())
property int todosCount
property int incidentsCount
signal dayClicked
......@@ -56,7 +56,7 @@ Rectangle {
/**
* Display a tiny indicator in case that
* todos exist for the day of the model
* todos or events exist for the day of the model
*/
Rectangle {
anchors {
......@@ -71,7 +71,7 @@ Rectangle {
height: width
radius: 50
color: Kirigami.Theme.selectionFocusColor
visible: todosCount > 0
visible: incidentsCount > 0
}
Controls2.ToolButton {
......
......@@ -39,6 +39,7 @@ Item {
property int dayRectWidth: Kirigami.Units.gridUnit*2.5
property date selectedDate: new Date()
property int selectedDayTodosCount: 0
property int selectedDayEventsCount: 0
property string currentMonthName
/**
* A model that provides:
......@@ -58,11 +59,23 @@ Item {
property var todosCount: function (todosDate) {
return 0;
}
/**
* Function that returns the amount of events of each day
*
* If implemented, a small indicator will be displayed
* into the cell of each day. Default implementation returns 0,
* so no indicator is displayed.
*/
property var eventsCount: function (eventsDate) {
return 0;
}
property bool showHeader: false
property bool showMonthName: true
function reloadSelectedDate() {
root.selectedDayTodosCount = root.todosCount(root.selectedDate)
root.selectedDayEventsCount = root.eventsCount(root.selectedDate)
}
onSelectedDateChanged: reloadSelectedDate()
......@@ -83,6 +96,7 @@ Item {
Layout.bottomMargin: Kirigami.Units.gridUnit / 2
headerDate: root.selectedDate
headerTodosCount: root.selectedDayTodosCount
headerEventsCount: root.selectedDayEventsCount
visible: root.showHeader
}
......@@ -133,7 +147,8 @@ Item {
currentDate: root.currentDate
delegateWidth: root.dayRectWidth
selectedDate: root.selectedDate
todosCount: root.todosCount(new Date(model.yearNumber, model.monthNumber -1, model.dayNumber))
incidentsCount: root.todosCount(new Date(model.yearNumber, model.monthNumber -1, model.dayNumber))
+ root.eventsCount(new Date(model.yearNumber, model.monthNumber -1, model.dayNumber))
onDayClicked: root.selectedDate = new Date(model.yearNumber, model.monthNumber -1, model.dayNumber)
}
......
......@@ -126,10 +126,14 @@ void EventModel::loadEvents()
m_events.clear();
if(m_calendar != nullptr && m_filterdt.isValid())
m_events = m_calendar->rawEventsForDate(m_filterdt);
{
m_events = m_calendar->rawEvents(m_filterdt,m_filterdt);
}
if(m_calendar != nullptr && m_filterdt.isNull())
{
m_events = m_calendar->rawEvents();
}
endResetModel();
emit rowCountChanged();
......
......@@ -234,6 +234,6 @@ int LocalCalendar::eventsCount(const QDate& date) const {
{
return 0;
}
Event::List eventList = m_calendar->rawEventsForDate(date);
Event::List eventList = m_calendar->rawEvents(date,date);
return eventList.count();
}
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