[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:19:38 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=0d7162e

The following commit has been merged in the master branch:
commit 0d7162e4cced7eacfc7ac94c82c3e5c3a569356f
Author: Alex Richardson <alex.richardson at gmx.de>
Date:   Wed Jul 20 22:32:46 2011 +0200

    Improve link highlighting in AdiumThemeView
    
    Additionally highlight links that don't start with "<protocol>://", but
    also links that start with "www.". Regular expression was updated to
    use [^\s] instead of listing all whitespace characters explicitly.
    
    REVIEW: 102024
---
 lib/adium-theme-view.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/adium-theme-view.cpp b/lib/adium-theme-view.cpp
index 9de0d65..0eb1090 100644
--- a/lib/adium-theme-view.cpp
+++ b/lib/adium-theme-view.cpp
@@ -393,17 +393,21 @@ QString AdiumThemeView::replaceMessageKeywords(QString &htmlTemplate, const Adiu
     htmlTemplate.replace("%message%", m_emoticons.theme().parseEmoticons(info.message()));
 
     // link detection
-    QRegExp linkRegExp("\b(\w+)://[^ 	



]+");
+    QRegExp linkRegExp("\b(?:(\w+)://|(www\.))([^\s]+)");
     int index = 0;
 
     while ((index = linkRegExp.indexIn(htmlTemplate, index)) != -1) {
         QString realUrl = linkRegExp.cap(0);
         QString protocol = linkRegExp.cap(1);
 
-        kDebug() << "Found URL " << realUrl << "with protocol : " << protocol;
+        //if cap(1) is empty cap(2) was matched -> starts with www.
+        const bool startsWithWWW = linkRegExp.cap(1).isEmpty();
+
+        kDebug() << "Found URL " << realUrl << "with protocol : " << (startsWithWWW ? QLatin1String("http") : protocol);
+
 
         // if url has a supported protocol
-        if (KProtocolInfo::protocols().contains(protocol, Qt::CaseInsensitive)) {
+        if (startsWithWWW || KProtocolInfo::protocols().contains(protocol, Qt::CaseInsensitive)) {
 
             // text not wanted in a link ( <,> )
             QRegExp unwanted("(<|>)");
@@ -420,14 +424,13 @@ QString AdiumThemeView::replaceMessageKeywords(QString &htmlTemplate, const Adiu
                 }
 
                 // check prefix
-                if (realUrl.startsWith("www")) {
+                if (startsWithWWW) {
                     realUrl.prepend("http://");
                 }
 
                 // if the url is changed, show in chat what the user typed in
                 QString link = "<a href='" + realUrl + "'>" + shownUrl + "</a>";
                 htmlTemplate.replace(index, shownUrl.length(), link);
-
                 // advance position otherwise I end up parsing the same link
                 index += link.length();
             } else {

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list