Commit b35912e5 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make in private class

parent fcf95d7a
......@@ -37,113 +37,141 @@
using namespace MessageViewer;
class MessageViewer::WebHitTestResultPrivate
{
public:
WebHitTestResultPrivate(const QPoint &pos, const QUrl &url, const QVariant &result)
: m_isNull(true),
m_isContentEditable(false),
m_isContentSelected(false),
m_mediaPaused(false),
m_mediaMuted(false),
m_pos(pos),
m_pageUrl(url)
{
init(result.toMap());
}
void init(const QVariantMap &map);
bool m_isNull;
QString m_alternateText;
QRect m_boundingRect;
QUrl m_imageUrl;
bool m_isContentEditable;
bool m_isContentSelected;
QString m_linkTitle;
QUrl m_linkUrl;
QUrl m_mediaUrl;
bool m_mediaPaused;
bool m_mediaMuted;
QPoint m_pos;
QString m_tagName;
QUrl m_pageUrl;
};
void WebHitTestResultPrivate::init(const QVariantMap &map)
{
if (map.isEmpty()) {
return;
}
//qDebug()<<" void WebHitTestResult::init(const QVariantMap &map)"<<map;
m_alternateText = map.value(QStringLiteral("alternateText")).toString();
m_imageUrl = map.value(QStringLiteral("imageUrl")).toUrl();
m_isContentEditable = map.value(QStringLiteral("contentEditable")).toBool();
m_isContentSelected = map.value(QStringLiteral("contentSelected")).toBool();
m_linkTitle = map.value(QStringLiteral("linkTitle")).toString();
m_linkUrl = map.value(QStringLiteral("linkUrl")).toUrl();
m_mediaUrl = map.value(QStringLiteral("mediaUrl")).toUrl();
m_mediaPaused = map.value(QStringLiteral("mediaPaused")).toBool();
m_mediaMuted = map.value(QStringLiteral("mediaMuted")).toBool();
m_tagName = map.value(QStringLiteral("tagName")).toString();
const QVariantList &rect = map.value(QStringLiteral("boundingRect")).toList();
if (rect.size() == 4) {
m_boundingRect = QRect(rect.at(0).toInt(), rect.at(1).toInt(), rect.at(2).toInt(), rect.at(3).toInt());
}
if (!m_imageUrl.isEmpty()) {
m_imageUrl = m_pageUrl.resolved(m_imageUrl);
}
if (!m_linkUrl.isEmpty()) {
m_linkUrl = m_pageUrl.resolved(m_linkUrl);
}
if (!m_mediaUrl.isEmpty()) {
m_mediaUrl = m_pageUrl.resolved(m_mediaUrl);
}
}
WebHitTestResult::WebHitTestResult(const QPoint &pos, const QUrl &url, const QVariant &result)
: m_isNull(true),
m_isContentEditable(false),
m_isContentSelected(false),
m_mediaPaused(false),
m_mediaMuted(false),
m_pos(pos),
m_pageUrl(url)
: d(new WebHitTestResultPrivate(pos, url, result))
{
init(result.toMap());
}
WebHitTestResult::~WebHitTestResult()
{
delete d;
}
QString WebHitTestResult::alternateText() const
{
return m_alternateText;
return d->m_alternateText;
}
QRect WebHitTestResult::boundingRect() const
{
return m_boundingRect;
return d->m_boundingRect;
}
QUrl WebHitTestResult::imageUrl() const
{
return m_imageUrl;
return d->m_imageUrl;
}
bool WebHitTestResult::isContentEditable() const
{
return m_isContentEditable;
return d->m_isContentEditable;
}
bool WebHitTestResult::isContentSelected() const
{
return m_isContentSelected;
return d->m_isContentSelected;
}
bool WebHitTestResult::isNull() const
{
return m_isNull;
return d->m_isNull;
}
QString WebHitTestResult::linkTitle() const
{
return m_linkTitle;
return d->m_linkTitle;
}
QUrl WebHitTestResult::linkUrl() const
{
return m_linkUrl;
return d->m_linkUrl;
}
QUrl WebHitTestResult::mediaUrl() const
{
return m_mediaUrl;
return d->m_mediaUrl;
}
bool WebHitTestResult::mediaPaused() const
{
return m_mediaPaused;
return d->m_mediaPaused;
}
bool WebHitTestResult::mediaMuted() const
{
return m_mediaMuted;
return d->m_mediaMuted;
}
QPoint WebHitTestResult::pos() const
{
return m_pos;
return d->m_pos;
}
QString WebHitTestResult::tagName() const
{
return m_tagName;
}
void WebHitTestResult::init(const QVariantMap &map)
{
if (map.isEmpty()) {
return;
}
//qDebug()<<" void WebHitTestResult::init(const QVariantMap &map)"<<map;
m_alternateText = map.value(QStringLiteral("alternateText")).toString();
m_imageUrl = map.value(QStringLiteral("imageUrl")).toUrl();
m_isContentEditable = map.value(QStringLiteral("contentEditable")).toBool();
m_isContentSelected = map.value(QStringLiteral("contentSelected")).toBool();
m_linkTitle = map.value(QStringLiteral("linkTitle")).toString();
m_linkUrl = map.value(QStringLiteral("linkUrl")).toUrl();
m_mediaUrl = map.value(QStringLiteral("mediaUrl")).toUrl();
m_mediaPaused = map.value(QStringLiteral("mediaPaused")).toBool();
m_mediaMuted = map.value(QStringLiteral("mediaMuted")).toBool();
m_tagName = map.value(QStringLiteral("tagName")).toString();
const QVariantList &rect = map.value(QStringLiteral("boundingRect")).toList();
if (rect.size() == 4) {
m_boundingRect = QRect(rect.at(0).toInt(), rect.at(1).toInt(), rect.at(2).toInt(), rect.at(3).toInt());
}
if (!m_imageUrl.isEmpty()) {
m_imageUrl = m_pageUrl.resolved(m_imageUrl);
}
if (!m_linkUrl.isEmpty()) {
m_linkUrl = m_pageUrl.resolved(m_linkUrl);
}
if (!m_mediaUrl.isEmpty()) {
m_mediaUrl = m_pageUrl.resolved(m_mediaUrl);
}
return d->m_tagName;
}
......@@ -43,10 +43,12 @@
namespace MessageViewer
{
class WebHitTestResultPrivate;
class MESSAGEVIEWER_EXPORT WebHitTestResult
{
public:
WebHitTestResult(const QPoint &pos, const QUrl &url, const QVariant &result);
~WebHitTestResult();
QString alternateText() const;
QRect boundingRect() const;
......@@ -63,23 +65,7 @@ public:
QString tagName() const;
private:
void init(const QVariantMap &map);
bool m_isNull;
QString m_alternateText;
QRect m_boundingRect;
QUrl m_imageUrl;
bool m_isContentEditable;
bool m_isContentSelected;
QString m_linkTitle;
QUrl m_linkUrl;
QUrl m_mediaUrl;
bool m_mediaPaused;
bool m_mediaMuted;
QPoint m_pos;
QString m_tagName;
QUrl m_pageUrl;
WebHitTestResultPrivate *const d;
};
}
#endif // WEBHITTESTRESULT_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment