Commit d79ca6ad authored by Laurent Montel's avatar Laurent Montel 😁

First step to rename it. It's not mail specific

parent 94eee144
......@@ -62,57 +62,57 @@ void TestWebEngineAccessKey::setHtml(const QString &html)
void TestWebEngineAccessKey::handleSearchAccessKey(const QVariant &var)
{
const QVariantList lst = var.toList();
QVector<MessageViewer::MailWebEngineAccessKeyAnchor> anchorList;
QVector<MessageViewer::WebEngineAccessKeyAnchor> anchorList;
anchorList.reserve(lst.count());
Q_FOREACH (const QVariant &anchor, lst) {
anchorList << MessageViewer::MailWebEngineAccessKeyAnchor(anchor);
anchorList << MessageViewer::WebEngineAccessKeyAnchor(anchor);
}
Q_EMIT accessKeySearchFinished(anchorList);
}
void TestWebEngineAccessKey::loadFinished(bool b)
{
mEngineView->page()->runJavaScript(MessageViewer::MailWebEngineAccessKeyUtils::script(), invoke(this, &TestWebEngineAccessKey::handleSearchAccessKey));
mEngineView->page()->runJavaScript(MessageViewer::WebEngineAccessKeyUtils::script(), invoke(this, &TestWebEngineAccessKey::handleSearchAccessKey));
}
Q_DECLARE_METATYPE(QVector<MessageViewer::MailWebEngineAccessKeyAnchor>)
Q_DECLARE_METATYPE(QVector<MessageViewer::WebEngineAccessKeyAnchor>)
MailWebEngineAccessKeyAnchorFromHtmlTest::MailWebEngineAccessKeyAnchorFromHtmlTest(QObject *parent)
: QObject(parent)
{
qRegisterMetaType<QVector<MessageViewer::MailWebEngineAccessKeyAnchor> >();
qRegisterMetaType<QVector<MessageViewer::WebEngineAccessKeyAnchor> >();
}
void MailWebEngineAccessKeyAnchorFromHtmlTest::shouldNotShowAccessKeyWhenHtmlAsNotAnchor()
{
TestWebEngineAccessKey w;
QSignalSpy accessKeySpy(&w, SIGNAL(accessKeySearchFinished(QVector<MessageViewer::MailWebEngineAccessKeyAnchor>)));
QSignalSpy accessKeySpy(&w, SIGNAL(accessKeySearchFinished(QVector<MessageViewer::WebEngineAccessKeyAnchor>)));
w.setHtml(QStringLiteral("<body>foo</body>"));
QVERIFY(accessKeySpy.wait());
QCOMPARE(accessKeySpy.count(), 1);
const QVector<MessageViewer::MailWebEngineAccessKeyAnchor> resultLst = accessKeySpy.at(0).at(0).value<QVector<MessageViewer::MailWebEngineAccessKeyAnchor> >();
const QVector<MessageViewer::WebEngineAccessKeyAnchor> resultLst = accessKeySpy.at(0).at(0).value<QVector<MessageViewer::WebEngineAccessKeyAnchor> >();
QCOMPARE(resultLst.count(), 0);
}
void MailWebEngineAccessKeyAnchorFromHtmlTest::shouldReturnOneAnchor()
{
TestWebEngineAccessKey w;
QSignalSpy accessKeySpy(&w, SIGNAL(accessKeySearchFinished(QVector<MessageViewer::MailWebEngineAccessKeyAnchor>)));
QSignalSpy accessKeySpy(&w, SIGNAL(accessKeySearchFinished(QVector<MessageViewer::WebEngineAccessKeyAnchor>)));
w.setHtml(QStringLiteral("<body>foo<a href=\"http://www.kde.org\">foo</a></body>"));
QVERIFY(accessKeySpy.wait());
QCOMPARE(accessKeySpy.count(), 1);
const QVector<MessageViewer::MailWebEngineAccessKeyAnchor> resultLst = accessKeySpy.at(0).at(0).value<QVector<MessageViewer::MailWebEngineAccessKeyAnchor> >();
const QVector<MessageViewer::WebEngineAccessKeyAnchor> resultLst = accessKeySpy.at(0).at(0).value<QVector<MessageViewer::WebEngineAccessKeyAnchor> >();
QCOMPARE(resultLst.count(), 1);
}
void MailWebEngineAccessKeyAnchorFromHtmlTest::shouldReturnTwoAnchor()
{
TestWebEngineAccessKey w;
QSignalSpy accessKeySpy(&w, SIGNAL(accessKeySearchFinished(QVector<MessageViewer::MailWebEngineAccessKeyAnchor>)));
QSignalSpy accessKeySpy(&w, SIGNAL(accessKeySearchFinished(QVector<MessageViewer::WebEngineAccessKeyAnchor>)));
w.setHtml(QStringLiteral("<body>foo<a href=\"http://www.kde.org\">foo</a><a href=\"http://www.kde.vv\">foo</a></body>"));
QVERIFY(accessKeySpy.wait());
QCOMPARE(accessKeySpy.count(), 1);
const QVector<MessageViewer::MailWebEngineAccessKeyAnchor> resultLst = accessKeySpy.at(0).at(0).value<QVector<MessageViewer::MailWebEngineAccessKeyAnchor> >();
const QVector<MessageViewer::WebEngineAccessKeyAnchor> resultLst = accessKeySpy.at(0).at(0).value<QVector<MessageViewer::WebEngineAccessKeyAnchor> >();
QCOMPARE(resultLst.count(), 2);
}
......
......@@ -36,7 +36,7 @@ private Q_SLOTS:
void handleSearchAccessKey(const QVariant &var);
Q_SIGNALS:
void accessKeySearchFinished(const QVector<MessageViewer::MailWebEngineAccessKeyAnchor> &var);
void accessKeySearchFinished(const QVector<MessageViewer::WebEngineAccessKeyAnchor> &var);
private:
QWebEngineView *mEngineView;
......
......@@ -33,7 +33,7 @@ MailWebEngineAccessKeyAnchorTest::~MailWebEngineAccessKeyAnchorTest()
void MailWebEngineAccessKeyAnchorTest::shouldReturnEmptyAccessKeyAnchor()
{
QVariant var;
MessageViewer::MailWebEngineAccessKeyAnchor accessKeyAnchor(var);
MessageViewer::WebEngineAccessKeyAnchor accessKeyAnchor(var);
QVERIFY(accessKeyAnchor.href().isEmpty());
QVERIFY(accessKeyAnchor.accessKey().isEmpty());
QVERIFY(accessKeyAnchor.boundingRect().isEmpty());
......
......@@ -63,7 +63,7 @@ public:
}
QList<QLabel *> mAccessKeyLabels;
QHash<QChar, MessageViewer::MailWebEngineAccessKeyAnchor> mAccessKeyNodes;
QHash<QChar, MessageViewer::WebEngineAccessKeyAnchor> mAccessKeyNodes;
QHash<QString, QChar> mDuplicateLinkElements;
QWebEngineView *mWebEngine;
AccessKeyState mAccessKeyActivated;
......@@ -93,7 +93,7 @@ static bool isEditableElement(QWebPage *page)
}
#endif
static QString linkElementKey(const MessageViewer::MailWebEngineAccessKeyAnchor &element, const QUrl &baseUrl)
static QString linkElementKey(const MessageViewer::WebEngineAccessKeyAnchor &element, const QUrl &baseUrl)
{
//qDebug()<<" element.href()"<<element.href();
if (!element.href().isEmpty()) {
......@@ -109,7 +109,7 @@ static QString linkElementKey(const MessageViewer::MailWebEngineAccessKeyAnchor
return QString();
}
static void handleDuplicateLinkElements(const MessageViewer::MailWebEngineAccessKeyAnchor &element, QHash<QString, QChar> *dupLinkList, QChar *accessKey, const QUrl &baseUrl)
static void handleDuplicateLinkElements(const MessageViewer::WebEngineAccessKeyAnchor &element, QHash<QString, QChar> *dupLinkList, QChar *accessKey, const QUrl &baseUrl)
{
if (element.tagName().compare(QLatin1String("A"), Qt::CaseInsensitive) == 0) {
const QString linkKey(linkElementKey(element, baseUrl));
......@@ -126,7 +126,7 @@ static void handleDuplicateLinkElements(const MessageViewer::MailWebEngineAccess
}
}
static bool isHiddenElement(const MessageViewer::MailWebEngineAccessKeyAnchor &element)
static bool isHiddenElement(const MessageViewer::WebEngineAccessKeyAnchor &element)
{
// width property set to less than zero
if (element.boundingRect().width() < 1) {
......@@ -233,7 +233,7 @@ void MailWebEngineAccessKey::hideAccessKeys()
}
}
void MailWebEngineAccessKey::makeAccessKeyLabel(QChar accessKey, const MessageViewer::MailWebEngineAccessKeyAnchor &element)
void MailWebEngineAccessKey::makeAccessKeyLabel(QChar accessKey, const MessageViewer::WebEngineAccessKeyAnchor &element)
{
//qDebug()<<" void MailWebEngineAccessKey::makeAccessKeyLabel(QChar accessKey, const MessageViewer::MailWebEngineAccessKeyAnchor &element)";
QLabel *label = new QLabel(d->mWebEngine);
......@@ -272,7 +272,7 @@ bool MailWebEngineAccessKey::checkForAccessKey(QKeyEvent *event)
QChar key = text.at(0).toUpper();
bool handled = false;
if (d->mAccessKeyNodes.contains(key)) {
MessageViewer::MailWebEngineAccessKeyAnchor element = d->mAccessKeyNodes[key];
MessageViewer::WebEngineAccessKeyAnchor element = d->mAccessKeyNodes[key];
if (element.tagName().compare(QLatin1String("A"), Qt::CaseInsensitive) == 0) {
const QString linkKey(linkElementKey(element, d->mWebEngine->url()));
if (!linkKey.isEmpty()) {
......@@ -289,11 +289,11 @@ void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
{
//qDebug() << " void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res)" << res;
const QVariantList lst = res.toList();
QVector<MessageViewer::MailWebEngineAccessKeyAnchor> anchorList;
QVector<MessageViewer::WebEngineAccessKeyAnchor> anchorList;
anchorList.reserve(lst.count());
Q_FOREACH (const QVariant &var, lst) {
//qDebug()<<" var"<<var;
anchorList << MessageViewer::MailWebEngineAccessKeyAnchor(var);
anchorList << MessageViewer::WebEngineAccessKeyAnchor(var);
}
QList<QChar> unusedKeys;
......@@ -319,9 +319,9 @@ void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
}
}
}
QVector<MessageViewer::MailWebEngineAccessKeyAnchor> unLabeledElements;
QVector<MessageViewer::WebEngineAccessKeyAnchor> unLabeledElements;
QRect viewport = d->mWebEngine->rect();//QRect(d->mWebEngine->page()->mainFrame()->scrollPosition(), d->mWebEngine->page()->viewportSize());
Q_FOREACH (const MessageViewer::MailWebEngineAccessKeyAnchor &element, anchorList) {
Q_FOREACH (const MessageViewer::WebEngineAccessKeyAnchor &element, anchorList) {
const QRect geometry = element.boundingRect();
if (geometry.size().isEmpty() || !viewport.contains(geometry.topLeft())) {
continue;
......@@ -356,7 +356,7 @@ void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
// Pick an access key first from the letters in the text and then from the
// list of unused access keys
Q_FOREACH (const MessageViewer::MailWebEngineAccessKeyAnchor &element, unLabeledElements) {
Q_FOREACH (const MessageViewer::WebEngineAccessKeyAnchor &element, unLabeledElements) {
const QRect geometry = element.boundingRect();
if (unusedKeys.isEmpty()
|| geometry.size().isEmpty()
......@@ -388,6 +388,6 @@ void MailWebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
void MailWebEngineAccessKey::showAccessKeys()
{
d->mAccessKeyActivated = MailWebEngineAccessKeyPrivate::Activated;
d->mWebEngine->page()->runJavaScript(MessageViewer::MailWebEngineAccessKeyUtils::script(), invoke(this, &MailWebEngineAccessKey::handleSearchAccessKey));
d->mWebEngine->page()->runJavaScript(MessageViewer::WebEngineAccessKeyUtils::script(), invoke(this, &MailWebEngineAccessKey::handleSearchAccessKey));
}
......@@ -29,7 +29,7 @@ class QWebEngineView;
namespace MessageViewer
{
class MailWebEngineAccessKeyPrivate;
class MailWebEngineAccessKeyAnchor;
class WebEngineAccessKeyAnchor;
class MESSAGEVIEWER_EXPORT MailWebEngineAccessKey : public QObject
{
Q_OBJECT
......@@ -45,7 +45,7 @@ public:
void keyReleaseEvent(QKeyEvent *e);
void showAccessKeys();
void makeAccessKeyLabel(QChar accessKey, const MessageViewer::MailWebEngineAccessKeyAnchor &element);
void makeAccessKeyLabel(QChar accessKey, const MessageViewer::WebEngineAccessKeyAnchor &element);
bool checkForAccessKey(QKeyEvent *event);
Q_SIGNALS:
......
......@@ -20,17 +20,17 @@
using namespace MessageViewer;
MailWebEngineAccessKeyAnchor::MailWebEngineAccessKeyAnchor(const QVariant &result)
WebEngineAccessKeyAnchor::WebEngineAccessKeyAnchor(const QVariant &result)
{
initialize(result);
}
MailWebEngineAccessKeyAnchor::MailWebEngineAccessKeyAnchor()
WebEngineAccessKeyAnchor::WebEngineAccessKeyAnchor()
{
}
void MailWebEngineAccessKeyAnchor::initialize(const QVariant &result)
void WebEngineAccessKeyAnchor::initialize(const QVariant &result)
{
if (result.isValid()) {
const QVariantMap map = result.toMap();
......@@ -46,32 +46,32 @@ void MailWebEngineAccessKeyAnchor::initialize(const QVariant &result)
}
}
QString MailWebEngineAccessKeyAnchor::innerText() const
QString WebEngineAccessKeyAnchor::innerText() const
{
return mInnerText;
}
QString MailWebEngineAccessKeyAnchor::tagName() const
QString WebEngineAccessKeyAnchor::tagName() const
{
return mTagName;
}
QString MailWebEngineAccessKeyAnchor::target() const
QString WebEngineAccessKeyAnchor::target() const
{
return mTarget;
}
QString MailWebEngineAccessKeyAnchor::href() const
QString WebEngineAccessKeyAnchor::href() const
{
return mHref;
}
QString MailWebEngineAccessKeyAnchor::accessKey() const
QString WebEngineAccessKeyAnchor::accessKey() const
{
return mAccessKey;
}
QRect MailWebEngineAccessKeyAnchor::boundingRect() const
QRect WebEngineAccessKeyAnchor::boundingRect() const
{
return mBoundingRect;
}
......@@ -23,11 +23,11 @@
namespace MessageViewer
{
class MailWebEngineAccessKeyAnchor
class WebEngineAccessKeyAnchor
{
public:
MailWebEngineAccessKeyAnchor(const QVariant &result);
MailWebEngineAccessKeyAnchor();
WebEngineAccessKeyAnchor(const QVariant &result);
WebEngineAccessKeyAnchor();
QRect boundingRect() const;
QString accessKey() const;
......@@ -51,5 +51,5 @@ private:
};
}
Q_DECLARE_TYPEINFO(MessageViewer::MailWebEngineAccessKeyAnchor, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(MessageViewer::WebEngineAccessKeyAnchor, Q_MOVABLE_TYPE);
#endif // MAILWEBENGINEACCESSKEYANCHOR_H
......@@ -17,7 +17,7 @@
#include "mailwebengineaccesskeyutils.h"
QString MessageViewer::MailWebEngineAccessKeyUtils::script()
QString MessageViewer::WebEngineAccessKeyUtils::script()
{
const QString script = QString::fromLatin1("(function() {"
"var out = [];"
......
......@@ -22,7 +22,7 @@
namespace MessageViewer
{
namespace MailWebEngineAccessKeyUtils
namespace WebEngineAccessKeyUtils
{
QString script();
}
......
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