summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Messages.sh2
-rw-r--r--src/adblock/adblockmanager.cpp6
-rw-r--r--src/adblock/adblockrule.h5
-rw-r--r--src/adblock/adblockrulefallbackimpl.cpp42
-rw-r--r--src/adblock/adblockrulefallbackimpl.h5
-rw-r--r--src/adblock/adblockruleimpl.h3
-rw-r--r--src/adblock/adblockruletextmatchimpl.cpp3
-rw-r--r--src/adblock/adblockruletextmatchimpl.h2
-rw-r--r--src/application.cpp4
-rw-r--r--src/bookmarks/bookmarkscontextmenu.cpp18
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp59
-rw-r--r--src/findbar.cpp57
-rw-r--r--src/findbar.h10
-rw-r--r--src/mainwindow.cpp13
-rw-r--r--src/mainwindow.h2
15 files changed, 154 insertions, 77 deletions
diff --git a/src/Messages.sh b/src/Messages.sh
index 86f846c8..ccad97fc 100644
--- a/src/Messages.sh
+++ b/src/Messages.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-$EXTRACTRC *.ui */*ui >> rc.cpp || exit 1
+$EXTRACTRC *.ui */*ui *.rc >> rc.cpp || exit 1
$XGETTEXT *.cpp */*.cpp -o $podir/rekonq.pot
rm -f rc.cpp
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index 8deb0bcd..f7c61cdb 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -187,7 +187,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
foreach(const AdBlockRule &filter, _whiteList)
{
- if (filter.match(urlString, urlStringLowerCase))
+ if (filter.match(request, urlString, urlStringLowerCase))
{
kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched: ***********";
kDebug() << "UrlString: " << urlString;
@@ -205,7 +205,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
foreach(const AdBlockRule &filter, _blackList)
{
- if (filter.match(urlString, urlStringLowerCase))
+ if (filter.match(request, urlString, urlStringLowerCase))
{
kDebug() << "****ADBLOCK: BLACK RULE Matched: ***********";
kDebug() << "UrlString: " << urlString;
@@ -215,7 +215,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
foreach(QWebElement el, elements)
{
const QString srcAttribute = el.attribute("src");
- if (filter.match(srcAttribute, srcAttribute.toLower()))
+ if (filter.match(request, srcAttribute, srcAttribute.toLower()))
{
kDebug() << "MATCHES ATTRIBUTE!!!!!";
el.setStyleProperty(QL1S("visibility"), QL1S("hidden"));
diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h
index ef7b2f5f..701a9fe1 100644
--- a/src/adblock/adblockrule.h
+++ b/src/adblock/adblockrule.h
@@ -63,6 +63,7 @@
#include <QSharedPointer>
// Forward Includes
+class QNetworkRequest;
class QString;
class AdBlockRule
@@ -70,10 +71,10 @@ class AdBlockRule
public:
AdBlockRule(const QString &filter);
- bool match(const QString &encodedUrl, const QString &encodedUrlLowerCase) const
+ bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const
{
Q_ASSERT(encodedUrl.toLower() == encodedUrlLowerCase);
- return m_implementation->match(encodedUrl, encodedUrlLowerCase);
+ return m_implementation->match(request, encodedUrl, encodedUrlLowerCase);
}
private:
diff --git a/src/adblock/adblockrulefallbackimpl.cpp b/src/adblock/adblockrulefallbackimpl.cpp
index 988f2895..959050da 100644
--- a/src/adblock/adblockrulefallbackimpl.cpp
+++ b/src/adblock/adblockrulefallbackimpl.cpp
@@ -30,8 +30,11 @@
#include "rekonq_defines.h"
// Qt Includes
+#include <QWebFrame>
+#include <QNetworkReply>
#include <QStringList>
+
static inline bool isRegExpFilter(const QString &filter)
{
return filter.startsWith(QL1C('/')) && filter.endsWith(QL1C('/'));
@@ -48,9 +51,24 @@ AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter)
const int optionsNumber = parsedLine.lastIndexOf(QL1C('$'));
if (optionsNumber >= 0 && !isRegExpFilter(parsedLine)) {
const QStringList options(parsedLine.mid(optionsNumber + 1).split(QL1C(',')));
+ parsedLine = parsedLine.left(optionsNumber);
+
if (options.contains(QL1S("match-case")))
m_regExp.setCaseSensitivity(Qt::CaseSensitive);
- parsedLine = parsedLine.left(optionsNumber);
+
+ foreach (const QString &option, options) {
+ // Domain restricted filter
+ const QString domainKeyword(QL1S("domain="));
+ if (option.startsWith(domainKeyword)) {
+ QStringList domainList = option.mid(domainKeyword.length()).split(QL1C('|'));
+ foreach (const QString &domain, domainList) {
+ if (domain.startsWith(QL1C('~')))
+ m_whiteDomains.insert(domain.toLower());
+ else
+ m_blackDomains.insert(domain.toLower());
+ }
+ }
+ }
}
if (isRegExpFilter(parsedLine))
@@ -61,9 +79,27 @@ AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter)
m_regExp.setPattern(parsedLine);
}
-bool AdBlockRuleFallbackImpl::match(const QString &encodedUrl, const QString &) const
+bool AdBlockRuleFallbackImpl::match(const QNetworkRequest &request, const QString &encodedUrl, const QString &) const
{
- return m_regExp.indexIn(encodedUrl) != -1;
+ const bool regexpMatch = m_regExp.indexIn(encodedUrl) != -1;
+
+ if (regexpMatch && (!m_whiteDomains.isEmpty() || !m_blackDomains.isEmpty())) {
+ Q_ASSERT(qobject_cast<QWebFrame*>(request.originatingObject()));
+ const QWebFrame *const origin = static_cast<QWebFrame *const>(request.originatingObject());
+
+ const QString originDomain = origin->url().host();
+
+ if (!m_whiteDomains.isEmpty()) {
+ // In this context, white domains means we block anything but what is in the list.
+ if (m_whiteDomains.contains(originDomain))
+ return false;
+ return true;
+ } else if (m_blackDomains.contains(originDomain)) {
+ return true;
+ }
+ return false;
+ }
+ return regexpMatch;
}
QString AdBlockRuleFallbackImpl::convertPatternToRegExp(const QString &wildcardPattern)
diff --git a/src/adblock/adblockrulefallbackimpl.h b/src/adblock/adblockrulefallbackimpl.h
index ed0f6dc6..8cb02e10 100644
--- a/src/adblock/adblockrulefallbackimpl.h
+++ b/src/adblock/adblockrulefallbackimpl.h
@@ -31,17 +31,20 @@
// Qt Includes
#include <QRegExp>
#include <QString>
+#include <QSet>
class AdBlockRuleFallbackImpl : public AdBlockRuleImpl
{
public:
AdBlockRuleFallbackImpl(const QString &filter);
- bool match(const QString &encodedUrl, const QString &encodedUrlLowerCase) const;
+ bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const;
private:
QString convertPatternToRegExp(const QString &wildcardPattern);
QRegExp m_regExp;
+ QSet<QString> m_whiteDomains;
+ QSet<QString> m_blackDomains;
};
#endif // ADBLOCKRULEFALLBACKIMPL_H
diff --git a/src/adblock/adblockruleimpl.h b/src/adblock/adblockruleimpl.h
index db5cec30..7702217b 100644
--- a/src/adblock/adblockruleimpl.h
+++ b/src/adblock/adblockruleimpl.h
@@ -27,13 +27,14 @@
#define ADBLOCKRULEIMPL_H
class QString;
+class QNetworkRequest;
class AdBlockRuleImpl
{
public:
AdBlockRuleImpl(const QString &) {}
virtual ~AdBlockRuleImpl() {}
- virtual bool match(const QString &encodedUrl, const QString &encodedUrlLowerCase) const = 0;
+ virtual bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const = 0;
};
#endif // ADBLOCKRULEIMPL_H
diff --git a/src/adblock/adblockruletextmatchimpl.cpp b/src/adblock/adblockruletextmatchimpl.cpp
index 892d78e0..2d534a3a 100644
--- a/src/adblock/adblockruletextmatchimpl.cpp
+++ b/src/adblock/adblockruletextmatchimpl.cpp
@@ -38,9 +38,10 @@ AdBlockRuleTextMatchImpl::AdBlockRuleTextMatchImpl(const QString &filter)
m_textToMatch.remove(QL1C('*'));
}
-bool AdBlockRuleTextMatchImpl::match(const QString &encodedUrl, const QString &encodedUrlLowerCase) const
+bool AdBlockRuleTextMatchImpl::match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const
{
Q_UNUSED(encodedUrl);
+ Q_UNUSED(request);
// Case sensitive compare is faster, but would be incorrect with encodedUrl since
// we do want case insensitive.
// What we do is work on a lowercase version of m_textToMatch, and compare to the lowercase
diff --git a/src/adblock/adblockruletextmatchimpl.h b/src/adblock/adblockruletextmatchimpl.h
index 28b0656c..b2c6e239 100644
--- a/src/adblock/adblockruletextmatchimpl.h
+++ b/src/adblock/adblockruletextmatchimpl.h
@@ -36,7 +36,7 @@ class AdBlockRuleTextMatchImpl : public AdBlockRuleImpl
{
public:
AdBlockRuleTextMatchImpl(const QString &filter);
- bool match(const QString &encodedUrl, const QString &encodedUrlLowerCase) const;
+ bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const;
static bool isTextMatchFilter(const QString &filter);
diff --git a/src/application.cpp b/src/application.cpp
index db71c602..e5677a0d 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -342,6 +342,8 @@ KIcon Application::icon(const KUrl &url)
return KIcon("text-html");
// rekonq icons..
+ if (url == KUrl("about:home"))
+ return KIcon("go-home");
if (url == KUrl("about:closedTabs"))
return KIcon("tab-close");
if (url == KUrl("about:history"))
@@ -350,6 +352,8 @@ KIcon Application::icon(const KUrl &url)
return KIcon("bookmarks");
if (url == KUrl("about:favorites"))
return KIcon("emblem-favorite");
+ if (url == KUrl("about:downloads"))
+ return KIcon("download");
KIcon icon = KIcon(QWebSettings::iconForUrl(url));
if (icon.isNull())
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp
index a473966a..da986fd2 100644
--- a/src/bookmarks/bookmarkscontextmenu.cpp
+++ b/src/bookmarks/bookmarkscontextmenu.cpp
@@ -69,10 +69,22 @@ void BookmarksContextMenu::addBookmarkActions()
void BookmarksContextMenu::addFolderActions()
{
- if (!bookmark().toGroup().first().isNull())
+ KBookmarkGroup group = bookmark().toGroup();
+
+ if (!group.first().isNull())
{
- addAction(bmOwner->action(BookmarkOwner::OPEN_FOLDER));
- addSeparator();
+ KBookmark child = group.first();
+
+ while (child.isGroup() || child.isSeparator())
+ {
+ child = group.next(child);
+ }
+
+ if (!child.isNull())
+ {
+ addAction(bmOwner->action(BookmarkOwner::OPEN_FOLDER));
+ addSeparator();
+ }
}
addAction(bmOwner->action(BookmarkOwner::BOOKMARK_PAGE));
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index bc307965..ddb70a65 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -38,7 +38,7 @@
// Qt Includes
#include <QtGui/QFrame>
-#include <QActionEvent>
+#include <QtGui/QActionEvent>
BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
@@ -124,6 +124,7 @@ void BookmarkMenu::refill()
void BookmarkMenu::addOpenFolderInTabs()
{
+ // TODO: Needs to be ported to the new BookmarkOwner API
KAction *action;
KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup();
@@ -336,33 +337,38 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
else if (event->type() == QEvent::Drop)
{
QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
- if (dropEvent->mimeData()->hasFormat("application/rekonq-bookmark"))
+ QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark");
+ KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
+
+ if (!dropEvent->mimeData()->hasFormat("application/rekonq-bookmark") && !bookmark.isNull())
{
- QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark");
- KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
+ return QObject::eventFilter(watched, event);
+ }
- QAction *destAction = toolBar()->actionAt(dropEvent->pos());
- if (destAction && destAction == m_dropAction)
+ QAction *destAction = toolBar()->actionAt(dropEvent->pos());
+ if (destAction && destAction == m_dropAction)
+ {
+ if (toolBar()->actions().indexOf(m_dropAction) > 0)
{
- if (toolBar()->actions().indexOf(m_dropAction) > 0)
- {
- destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1);
- }
- else
- {
- destAction = toolBar()->actions().at(1);
- }
+ destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1);
}
+ else
+ {
+ destAction = toolBar()->actions().at(1);
+ }
+ }
+ KBookmarkGroup root = Application::bookmarkProvider()->rootGroup();
+
+ if (destAction)
+ {
KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction);
QWidget *widgetAction = toolBar()->widgetForAction(destAction);
- if (!bookmark.isNull() && destBookmarkAction && !destBookmarkAction->bookmark().isNull()
+ if (destBookmarkAction && !destBookmarkAction->bookmark().isNull()
&& widgetAction && bookmark.address() != destBookmarkAction->bookmark().address())
{
- KBookmarkGroup root = Application::bookmarkProvider()->rootGroup();
KBookmark destBookmark = destBookmarkAction->bookmark();
- // To fix an issue with panel's drags
root.deleteBookmark(bookmark);
if ((dropEvent->pos().x() - widgetAction->pos().x()) > (widgetAction->width() / 2))
@@ -373,18 +379,31 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
{
root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
}
-
Application::bookmarkProvider()->bookmarkManager()->emitChanged();
- dropEvent->accept();
}
}
+ else
+ {
+ root.deleteBookmark(bookmark);
+ if (QCursor::pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x())
+ {
+ root.moveBookmark(bookmark, KBookmark());
+ }
+ else
+ {
+ root.addBookmark(bookmark);
+ }
+
+ Application::bookmarkProvider()->bookmarkManager()->emitChanged();
+ }
+ dropEvent->accept();
}
}
else
{
// Drag handling
if (event->type() == QEvent::MouseButtonPress)
- {//QMessageBox::information(NULL, "", "");
+ {
QPoint pos = toolBar()->mapFromGlobal(QCursor::pos());
KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos));
diff --git a/src/findbar.cpp b/src/findbar.cpp
index b3b80fac..0e3f7385 100644
--- a/src/findbar.cpp
+++ b/src/findbar.cpp
@@ -49,16 +49,14 @@
#include <QtCore/QTimer>
-FindBar::FindBar(QWidget *parent)
- : QWidget(parent)
+FindBar::FindBar(MainWindow *window)
+ : QWidget(window)
+ , m_mainWindow(window)
, m_lineEdit(new KLineEdit(this))
, m_hideTimer(new QTimer(this))
, m_matchCase(new QCheckBox(i18n("&Match case"), this))
, m_highlightAll(new QCheckBox(i18n("&Highlight all"), this))
{
- // mainwindow pointer
- MainWindow *window = qobject_cast<MainWindow *>(parent);
-
QHBoxLayout *layout = new QHBoxLayout;
// cosmetic
@@ -138,25 +136,33 @@ bool FindBar::highlightAllState() const
return m_highlightAll->isChecked();
}
-
-void FindBar::show()
+void FindBar::setVisible(bool visible)
{
- // show findbar if not visible
- if (isHidden())
- {
- emit visibilityChanged(true);
- QWidget::show();
+ QWidget::setVisible(visible);
+
+ if (visible != isVisible())
+ emit visibilityChanged(visible);
+
+ if (visible) {
+ if (!hasFocus()) {
+ const QString selectedText = m_mainWindow->selectedText();
+ if (!selectedText.isEmpty())
+ m_lineEdit->setText(selectedText);
+ }
+
+ // show findbar if not visible
emit searchString(m_lineEdit->text());
- }
- m_hideTimer->start(60000);
+ m_hideTimer->start(60000);
- // set focus to findbar if user select showFindBar shortcut
- m_lineEdit->setFocus();
- m_lineEdit->selectAll();
+ // set focus to findbar if user select showFindBar shortcut
+ m_lineEdit->setFocus();
+ m_lineEdit->selectAll();
+ } else {
+ m_hideTimer->stop();
+ }
}
-
void FindBar::notifyMatch(bool match)
{
QPalette p = m_lineEdit->palette();
@@ -179,18 +185,3 @@ void FindBar::notifyMatch(bool match)
m_lineEdit->setPalette(p);
m_hideTimer->start(60000);
}
-
-
-void FindBar::hide()
-{
- m_hideTimer->stop();
- emit visibilityChanged(false);
- QWidget::hide();
- emit(searchString(m_lineEdit->text()));
-}
-
-
-void FindBar::toggleVisibility()
-{
- isVisible() ? hide() : show();
-}
diff --git a/src/findbar.h b/src/findbar.h
index 38bbcbc5..6451aac8 100644
--- a/src/findbar.h
+++ b/src/findbar.h
@@ -41,30 +41,28 @@
// Forward Declarations
class QString;
-
+class MainWindow;
class REKONQ_TESTS_EXPORT FindBar : public QWidget
{
Q_OBJECT
public:
- FindBar(QWidget *parent);
+ FindBar(MainWindow *parent);
~FindBar();
bool matchCase() const;
void notifyMatch(bool match);
bool highlightAllState() const;
-public slots:
- void show();
- void hide();
- void toggleVisibility();
+ void setVisible(bool visible);
signals:
void searchString(const QString &);
void visibilityChanged(bool);
private:
+ MainWindow *m_mainWindow;
KLineEdit *m_lineEdit;
QTimer *m_hideTimer;
QCheckBox *m_matchCase;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 4f9d6dab..44cc6d59 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -365,11 +365,11 @@ void MainWindow::setupActions()
KStandardAction::print(this, SLOT(printRequested()), actionCollection());
KStandardAction::quit(this , SLOT(close()), actionCollection());
- a = KStandardAction::find(m_findBar, SLOT(toggleVisibility()), actionCollection());
+ a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection());
KShortcut findShortcut = KStandardShortcut::find();
findShortcut.setAlternate(Qt::Key_Slash);
a->setShortcut(findShortcut);
- a->setCheckable(true);
+ a->setChecked(m_findBar->isVisible());
connect(m_findBar, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool)));
KStandardAction::findNext(this, SLOT(findNext()) , actionCollection());
@@ -907,6 +907,15 @@ void MainWindow::setWidgetsVisible(bool makeVisible)
}
+QString MainWindow::selectedText() const
+{
+ if (!currentTab())
+ return QString();
+
+ return currentTab()->view()->selectedText();
+}
+
+
void MainWindow::viewPageSource()
{
if (!currentTab())
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 3aa57f5c..cd55faa5 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -80,6 +80,8 @@ public:
virtual QSize sizeHint() const;
void setWidgetsVisible(bool makeFullScreen);
+ QString selectedText() const;
+
private:
void setupBookmarksAndToolsShortcuts();
void setupActions();