Commit 05b294b4 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Better handling of null dates. Show calendar name in global "Show>Tasks" action.

parent d1c32570
Pipeline #2190 failed with stage
in 12 minutes and 28 seconds
...@@ -72,11 +72,11 @@ Kirigami.ApplicationWindow { ...@@ -72,11 +72,11 @@ Kirigami.ApplicationWindow {
} }
Kirigami.Action { Kirigami.Action {
text: "Tasks" text: "Tasks" + " (" + localCalendar.name + ")"
iconName: "view-calendar-tasks" iconName: "view-calendar-tasks"
onTriggered: { onTriggered: {
pageStack.clear(); pageStack.clear();
pageStack.push(todosView, {filtered: false, todoDt: null}); pageStack.push(todosView, { todoDt: localCalendar.nulldate });
} }
} }
} }
...@@ -162,7 +162,7 @@ Kirigami.ApplicationWindow { ...@@ -162,7 +162,7 @@ Kirigami.ApplicationWindow {
onTriggered: { onTriggered: {
if(localCalendar.todosCount(calendarMonthView.selectedDate) > 0) { if(localCalendar.todosCount(calendarMonthView.selectedDate) > 0) {
root.pageStack.push(todosView, { filtered: true, todoDt: calendarMonthView.selectedDate }); root.pageStack.push(todosView, { todoDt: calendarMonthView.selectedDate });
} }
else { else {
showPassiveNotification (i18n("There is no task for the day selected")); showPassiveNotification (i18n("There is no task for the day selected"));
......
...@@ -26,9 +26,8 @@ import org.kde.phone.calindori 0.1 as Calindori ...@@ -26,9 +26,8 @@ import org.kde.phone.calindori 0.1 as Calindori
Kirigami.Page { Kirigami.Page {
id: root id: root
property var todoDt property date todoDt
property var calendar property var calendar
property bool filtered
signal editTask(var modelData) signal editTask(var modelData)
signal tasksUpdated signal tasksUpdated
...@@ -43,7 +42,7 @@ Kirigami.Page { ...@@ -43,7 +42,7 @@ Kirigami.Page {
actions.main: Kirigami.Action { actions.main: Kirigami.Action {
icon.name: "resource-calendar-insert" icon.name: "resource-calendar-insert"
text: qsTr("Add task") text: qsTr("Add task")
onTriggered: pageStack.push(todoPage, { startdt: todoDt} ) onTriggered: pageStack.push(todoPage, {startdt: todoDt})
} }
...@@ -64,8 +63,7 @@ Kirigami.Page { ...@@ -64,8 +63,7 @@ Kirigami.Page {
anchors.fill: parent anchors.fill: parent
model: Calindori.TodosModel { model: Calindori.TodosModel {
filtered: root.filtered filterdt: root.todoDt
filterdt: root.todoDt != null && !isNaN(root.todoDt) ? root.todoDt : new Date("No Date")
memorycalendar: root.calendar.memorycalendar memorycalendar: root.calendar.memorycalendar
} }
......
...@@ -162,3 +162,9 @@ void LocalCalendar::deleteCalendar() ...@@ -162,3 +162,9 @@ void LocalCalendar::deleteCalendar()
calendarFile.remove(); calendarFile.remove();
} }
} }
QDateTime LocalCalendar::nulldate() const
{
return QDateTime();
}
...@@ -30,32 +30,33 @@ class LocalCalendar : public QObject ...@@ -30,32 +30,33 @@ class LocalCalendar : public QObject
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QSharedPointer<MemoryCalendar> memorycalendar READ memorycalendar WRITE setMemorycalendar NOTIFY memorycalendarChanged) Q_PROPERTY(QSharedPointer<MemoryCalendar> memorycalendar READ memorycalendar WRITE setMemorycalendar NOTIFY memorycalendarChanged)
Q_PROPERTY(QSharedPointer<FileStorage> calendarstorage READ calendarstorage WRITE setCalendarstorage NOTIFY calendarstorageChanged) Q_PROPERTY(QSharedPointer<FileStorage> calendarstorage READ calendarstorage WRITE setCalendarstorage NOTIFY calendarstorageChanged)
Q_PROPERTY(QDateTime nulldate READ nulldate CONSTANT)
public: public:
explicit LocalCalendar(QObject* parent = nullptr); explicit LocalCalendar(QObject* parent = nullptr);
~LocalCalendar() override; ~LocalCalendar() override;
MemoryCalendar::Ptr memorycalendar() const; MemoryCalendar::Ptr memorycalendar() const;
FileStorage::Ptr calendarstorage() const; FileStorage::Ptr calendarstorage() const;
QString name() const; QString name() const;
QDateTime nulldate() const;
void setMemorycalendar(MemoryCalendar::Ptr memoryCalendar); void setMemorycalendar(MemoryCalendar::Ptr memoryCalendar);
void setCalendarstorage(FileStorage::Ptr calendarStorage); void setCalendarstorage(FileStorage::Ptr calendarStorage);
void setName(QString calendarName); void setName(QString calendarName);
public Q_SLOTS: public Q_SLOTS:
void addEditTask(QString uid, QDate startDate, QString summary, QString description, int startHour, int startMinute, bool allDayFlg, QString location); 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; int todosCount(const QDate &date) const;
void deleteCalendar(); void deleteCalendar();
Q_SIGNALS: Q_SIGNALS:
void memorycalendarChanged(); void memorycalendarChanged();
void calendarstorageChanged(); void calendarstorageChanged();
void nameChanged(); void nameChanged();
private: private:
MemoryCalendar::Ptr m_calendar; MemoryCalendar::Ptr m_calendar;
FileStorage::Ptr m_cal_storage; FileStorage::Ptr m_cal_storage;
......
...@@ -26,7 +26,6 @@ TodosModel::TodosModel(QObject* parent) ...@@ -26,7 +26,6 @@ TodosModel::TodosModel(QObject* parent)
{ {
connect(this, &TodosModel::memorycalendarChanged, this, &TodosModel::loadTasks); connect(this, &TodosModel::memorycalendarChanged, this, &TodosModel::loadTasks);
connect(this, &TodosModel::filterdtChanged, this, &TodosModel::loadTasks); connect(this, &TodosModel::filterdtChanged, this, &TodosModel::loadTasks);
connect(this, &TodosModel::filteredChanged, this, &TodosModel::loadTasks);
} }
TodosModel::~TodosModel() = default; TodosModel::~TodosModel() = default;
...@@ -101,10 +100,8 @@ QDate TodosModel::filterdt() const ...@@ -101,10 +100,8 @@ QDate TodosModel::filterdt() const
void TodosModel::setFilterdt(QDate filterDate) void TodosModel::setFilterdt(QDate filterDate)
{ {
if (filterDate.isValid()) { m_filterdt = filterDate;
m_filterdt = filterDate; emit filterdtChanged();
emit filterdtChanged();
}
} }
int TodosModel::rowCount(const QModelIndex& parent) const int TodosModel::rowCount(const QModelIndex& parent) const
...@@ -118,22 +115,11 @@ void TodosModel::loadTasks() ...@@ -118,22 +115,11 @@ void TodosModel::loadTasks()
{ {
beginResetModel(); beginResetModel();
m_todos.clear(); 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); 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(); m_todos = m_calendar->rawTodos();
} }
endResetModel(); endResetModel();
} }
void TodosModel::setFiltered(bool hasFilter)
{
m_filtered = hasFilter;
emit filteredChanged();
}
bool TodosModel::filtered() const
{
return m_filtered;
}
...@@ -31,7 +31,6 @@ class TodosModel : public QAbstractListModel ...@@ -31,7 +31,6 @@ class TodosModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool filtered READ filtered WRITE setFiltered NOTIFY filteredChanged)
Q_PROPERTY(QDate filterdt READ filterdt WRITE setFilterdt NOTIFY filterdtChanged) Q_PROPERTY(QDate filterdt READ filterdt WRITE setFilterdt NOTIFY filterdtChanged)
Q_PROPERTY(QSharedPointer<MemoryCalendar> memorycalendar READ memorycalendar WRITE setMemorycalendar NOTIFY memorycalendarChanged ) Q_PROPERTY(QSharedPointer<MemoryCalendar> memorycalendar READ memorycalendar WRITE setMemorycalendar NOTIFY memorycalendarChanged )
Q_PROPERTY(int count READ rowCount NOTIFY rowsChanged) Q_PROPERTY(int count READ rowCount NOTIFY rowsChanged)
...@@ -61,9 +60,6 @@ public: ...@@ -61,9 +60,6 @@ public:
QDate filterdt() const; QDate filterdt() const;
void setFilterdt(QDate filterDate); void setFilterdt(QDate filterDate);
bool filtered() const;
void setFiltered(bool hasFilter);
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
public Q_SLOTS: public Q_SLOTS:
...@@ -73,7 +69,6 @@ Q_SIGNALS: ...@@ -73,7 +69,6 @@ Q_SIGNALS:
void rowsChanged(); void rowsChanged();
void memorycalendarChanged(); void memorycalendarChanged();
void filterdtChanged(); void filterdtChanged();
void filteredChanged();
private: private:
......
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