[pim/korganizer] src/kontactplugin/korganizer: apptsummarywidget.cpp,todosummarywidget.cpp - improve menu for read-only

Allen Winter <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 89be2657c4b542b9d1ca3affc38517f4763051c3 by Allen Winter.
Committed on 25/07/2026 at 15:14.
Pushed by winterz into branch 'master'.

apptsummarywidget.cpp,todosummarywidget.cpp - improve menu for read-only

For read-only calendars the context menus say:
 - Show Appointment or Show To-do
 - disable Delete
 
For writeable calendars the context menus say:
 - Edit Appointment or Edit To-do
 - enable Delete

M  +16   -7    src/kontactplugin/korganizer/apptsummarywidget.cpp
M  +17   -8    src/kontactplugin/korganizer/todosummarywidget.cpp

https://invent.kde.org/pim/korganizer/-/commit/89be2657c4b542b9d1ca3affc38517f4763051c3

diff --git a/src/kontactplugin/korganizer/apptsummarywidget.cpp b/src/kontactplugin/korganizer/apptsummarywidget.cpp
index 309a815ee..3abbfb732 100644
--- a/src/kontactplugin/korganizer/apptsummarywidget.cpp
+++ b/src/kontactplugin/korganizer/apptsummarywidget.cpp
@@ -233,17 +233,26 @@ void ApptSummaryWidget::removeEvent(const Akonadi::Item &item)
 
 void ApptSummaryWidget::popupMenu(const QString &uid)
 {
+    const Akonadi::Item item = mCalendar->item(uid);
+    if (!item.isValid()) {
+        return;
+    }
+
     QMenu popup(this);
 
-    // FIXME: Should say "Show Appointment" if we don't have rights to edit
-    // Doesn't make sense to edit events from birthday resource for example
-    QAction *editIt = popup.addAction(i18nc("@action:inmenu", "&Edit Appointment…"));
-    editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
+    QAction *editIt;
+    const bool writeable = mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem);
+    if (writeable) {
+        editIt = popup.addAction(i18nc("@action:inmenu", "&Edit Appointment…"));
+        editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
+    } else {
+        editIt = popup.addAction(i18nc("@action:inmenu", "&Show Appointment…"));
+        editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-preview")));
+    }
+
     QAction *delIt = popup.addAction(i18nc("@action:inmenu", "&Delete Appointment"));
     delIt->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
-
-    const Akonadi::Item item = mCalendar->item(uid);
-    delIt->setEnabled(mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem));
+    delIt->setEnabled(writeable);
 
     const QAction *selectedAction = popup.exec(QCursor::pos());
     if (selectedAction == editIt) {
diff --git a/src/kontactplugin/korganizer/todosummarywidget.cpp b/src/kontactplugin/korganizer/todosummarywidget.cpp
index c8175bcc0..a8554c0bc 100644
--- a/src/kontactplugin/korganizer/todosummarywidget.cpp
+++ b/src/kontactplugin/korganizer/todosummarywidget.cpp
@@ -373,23 +373,32 @@ void TodoSummaryWidget::completeTodo(Akonadi::Item::Id id)
 
 void TodoSummaryWidget::popupMenu(const QString &uid)
 {
-    KCalendarCore::Todo::Ptr const todo = mCalendar->todo(uid);
-    if (!todo) {
+    const Akonadi::Item item = mCalendar->item(uid);
+    if (!item.isValid()) {
         return;
     }
-    Akonadi::Item const item = mCalendar->item(uid);
+
     QMenu popup(this);
-    QAction *editIt = popup.addAction(i18nc("@action:inmenu", "&Edit To-do…"));
-    editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
+
+    QAction *editIt;
+    const bool writeable = mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem);
+    if (writeable) {
+        editIt = popup.addAction(i18nc("@action:inmenu", "&Edit To-do…"));
+        editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
+    } else {
+        editIt = popup.addAction(i18nc("@action:inmenu", "&Show To-do…"));
+        editIt->setIcon(QIcon::fromTheme(QStringLiteral("document-preview")));
+    }
+
     QAction *delIt = popup.addAction(i18nc("@action:inmenu", "&Delete To-do"));
     delIt->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
-    delIt->setEnabled(mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem));
+    delIt->setEnabled(writeable);
 
     QAction *doneIt = nullptr;
-    if (!todo->isCompleted()) {
+    if (!mCalendar->todo(uid)->isCompleted()) {
         doneIt = popup.addAction(i18nc("@action:inmenu", "&Mark To-do Completed"));
         doneIt->setIcon(QIcon::fromTheme(QStringLiteral("task-complete")));
-        doneIt->setEnabled(mCalendar->hasRight(item, Akonadi::Collection::CanChangeItem));
+        doneIt->setEnabled(writeable);
     }
 
     const QAction *selectedAction = popup.exec(QCursor::pos());
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.