Commit b427def6 authored by Claudio Cambra's avatar Claudio Cambra Committed by Carl Schwan
Browse files

Fix the 'Enable calendar' button in the task view



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@gmail.com>
parent 50efb25c
Pipeline #184419 passed with stage
in 3 minutes and 8 seconds
......@@ -820,6 +820,21 @@ void CalendarManager::editCollection(qint64 collectionId)
dlg->show();
}
void CalendarManager::toggleCollection(qint64 collectionId)
{
const auto matches = m_calendar->checkableProxyModel()->match(m_calendar->checkableProxyModel()->index(0, 0),
Akonadi::EntityTreeModel::CollectionIdRole,
collectionId,
1,
Qt::MatchExactly | Qt::MatchWrap | Qt::MatchRecursive);
if (matches.count() > 0) {
const auto collectionIndex = matches.first();
const auto collectionChecked = collectionIndex.data(Qt::CheckStateRole).toInt() == Qt::Checked;
const auto checkStateToSet = collectionChecked ? Qt::Unchecked : Qt::Checked;
m_calendar->checkableProxyModel()->setData(collectionIndex, checkStateToSet, Qt::CheckStateRole);
}
}
#ifndef UNITY_CMAKE_SUPPORT
Q_DECLARE_METATYPE(KCalendarCore::Incidence::Ptr)
#endif
......
......@@ -97,6 +97,7 @@ public:
Q_INVOKABLE void updateCollection(qint64 collectionId);
Q_INVOKABLE void deleteCollection(qint64 collectionId);
Q_INVOKABLE void editCollection(qint64 collectionId);
Q_INVOKABLE void toggleCollection(qint64 collectionId);
private Q_SLOTS:
void delayedInit();
......
......@@ -96,8 +96,7 @@ TreeListView {
helpfulAction: Kirigami.Action {
icon.name: "gtk-yes"
text: i18n("Enable")
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
onTriggered: Kalendar.CalendarManager.toggleCollection(root.filterCollectionDetails.id)
}
}
......
Supports Markdown
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