insignifican fixes about urls parsing
This commit is contained in:
parent
ae3a1c97e3
commit
0c33d81c59
@ -289,7 +289,7 @@ void Core::NetworkAccess::onDownloadFinished()
|
|||||||
QStringList hops = url.split("/");
|
QStringList hops = url.split("/");
|
||||||
QString fileName = hops.back();
|
QString fileName = hops.back();
|
||||||
QStringList parts = fileName.split(".");
|
QStringList parts = fileName.split(".");
|
||||||
path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/";
|
||||||
QString suffix("");
|
QString suffix("");
|
||||||
QString realName = parts.front();
|
QString realName = parts.front();
|
||||||
for (QStringList::const_iterator sItr = (parts.begin()++), sEnd = parts.end(); sItr != sEnd; ++sItr) {
|
for (QStringList::const_iterator sItr = (parts.begin()++), sEnd = parts.end(); sItr != sEnd; ++sItr) {
|
||||||
|
@ -20,10 +20,11 @@
|
|||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
const QRegExp urlReg("(?!<img\\ssrc=\")((?:https?|ftp)://\\S+)");
|
const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])((?:https?|ftp)://\\S+)"); //finds all hypertext references which are not wrapped in a or img tags
|
||||||
const QRegExp imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
|
const QRegularExpression imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
|
||||||
|
|
||||||
Message::Message(const Shared::Message& source, bool outgoing, const QString& p_sender, QWidget* parent):
|
Message::Message(const Shared::Message& source, bool outgoing, const QString& p_sender, QWidget* parent):
|
||||||
QHBoxLayout(parent),
|
QHBoxLayout(parent),
|
||||||
@ -49,6 +50,7 @@ Message::Message(const Shared::Message& source, bool outgoing, const QString& p_
|
|||||||
QString bd = msg.getBody();
|
QString bd = msg.getBody();
|
||||||
//bd.replace(imgReg, "<img src=\"\\1\"/>");
|
//bd.replace(imgReg, "<img src=\"\\1\"/>");
|
||||||
bd.replace(urlReg, "<a href=\"\\1\">\\1</a>");
|
bd.replace(urlReg, "<a href=\"\\1\">\\1</a>");
|
||||||
|
text->setTextFormat(Qt::RichText);
|
||||||
text->setText(bd);;
|
text->setText(bd);;
|
||||||
text->setTextInteractionFlags(text->textInteractionFlags() | Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
text->setTextInteractionFlags(text->textInteractionFlags() | Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
||||||
text->setWordWrap(true);
|
text->setWordWrap(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user