Commit e7595dfc authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Fixed task view placeholder messages

parent 88281cfb
Pipeline #93350 canceled with stage
......@@ -368,6 +368,7 @@ CalendarManager::CalendarManager(QObject *parent)
m_calendar = QSharedPointer<Akonadi::ETMCalendar>::create(); // QSharedPointer
setCollectionSelectionProxyModel(m_calendar->checkableProxyModel());
connect(m_calendar->checkableProxyModel(), &KCheckableProxyModel::dataChanged, this, &CalendarManager::refreshEnabledTodoCollections);
m_changer = m_calendar->incidenceChanger();
m_changer->setHistoryEnabled(true);
......@@ -480,6 +481,24 @@ QAbstractItemModel *CalendarManager::viewCollections()
return m_viewCollectionModel;
}
QVector<qint64> CalendarManager::enabledTodoCollections()
{
return m_enabledTodoCollections;
}
void CalendarManager::refreshEnabledTodoCollections()
{
m_enabledTodoCollections.clear();
for (auto selectedIndex : m_calendar->checkableProxyModel()->selectionModel()->selectedIndexes()) {
auto collection = selectedIndex.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
if (collection.contentMimeTypes().contains(QStringLiteral("application/x-vnd.akonadi.calendar.todo"))) {
m_enabledTodoCollections.append(collection.id());
}
}
Q_EMIT enabledTodoCollectionsChanged();
}
bool CalendarManager::loading() const
{
return !m_calendar->isLoaded();
......
......@@ -42,6 +42,7 @@ class CalendarManager : public QObject
Q_PROPERTY(QAbstractProxyModel *collections READ collections CONSTANT)
Q_PROPERTY(QAbstractItemModel *todoCollections READ todoCollections CONSTANT)
Q_PROPERTY(QAbstractItemModel *viewCollections READ viewCollections CONSTANT)
Q_PROPERTY(QVector<qint64> enabledTodoCollections READ enabledTodoCollections NOTIFY enabledTodoCollectionsChanged)
Q_PROPERTY(KDescendantsProxyModel *allCalendars READ allCalendars CONSTANT)
Q_PROPERTY(Akonadi::EntityRightsFilterModel *selectableEventCalendars READ selectableEventCalendars CONSTANT)
Q_PROPERTY(Akonadi::EntityRightsFilterModel *selectableTodoCalendars READ selectableTodoCalendars CONSTANT)
......@@ -60,6 +61,9 @@ public:
QAbstractProxyModel *collections();
QAbstractItemModel *todoCollections();
QAbstractItemModel *viewCollections();
QVector<qint64> enabledTodoCollections();
void refreshEnabledTodoCollections();
Q_INVOKABLE void save();
Akonadi::ETMCalendar *calendar() const;
Akonadi::IncidenceChanger *incidenceChanger() const;
......@@ -89,6 +93,7 @@ Q_SIGNALS:
void entityTreeModelChanged();
void undoRedoDataChanged();
void incidenceChanged();
void enabledTodoCollectionsChanged();
private:
Akonadi::ETMCalendar::Ptr m_calendar = nullptr;
......@@ -104,4 +109,5 @@ private:
Akonadi::EntityRightsFilterModel *m_todoRightsFilterModel = nullptr;
Akonadi::CollectionFilterProxyModel *m_todoViewCollectionModel = nullptr;
Akonadi::CollectionFilterProxyModel *m_viewCollectionModel = nullptr;
QVector<qint64> m_enabledTodoCollections;
};
......@@ -47,8 +47,23 @@ TreeListView {
}
Kirigami.PlaceholderMessage {
id: allTasksPlaceholderMessage
anchors.centerIn: parent
visible: root.filter && root.filter.collectionId >= 0 && root.filterCollectionDetails.isFiltered && parent.count === 0
visible: (!root.filter || !root.filter.collectionId || root.filter.collectionId < 0) && Kalendar.CalendarManager.enabledTodoCollections.length === 0 && parent.count === 0
onVisibleChanged: console.log(root.filter, root.filter.collectionId)
text: i18n("No task calendars enabled.")
helpfulAction: Kirigami.Action {
icon.name: "gtk-yes"
text: i18n("Enable all")
onTriggered: Kalendar.CalendarManager.allCalendars.setData(Kalendar.CalendarManager.allCalendars.index(root.filterCollectionDetails.allCalendarsRow, 0), 2, 10)
// HACK: Last two numbers are Qt.Checked and Qt.CheckStateRole
}
}
Kirigami.PlaceholderMessage {
id: collectionPlaceholderMessage
anchors.centerIn: parent
visible: root.filter && root.filter.collectionId >= 0 && !Kalendar.CalendarManager.enabledTodoCollections.includes(root.filter.collectionId) && parent.count === 0
text: i18n("Calendar is not enabled")
helpfulAction: Kirigami.Action {
icon.name: "gtk-yes"
......@@ -60,7 +75,7 @@ TreeListView {
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
visible: parent.count === 0 && root.filterCollectionDetails && !root.filterCollectionDetails.isFiltered
visible: parent.count === 0 && !allTasksPlaceholderMessage.visible && !collectionPlaceholderMessage.visible
text: root.showCompleted === Kalendar.TodoSortFilterProxyModel.ShowCompleteOnly ?
i18n("No tasks completed") : i18n("No tasks left to complete")
helpfulAction: Kirigami.Action {
......
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