Format url links in event descriptions making them clickable

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>
pull/141/head
Calvin Morrison 4 days ago committed by Michele Calgaro
parent c9f69ee6df
commit 8c92599470
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -575,9 +575,22 @@ static TQString displayViewFormatEvent( Calendar *calendar, Event *event,
} }
if ( !event->description().isEmpty() ) { 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 += "<tr>";
tmpStr += "<td><b>" + i18n( "Description:" ) + "</b></td>"; tmpStr += "<td><b>" + i18n( "Description:" ) + "</b></td>";
tmpStr += "<td>" + event->description() + "</td>"; tmpStr += "<td>" + description + "</td>";
tmpStr += "</tr>"; tmpStr += "</tr>";
} }

Loading…
Cancel
Save