diff --git a/src/contents/ui/Main.qml b/src/contents/ui/Main.qml index 71405afcca1b52b0b49288ea076cf59f43a218fc..395ade83f6b6ab4c2a2c57ec41b4cb6b19f877ea 100644 --- a/src/contents/ui/Main.qml +++ b/src/contents/ui/Main.qml @@ -72,11 +72,11 @@ Kirigami.ApplicationWindow { } Kirigami.Action { - text: "Tasks" + text: "Tasks" + " (" + localCalendar.name + ")" iconName: "view-calendar-tasks" onTriggered: { pageStack.clear(); - pageStack.push(todosView, {filtered: false, todoDt: null}); + pageStack.push(todosView, { todoDt: localCalendar.nulldate }); } } } @@ -162,7 +162,7 @@ Kirigami.ApplicationWindow { onTriggered: { if(localCalendar.todosCount(calendarMonthView.selectedDate) > 0) { - root.pageStack.push(todosView, { filtered: true, todoDt: calendarMonthView.selectedDate }); + root.pageStack.push(todosView, { todoDt: calendarMonthView.selectedDate }); } else { showPassiveNotification (i18n("There is no task for the day selected")); diff --git a/src/contents/ui/TodosView.qml b/src/contents/ui/TodosView.qml index d60a54827ff7ae4376f5ca0a4e4ea76d74c8e1e8..e2dddb8ee25ee4340547ee360b5347da51c648e2 100644 --- a/src/contents/ui/TodosView.qml +++ b/src/contents/ui/TodosView.qml @@ -26,9 +26,8 @@ import org.kde.phone.calindori 0.1 as Calindori Kirigami.Page { id: root - property var todoDt + property date todoDt property var calendar - property bool filtered signal editTask(var modelData) signal tasksUpdated @@ -43,7 +42,7 @@ Kirigami.Page { actions.main: Kirigami.Action { icon.name: "resource-calendar-insert" text: qsTr("Add task") - onTriggered: pageStack.push(todoPage, { startdt: todoDt} ) + onTriggered: pageStack.push(todoPage, {startdt: todoDt}) } @@ -64,8 +63,7 @@ Kirigami.Page { anchors.fill: parent model: Calindori.TodosModel { - filtered: root.filtered - filterdt: root.todoDt != null && !isNaN(root.todoDt) ? root.todoDt : new Date("No Date") + filterdt: root.todoDt memorycalendar: root.calendar.memorycalendar } diff --git a/src/plugins/localcalendar.cpp b/src/plugins/localcalendar.cpp index 0eac18cede9b09031e16e9a058f574bc65f352e9..b666cb33b70ffb7cbefd7ad72a21266708a833da 100644 --- a/src/plugins/localcalendar.cpp +++ b/src/plugins/localcalendar.cpp @@ -162,3 +162,9 @@ void LocalCalendar::deleteCalendar() calendarFile.remove(); } } + + +QDateTime LocalCalendar::nulldate() const +{ + return QDateTime(); +} diff --git a/src/plugins/localcalendar.h b/src/plugins/localcalendar.h index a9c277b391e0b6ed7f35928e5c4dc53c88a2a9f7..78ff9b10f3eb6e5629cfad60d60935b5416b18c8 100644 --- a/src/plugins/localcalendar.h +++ b/src/plugins/localcalendar.h @@ -30,32 +30,33 @@ class LocalCalendar : public QObject Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QSharedPointer memorycalendar READ memorycalendar WRITE setMemorycalendar NOTIFY memorycalendarChanged) - Q_PROPERTY(QSharedPointer calendarstorage READ calendarstorage WRITE setCalendarstorage NOTIFY calendarstorageChanged) + Q_PROPERTY(QSharedPointer calendarstorage READ calendarstorage WRITE setCalendarstorage NOTIFY calendarstorageChanged) + Q_PROPERTY(QDateTime nulldate READ nulldate CONSTANT) public: - explicit LocalCalendar(QObject* parent = nullptr); ~LocalCalendar() override; - + MemoryCalendar::Ptr memorycalendar() const; FileStorage::Ptr calendarstorage() const; QString name() const; + QDateTime nulldate() const; void setMemorycalendar(MemoryCalendar::Ptr memoryCalendar); void setCalendarstorage(FileStorage::Ptr calendarStorage); void setName(QString calendarName); - + 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); + void deleteTask(QString uid); int todosCount(const QDate &date) const; void deleteCalendar(); - + Q_SIGNALS: void memorycalendarChanged(); void calendarstorageChanged(); void nameChanged(); - + private: MemoryCalendar::Ptr m_calendar; FileStorage::Ptr m_cal_storage; diff --git a/src/plugins/todosmodel.cpp b/src/plugins/todosmodel.cpp index 61549da8c70bea061af24d549651aadd75273fbf..91aeee584e2393fe556ccc0ba499452833fcbea4 100644 --- a/src/plugins/todosmodel.cpp +++ b/src/plugins/todosmodel.cpp @@ -26,7 +26,6 @@ TodosModel::TodosModel(QObject* parent) { connect(this, &TodosModel::memorycalendarChanged, this, &TodosModel::loadTasks); connect(this, &TodosModel::filterdtChanged, this, &TodosModel::loadTasks); - connect(this, &TodosModel::filteredChanged, this, &TodosModel::loadTasks); } TodosModel::~TodosModel() = default; @@ -101,10 +100,8 @@ QDate TodosModel::filterdt() const void TodosModel::setFilterdt(QDate filterDate) { - if (filterDate.isValid()) { - m_filterdt = filterDate; - emit filterdtChanged(); - } + m_filterdt = filterDate; + emit filterdtChanged(); } int TodosModel::rowCount(const QModelIndex& parent) const @@ -118,22 +115,11 @@ void TodosModel::loadTasks() { beginResetModel(); m_todos.clear(); - if(m_calendar != nullptr && m_filterdt.isValid() && filtered()) { + if(m_calendar != nullptr && m_filterdt.isValid()) { m_todos = m_calendar->rawTodos(m_filterdt,m_filterdt); } - if (m_calendar != nullptr && !(filtered())) { + if (m_calendar != nullptr && m_filterdt.isNull()) { m_todos = m_calendar->rawTodos(); } endResetModel(); } - -void TodosModel::setFiltered(bool hasFilter) -{ - m_filtered = hasFilter; - emit filteredChanged(); -} - -bool TodosModel::filtered() const -{ - return m_filtered; -} diff --git a/src/plugins/todosmodel.h b/src/plugins/todosmodel.h index 2f9145a2423e511609bc6bb25d2098b9abaa5814..13d1830a6e35355a7f7c044fb1228df32e454e52 100644 --- a/src/plugins/todosmodel.h +++ b/src/plugins/todosmodel.h @@ -31,7 +31,6 @@ 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 READ memorycalendar WRITE setMemorycalendar NOTIFY memorycalendarChanged ) Q_PROPERTY(int count READ rowCount NOTIFY rowsChanged) @@ -61,9 +60,6 @@ public: QDate filterdt() const; void setFilterdt(QDate filterDate); - bool filtered() const; - void setFiltered(bool hasFilter); - QHash roleNames() const override; public Q_SLOTS: @@ -73,7 +69,6 @@ Q_SIGNALS: void rowsChanged(); void memorycalendarChanged(); void filterdtChanged(); - void filteredChanged(); private: