[pim/korganizer] src/kontactplugin: kontactplugin summaries - use KUrlLabel::setStatusTip()
Allen Winter <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 5edbec4bc31befd9f5e0c46e0c6acb64424bbeac by Allen Winter.
Committed on 25/07/2026 at 16:27.
Pushed by winterz into branch 'master'.
kontactplugin summaries - use KUrlLabel::setStatusTip()
Remove EventFilter in favor of KUrlLabel::setStatusTip().
M +5 -18 src/kontactplugin/korganizer/apptsummarywidget.cpp
M +0 -3 src/kontactplugin/korganizer/apptsummarywidget.h
M +8 -2 src/kontactplugin/korganizer/summaryeventinfo.cpp
M +2 -1 src/kontactplugin/korganizer/summaryeventinfo.h
M +7 -15 src/kontactplugin/korganizer/todosummarywidget.cpp
M +0 -3 src/kontactplugin/korganizer/todosummarywidget.h
M +1 -16 src/kontactplugin/specialdates/sdsummarywidget.cpp
M +0 -3 src/kontactplugin/specialdates/sdsummarywidget.h
https://invent.kde.org/pim/korganizer/-/commit/5edbec4bc31befd9f5e0c46e0c6acb64424bbeac
diff --git a/src/kontactplugin/korganizer/apptsummarywidget.cpp b/src/kontactplugin/korganizer/apptsummarywidget.cpp
index 3abbfb732..3e35e9a59 100644
--- a/src/kontactplugin/korganizer/apptsummarywidget.cpp
+++ b/src/kontactplugin/korganizer/apptsummarywidget.cpp
@@ -166,7 +166,6 @@ void ApptSummaryWidget::updateView()
auto urlLabel = new KUrlLabel(this);
urlLabel->setText(event->summaryText);
urlLabel->setUrl(event->summaryUrl);
- urlLabel->installEventFilter(this);
urlLabel->setTextFormat(Qt::RichText);
urlLabel->setWordWrap(true);
mLayout->addWidget(urlLabel, counter, 3);
@@ -177,8 +176,11 @@ void ApptSummaryWidget::updateView()
connect(urlLabel, &KUrlLabel::rightClickedUrl, this, [this, urlLabel] {
popupMenu(urlLabel->url());
});
- if (!event->summaryTooltip.isEmpty()) {
- urlLabel->setToolTip(event->summaryTooltip);
+ if (!event->summaryToolTip.isEmpty()) {
+ urlLabel->setToolTip(event->summaryToolTip);
+ }
+ if (!event->summaryStatusTip.isEmpty()) {
+ urlLabel->setStatusTip(event->summaryStatusTip);
}
// Time range label (only for non-floating events)
@@ -262,19 +264,4 @@ void ApptSummaryWidget::popupMenu(const QString &uid)
}
}
-bool ApptSummaryWidget::eventFilter(QObject *obj, QEvent *e)
-{
- if (obj->inherits("KUrlLabel")) {
- auto label = static_cast<KUrlLabel *>(obj);
- if (e->type() == QEvent::Enter) {
- Q_EMIT message(i18nc("@info:status", "Edit Event: \"%1\"", label->text()));
- }
- if (e->type() == QEvent::Leave) {
- Q_EMIT message(QString());
- }
- }
-
- return KontactInterface::Summary::eventFilter(obj, e);
-}
-
#include "moc_apptsummarywidget.cpp"
diff --git a/src/kontactplugin/korganizer/apptsummarywidget.h b/src/kontactplugin/korganizer/apptsummarywidget.h
index 6728e21b9..3a35095d9 100644
--- a/src/kontactplugin/korganizer/apptsummarywidget.h
+++ b/src/kontactplugin/korganizer/apptsummarywidget.h
@@ -43,9 +43,6 @@ public:
updateView();
}
-protected:
- [[nodiscard]] bool eventFilter(QObject *obj, QEvent *e) override;
-
private Q_SLOTS:
void updateView();
void popupMenu(const QString &uid);
diff --git a/src/kontactplugin/korganizer/summaryeventinfo.cpp b/src/kontactplugin/korganizer/summaryeventinfo.cpp
index cf3860d28..550dec917 100644
--- a/src/kontactplugin/korganizer/summaryeventinfo.cpp
+++ b/src/kontactplugin/korganizer/summaryeventinfo.cpp
@@ -264,14 +264,20 @@ SummaryEventInfo::List SummaryEventInfo::eventsForRange(QDate start, QDate end,
QString displayName;
Akonadi::Item item = calendar->item(ev);
+ bool writeable = false;
if (item.isValid()) {
const Akonadi::Collection col = item.parentCollection();
if (col.isValid()) {
displayName = col.displayName();
}
+ writeable = calendar->hasRight(item, Akonadi::Collection::CanDeleteItem);
+ }
+ summaryEvent->summaryToolTip = KCalUtils::IncidenceFormatter::toolTipStr(displayName, ev, start, true);
+ if (writeable) {
+ summaryEvent->summaryStatusTip = i18nc("@info:status", "Edit Event: \"%1\"", ev->summary());
+ } else {
+ summaryEvent->summaryStatusTip = i18nc("@info:status", "Show Event: \"%1\"", ev->summary());
}
- summaryEvent->summaryTooltip = KCalUtils::IncidenceFormatter::toolTipStr(displayName, ev, start, true);
-
// Time range label (only for non-floating events)
str.clear();
if (!ev->allDay()) {
diff --git a/src/kontactplugin/korganizer/summaryeventinfo.h b/src/kontactplugin/korganizer/summaryeventinfo.h
index 8a15abdae..c07a95ef1 100644
--- a/src/kontactplugin/korganizer/summaryeventinfo.h
+++ b/src/kontactplugin/korganizer/summaryeventinfo.h
@@ -32,7 +32,8 @@ public:
QString timeRange;
QString summaryText;
QString summaryUrl;
- QString summaryTooltip;
+ QString summaryToolTip;
+ QString summaryStatusTip;
bool makeBold = false;
bool makeUrgent = false;
diff --git a/src/kontactplugin/korganizer/todosummarywidget.cpp b/src/kontactplugin/korganizer/todosummarywidget.cpp
index a8554c0bc..20c35f279 100644
--- a/src/kontactplugin/korganizer/todosummarywidget.cpp
+++ b/src/kontactplugin/korganizer/todosummarywidget.cpp
@@ -287,20 +287,26 @@ void TodoSummaryWidget::updateView()
QString displayName;
Akonadi::Item item = mCalendar->item(todo);
+ bool writeable = false;
if (item.isValid()) {
const Akonadi::Collection col = item.parentCollection();
if (col.isValid()) {
displayName = col.displayName();
}
+ writeable = mCalendar->hasRight(item, Akonadi::Collection::CanDeleteItem);
}
auto urlLabel = new KUrlLabel(this);
urlLabel->setText(str);
urlLabel->setUrl(todo->uid());
- urlLabel->installEventFilter(this);
urlLabel->setTextFormat(Qt::RichText);
urlLabel->setWordWrap(true);
urlLabel->setToolTip(KCalUtils::IncidenceFormatter::toolTipStr(displayName, todo, currDate, true));
+ if (writeable) {
+ urlLabel->setStatusTip(i18nc("@info:status", "Edit To-do: \"%1\"", todo->summary()));
+ } else {
+ urlLabel->setStatusTip(i18nc("@info:status", "Show To-do: \"%1\"", todo->summary()));
+ }
mLayout->addWidget(urlLabel, counter, 4);
mLabels.append(urlLabel);
connect(urlLabel, &KUrlLabel::leftClickedUrl, this, [this, urlLabel] {
@@ -411,20 +417,6 @@ void TodoSummaryWidget::popupMenu(const QString &uid)
}
}
-bool TodoSummaryWidget::eventFilter(QObject *obj, QEvent *e)
-{
- if (obj->inherits("KUrlLabel")) {
- auto label = static_cast<KUrlLabel *>(obj);
- if (e->type() == QEvent::Enter) {
- Q_EMIT message(i18nc("@info:status", "Edit To-do: \"%1\"", label->text()));
- }
- if (e->type() == QEvent::Leave) {
- Q_EMIT message(QString());
- }
- }
- return KontactInterface::Summary::eventFilter(obj, e);
-}
-
bool TodoSummaryWidget::startsToday(const KCalendarCore::Todo::Ptr &todo) const
{
return todo->hasStartDate() && todo->dtStart().date() == QDate::currentDate();
diff --git a/src/kontactplugin/korganizer/todosummarywidget.h b/src/kontactplugin/korganizer/todosummarywidget.h
index f04b62860..3f444b8de 100644
--- a/src/kontactplugin/korganizer/todosummarywidget.h
+++ b/src/kontactplugin/korganizer/todosummarywidget.h
@@ -46,9 +46,6 @@ public Q_SLOTS:
updateView();
}
-protected:
- bool eventFilter(QObject *obj, QEvent *e) override;
-
private Q_SLOTS:
void updateView();
void popupMenu(const QString &uid);
diff --git a/src/kontactplugin/specialdates/sdsummarywidget.cpp b/src/kontactplugin/specialdates/sdsummarywidget.cpp
index da50819cc..cf44ad8fb 100644
--- a/src/kontactplugin/specialdates/sdsummarywidget.cpp
+++ b/src/kontactplugin/specialdates/sdsummarywidget.cpp
@@ -539,11 +539,11 @@ void SDSummaryWidget::createLabels()
// Description
if ((*addrIt).type == IncidenceTypeContact) {
auto urlLabel = new KUrlLabel(this);
- urlLabel->installEventFilter(this);
urlLabel->setUrl((*addrIt).item.url(Akonadi::Item::UrlWithMimeType).url());
urlLabel->setText((*addrIt).addressee.realName());
urlLabel->setTextFormat(Qt::RichText);
urlLabel->setWordWrap(true);
+ urlLabel->setStatusTip(i18nc("@info:status", "Mail to:\"%1\"", urlLabel->text()));
mLayout->addWidget(urlLabel, counter, 4);
mLabels.append(urlLabel);
connect(urlLabel, &KUrlLabel::leftClickedUrl, this, [this, urlLabel] {
@@ -685,21 +685,6 @@ void SDSummaryWidget::popupMenu(const QString &url)
}
}
-bool SDSummaryWidget::eventFilter(QObject *obj, QEvent *e)
-{
- if (obj->inherits("KUrlLabel")) {
- auto label = static_cast<KUrlLabel *>(obj);
- if (e->type() == QEvent::Enter) {
- Q_EMIT message(i18nc("@info:status", "Mail to:\"%1\"", label->text()));
- }
- if (e->type() == QEvent::Leave) {
- Q_EMIT message(QString());
- }
- }
-
- return KontactInterface::Summary::eventFilter(obj, e);
-}
-
void SDSummaryWidget::dateDiff(const QDate &date, int &days, int &years) const
{
QDate currentDate;
diff --git a/src/kontactplugin/specialdates/sdsummarywidget.h b/src/kontactplugin/specialdates/sdsummarywidget.h
index c3ad4c9ea..99c0b13a3 100644
--- a/src/kontactplugin/specialdates/sdsummarywidget.h
+++ b/src/kontactplugin/specialdates/sdsummarywidget.h
@@ -45,9 +45,6 @@ public:
updateView();
}
-protected:
- bool eventFilter(QObject *obj, QEvent *e) override;
-
private:
void updateView();
void popupMenu(const QString &url);