Commit ad7e4dc1 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos
Browse files

Show indicators if tasks exist and add a heading to the month view

parent 78e2ee65
......@@ -39,19 +39,20 @@ Kirigami.ApplicationWindow {
pageStack.initialPage: [calendarDashboardComponent]
signal todoCompleted;
Component {
id: calendarDashboardComponent
Kirigami.Page {
id: monthPage
property alias monthName: monthView.monthName
property alias year: monthView.year
anchors.fill: parent
//anchors.fill: parent
title: monthView.monthName + " " + monthView.year
actions {
left: Kirigami.Action {
iconName: "go-previous"
......@@ -92,9 +93,25 @@ Kirigami.ApplicationWindow {
PlayMonthView {
id: monthView
anchors.centerIn: parent
todosCount: function (dayNumber, monthNumber, yearNumber) {
var date = new Date(yearNumber, monthNumber-1, dayNumber);
var todos = localCalendar.todosCount(date);
//DEBUG console.log(date.toString() + " has " + todos + " todos");
return localCalendar.todosCount(date);
}
Connections {
target: root
onTodoCompleted: {
console.log("daysModel update");
monthView.daysModel.update();
}
}
height: monthPage.height
width: monthPage.width
}
}
......@@ -116,10 +133,11 @@ Kirigami.ApplicationWindow {
TodoPage {
calendar: localCalendar
onTaskeditcompleted: {
console.log("Closing todo page");
todosView.todosmodel.reloadTasks();
root.todoCompleted();
root.pageStack.pop(todoPage);
}
}
......
......@@ -147,7 +147,7 @@ Kirigami.Page {
main: Kirigami.Action {
id: info
text: qStr("Info")
text: qsTr("Info")
icon.name : "documentinfo"
onTriggered: {
......
......@@ -23,46 +23,71 @@ import QtQuick.Layouts 1.11
import org.kde.kirigami 2.0 as Kirigami
/**
* Month Day Delegate
*
* Controls the display of each day of a months' grid
*
*/
* Month Day Delegate
*
* Controls the display of each day of a months' grid
*
*/
Rectangle {
id: dayDelegate
property date currentDate
property int delegateWidth
property int selectedYear
property int selectedMonth
property int selectedDay
property bool highlight: (model.yearNumber == selectedYear) && (model.monthNumber == selectedMonth) && (model.dayNumber == selectedDay)
property bool highlight: (model.yearNumber == selectedYear) && (model.monthNumber == selectedMonth) && (model.dayNumber == selectedDay)
property int todosCount
signal dayClicked
width: childrenRect.width
height: childrenRect.height
opacity:(dayButton.isCurrentDate || highlight ) ? 0.4 : 1
color: dayButton.isCurrentDate ? Kirigami.Theme.textColor : ( highlight ? Kirigami.Theme.selectionBackgroundColor : Kirigami.Theme.backgroundColor )
border.color: Kirigami.Theme.disabledTextColor
// onHighlightChanged: {
// // //DEBUG
// console.log("*** highlight: " + highlight + ", selectedDate: " + dayDelegate.selectedYear + "-" + dayDelegate.selectedMonth + "-" + dayDelegate.selectedDay + ", delegateDate: " + model.yearNumber + "-" + model.monthNumber + "-" + model.dayNumber + " ***")
// }
// onHighlightChanged: {
// // //DEBUG
// console.log("*** highlight: " + highlight + ", selectedDate: " + dayDelegate.selectedYear + "-" + dayDelegate.selectedMonth + "-" + dayDelegate.selectedDay + ", delegateDate: " + model.yearNumber + "-" + model.monthNumber + "-" + model.dayNumber + " ***")
// }
Item {
width: dayDelegate.delegateWidth
height: width
Rectangle {
anchors {
bottom: parent.bottom
bottomMargin: parent.width/15
right: parent.right
rightMargin: parent.width/15
}
width: parent.width/10
height: width
radius: 50
color: Kirigami.Theme.selectionFocusColor
visible: todosCount > 0
}
Controls2.ToolButton {
id: dayButton
anchors.fill: parent
property bool isCurrentDate: ( Qt.formatDate(dayDelegate.currentDate, "yyyy") == model.yearNumber ) && ( Qt.formatDate(dayDelegate.currentDate, "MM") == model.monthNumber ) && ( Qt.formatDate(dayDelegate.currentDate, "dd") == model.dayNumber )
property bool isCurrentMonth: model.monthNumber == Qt.formatDate(plasmaCalendar.displayedDate, "MM")
onClicked: dayDelegate.dayClicked()
Controls2.ToolButton {
id: dayButton
property bool isCurrentDate: ( Qt.formatDate(dayDelegate.currentDate, "yyyy") == model.yearNumber ) && ( Qt.formatDate(dayDelegate.currentDate, "MM") == model.monthNumber ) && ( Qt.formatDate(dayDelegate.currentDate, "dd") == model.dayNumber )
property bool isCurrentMonth: model.monthNumber == Qt.formatDate(plasmaCalendar.displayedDate, "MM")
onClicked: dayDelegate.dayClicked()
width: dayDelegate.delegateWidth
height: width
text: model.dayNumber
enabled: isCurrentMonth
text: model.dayNumber
enabled: isCurrentMonth
}
}
}
......@@ -34,18 +34,25 @@ Item {
property int selectedYear: currentDate.getFullYear()
property int selectedMonth: currentDate.getMonth() + 1
property int selectedDay: currentDate.getDate()
property string selectedDayName: new Date().toLocaleDateString(Qt.locale(), "dddd");
property var todosCount: function (dayNumber, monthNumber, yearNumber) {
return 0;
}
property int selectedDayTodosCount: todosCount(selectedDay, selectedMonth,selectedYear)
property alias daysModel: plasmaCalendar.daysModel
signal nextMonth
signal previousMonth
signal goToday
signal dayClicked(int index, var model, var item)
signal populateDay(int index, var model, var item)
onDayClicked: {
onPopulateDay: {
root.selectedYear = model.yearNumber;
root.selectedMonth = model.monthNumber;
root.selectedDay = model.dayNumber;
console.log("Selected date: "+ model.yearNumber + model.monthNumber + model.dayNumber + " clicked");
root.selectedDayName = new Date(model.yearNumber, model.monthNumber -1, model.dayNumber).toLocaleDateString(Qt.locale(), "dddd");
//DEBUG console.log("Selected date: " + " " + model.yearNumber + model.monthNumber + model.dayNumber + " clicked");
}
onNextMonth: {
......@@ -74,7 +81,41 @@ Item {
ColumnLayout {
spacing: 0
anchors.centerIn: parent
spacing: Kirigami.Units.gridUnit / 4
RowLayout {
id: selectedDayHeading
spacing: Kirigami.Units.gridUnit / 2
Controls2.Label {
font.pointSize: Kirigami.Units.fontMetrics.font.pointSize * 4
text: root.selectedDay
opacity: 0.6
}
ColumnLayout {
spacing: Kirigami.Units.gridUnit / 6
Controls2.Label {
text: root.selectedDayName
font.pointSize: Kirigami.Units.fontMetrics.font.pointSize * 1.5
}
Controls2.Label {
text: root.monthName + " " + root.selectedYear
}
}
}
Controls2.Label {
text: (root.selectedDayTodosCount) ? i18np("%1 task for today", "%1 tasks for today",root.selectedDayTodosCount) : ""
opacity: 0.6
bottomPadding: Kirigami.Units.gridUnit / 2
}
/**
* Header of the days' calendar grid
......@@ -99,6 +140,8 @@ Item {
rows: root.weeks
Repeater {
id: dayRepeater
model: plasmaCalendar.daysModel
delegate: MonthDayDelegate {
id: monthDayDelegate
......@@ -108,12 +151,14 @@ Item {
selectedYear: root.selectedYear
selectedMonth: root.selectedMonth
selectedDay: root.selectedDay
todosCount: root.todosCount(model.dayNumber, model.monthNumber, model.yearNumber)
onDayClicked: root.dayClicked(index, model, monthDayDelegate)
onDayClicked: root.populateDay(index, model, monthDayDelegate)
}
}
}
}
/**
......
......@@ -131,8 +131,6 @@ void LocalCalendar::addEditTask(QString uid, QDate startDate, QString summary, Q
qDebug() << "Todo has been saved";
}
void LocalCalendar::deleteTask(QString uid) {
qDebug() << "Deleting task: " << uid;
Todo::Ptr todo = m_calendar->todo(uid);
......@@ -140,3 +138,9 @@ void LocalCalendar::deleteTask(QString uid) {
bool success = m_cal_storage->save();
qDebug() << "Task deleted? " << success;
}
int LocalCalendar::todosCount(const QDate &date) const {
Todo::List todoList = m_calendar->rawTodos(date,date);
//DEBUG qDebug() << todoList.size() << " todos found in " << date.toString();
return todoList.size();
}
......@@ -48,6 +48,7 @@ public:
public Q_SLOTS:
void addEditTask(QString uid, QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location);
void deleteTask(QString uid);
int todosCount(const QDate &date) const;
Q_SIGNALS:
void memorycalendarChanged();
......
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