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 {
}
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"));
......
......@@ -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
}
......
......@@ -162,3 +162,9 @@ void LocalCalendar::deleteCalendar()
calendarFile.remove();
}
}
QDateTime LocalCalendar::nulldate() const
{
return QDateTime();
}
......@@ -30,32 +30,33 @@ class LocalCalendar : public QObject
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
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:
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;
......
......@@ -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;
}
......@@ -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> 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<int, QByteArray> roleNames() const override;
public Q_SLOTS:
......@@ -73,7 +69,6 @@ Q_SIGNALS:
void rowsChanged();
void memorycalendarChanged();
void filterdtChanged();
void filteredChanged();
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