Commit 535b8ce9 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

WIP: All tasks view added

parent f5c36376
......@@ -54,8 +54,34 @@ Kirigami.ApplicationWindow {
Kirigami.Action {
separator: true
}
},
Kirigami.Action {
id: show
text: "Show"
//TODO iconName:
Kirigami.Action {
text: "Calendar"
//TODO iconName:
onTriggered: {
pageStack.clear();
pageStack.push(calendarDashboardComponent)
}
}
Kirigami.Action {
text: "Tasks"
//TODO iconName:
onTriggered: {
pageStack.clear();
pageStack.push(todosView, {filtered: false});
}
}
}
]
Component.onCompleted: Utils.loadGlobalActions(calindoriConfig.calendars, calendarActions, calendarAction)
}
......@@ -136,7 +162,7 @@ Kirigami.ApplicationWindow {
onTriggered: {
if(localCalendar.todosCount(calendarMonthView.selectedDate) > 0) {
root.pageStack.push(todosView, { todoDt: calendarMonthView.selectedDate });
root.pageStack.push(todosView, { filtered: true, todoDt: calendarMonthView.selectedDate });
}
else {
showPassiveNotification (i18n("There is no task for the day selected"));
......@@ -192,7 +218,6 @@ Kirigami.ApplicationWindow {
calendar: localCalendar
onTaskeditcompleted: {
//console.log("Closing todo page");
root.refreshNeeded();
root.pageStack.pop(todoPage);
}
......
......@@ -28,13 +28,14 @@ Kirigami.Page {
property date todoDt
property var calendar
property bool filtered
signal editTask(var modelData)
signal tasksUpdated
function reload()
{
cardsListview.model.reloadTasks();
cardsListview.model.loadTasks();
}
title: qsTr("Tasks")
......@@ -62,6 +63,7 @@ Kirigami.Page {
anchors.fill: parent
model: Calindori.TodosModel {
filtered: root.filtered
filterdt: root.todoDt
memorycalendar: root.calendar.memorycalendar
}
......
......@@ -19,13 +19,14 @@
#include "todosmodel.h"
#include <QDebug>
TodosModel::TodosModel(QObject* parent)
: QAbstractListModel(parent),
: QAbstractListModel(parent),
m_todos(Todo::List()),
m_calendar(nullptr),
m_filterdt(QDate())
{
connect(this, &TodosModel::memorycalendarChanged, this, &TodosModel::reloadTasks);
connect(this, &TodosModel::filterdtChanged, this, &TodosModel::reloadTasks);
connect(this, &TodosModel::memorycalendarChanged, this, &TodosModel::loadTasks);
connect(this, &TodosModel::filterdtChanged, this, &TodosModel::loadTasks);
connect(this, &TodosModel::filteredChanged, this, &TodosModel::loadTasks);
}
TodosModel::~TodosModel() = default;
......@@ -102,9 +103,8 @@ void TodosModel::setFilterdt(QDate filterDate)
{
if (filterDate.isValid()) {
m_filterdt = filterDate;
emit filterdtChanged();
}
emit filterdtChanged();
}
int TodosModel::rowCount(const QModelIndex& parent) const
......@@ -114,19 +114,26 @@ int TodosModel::rowCount(const QModelIndex& parent) const
return m_todos.count();
}
void TodosModel::loadTasks(QDate taskDt)
void TodosModel::loadTasks()
{
beginResetModel();
m_todos.clear();
if(m_calendar != nullptr) {
m_todos = m_calendar->rawTodos(taskDt,taskDt);
if(m_calendar != nullptr && m_filterdt.isValid() && filtered()) {
m_todos = m_calendar->rawTodos(m_filterdt,m_filterdt);
}
if (m_calendar != nullptr && !(filtered())) {
m_todos = m_calendar->rawTodos();
}
endResetModel();
}
void TodosModel::reloadTasks()
void TodosModel::setFiltered(bool hasFilter)
{
if (m_filterdt.isValid()) {
loadTasks(m_filterdt);
}
m_filtered = hasFilter;
emit filteredChanged();
}
bool TodosModel::filtered() const
{
return m_filtered;
}
......@@ -31,6 +31,7 @@ class TodosModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(bool filtered READ filtered WRITE setFiltered NOTIFY filteredChanged)
Q_PROPERTY(QDate filterdt READ filterdt WRITE setFilterdt NOTIFY filterdtChanged)
Q_PROPERTY(QSharedPointer<MemoryCalendar> memorycalendar READ memorycalendar WRITE setMemorycalendar NOTIFY memorycalendarChanged )
Q_PROPERTY(int count READ rowCount NOTIFY rowsChanged)
......@@ -60,22 +61,26 @@ public:
QDate filterdt() const;
void setFilterdt(QDate filterDate);
bool filtered() const;
void setFiltered(bool hasFilter);
QHash<int, QByteArray> roleNames() const override;
public Q_SLOTS:
void reloadTasks();
void loadTasks();
Q_SIGNALS:
void rowsChanged();
void memorycalendarChanged();
void filterdtChanged();
void filteredChanged();
private:
Todo::List m_todos;
MemoryCalendar::Ptr m_calendar;
QDate m_filterdt;
void loadTasks(QDate taskDt);
bool m_filtered;
};
#endif // TODOSMODEL_H
......
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