]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/gui/eventdialog.cpp
Bump copyright years.
[toast/confclerk.git] / src / gui / eventdialog.cpp
index dce05bf88938e2282d18fb094495ce1238cfda34..20a4da4f1f57729e58f352b00d0fcecb3c3f3efd 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011-2015 Philipp Spitzer, gregor herrmann, Stefan Stahl
+ * Copyright (C) 2011-2024 Philipp Spitzer, gregor herrmann, Stefan Stahl
  *
  * This file is part of ConfClerk.
  *
 #include "appsettings.h"
 #endif
 
+QString toHtmlEscaped(const QString& string) {
+#if QT_VERSION >= 0x050000
+    return string.toHtmlEscaped();
+#else
+    return Qt::escape(string);
+#endif
+}
+
 EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) {
     setupUi(this);
 
@@ -38,12 +46,12 @@ EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialo
 
     QString info;
     // title
-    info.append(QString("<h1>%1</h1>\n").arg(Qt::escape(event.title())));
+    info.append(QString("<h1>%1</h1>\n").arg(toHtmlEscaped(event.title())));
 
     // persons
     info += QString("<h2>%1</h2>\n").arg(tr("Persons"));
     QStringList persons = event.persons();
-    for (int i = 0; i != persons.size(); ++i) persons[i] = Qt::escape(persons[i]);
+    for (int i = 0; i != persons.size(); ++i) persons[i] = toHtmlEscaped(persons[i]);
     info += QString("<p>%1</p>\n").arg(persons.join(", "));
 
     // abstract
@@ -59,7 +67,10 @@ EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialo
     if (Qt::mightBeRichText(event.description())) {
         info += event.description();
     } else {
-        info += Qt::convertFromPlainText(event.description(), Qt::WhiteSpaceNormal);
+        QString description = Qt::convertFromPlainText(event.description(), Qt::WhiteSpaceNormal);
+        // make links clickable
+        QRegExp rx("<?(((s?ftp|https?|svn|svn\\+ssh|git|git\\+ssh)://|(file|news):|www\\.)[-a-z0-9_.:%]*[a-z0-9](/[^][{}\\s\"<>()]*[^][{}\\s\"<>().,:!])?/?)>?");
+        info += description.replace(rx, "<a href=\"\\1\">\\1</a>");
     }
 
     // links
@@ -71,7 +82,7 @@ EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialo
         QString name(i.key());
         if (url.isEmpty() || url == "http://") continue;
         if (name.isEmpty()) name = url;
-        info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(Qt::escape(url), Qt::escape(name));
+        info += QString("<li><a href=\"%1\">%2</a></li>\n").arg(toHtmlEscaped(url), toHtmlEscaped(name));
     }
     info += QString("</ul>\n");
     eventInfoTextBrowser->setHtml(info);
@@ -149,9 +160,9 @@ void EventDialog::alarmClicked()
 
 void EventDialog::updateFavouriteButton(const Event& event) {
     switch (event.favourite()) {
-        case Favourite_no: favouriteButton->setIcon(QIcon(":/icons/favourite-off.png")); break;
+        case Favourite_no: favouriteButton->setIcon(QIcon(":/icons/favourite-no.png")); break;
         case Favourite_weak: favouriteButton->setIcon(QIcon(":/icons/favourite-weak.png")); break;
-        case Favourite_strong: favouriteButton->setIcon(QIcon(":/icons/favourite-on.png")); break;
+        case Favourite_strong: favouriteButton->setIcon(QIcon(":/icons/favourite-strong.png")); break;
     }
 }