summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2024-11-18 13:22:20 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-11-18 13:22:20 +0900
commit8c9259947084d6e77a74d8eeb1504fe7cbd7626f (patch)
tree3f5939f77c3db26f1df6843b06326f958cab0e21
parentc9f69ee6df2571d13f7c72d03b2d96977ce54eb2 (diff)
downloadtdepim-feat/libkcal-clickable-event-links.tar.gz
tdepim-feat/libkcal-clickable-event-links.zip
Format url links in event descriptions making them clickablefeat/libkcal-clickable-event-links
This allows to click through links in events in description fields wherever the description field is displayed from libkcal. This is useful since links to virtual meetings are often attached in the description field in recent years Signed-off-by: Calvin Morrison <calvin@pobox.com> Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--libkcal/incidenceformatter.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/libkcal/incidenceformatter.cpp b/libkcal/incidenceformatter.cpp
index 785a681bd..887d000aa 100644
--- a/libkcal/incidenceformatter.cpp
+++ b/libkcal/incidenceformatter.cpp
@@ -575,9 +575,22 @@ static TQString displayViewFormatEvent( Calendar *calendar, Event *event,
}
if ( !event->description().isEmpty() ) {
+ TQString description = event->description();
+
+ // Regular expression to match URLs
+ TQRegExp urlRegex("https?://[^\\s]+");
+
+ int pos = 0;
+ while ((pos = urlRegex.search(description, pos)) != -1) {
+ TQString url = urlRegex.cap(0);
+ TQString link = "<a href=\"" + url + "\">" + url + "</a>";
+ description.replace(pos, url.length(), link);
+ pos += link.length();
+ }
+
tmpStr += "<tr>";
tmpStr += "<td><b>" + i18n( "Description:" ) + "</b></td>";
- tmpStr += "<td>" + event->description() + "</td>";
+ tmpStr += "<td>" + description + "</td>";
tmpStr += "</tr>";
}