summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarkowner.cpp1
-rw-r--r--src/bookmarks/bookmarkowner.h27
-rw-r--r--src/bookmarks/bookmarkprovider.cpp3
-rw-r--r--src/bookmarks/bookmarkprovider.h19
-rw-r--r--src/bookmarks/bookmarkspanel.cpp37
-rw-r--r--src/bookmarks/bookmarkspanel.h16
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp1
-rw-r--r--src/bookmarks/bookmarkstreemodel.h13
-rw-r--r--src/history/historypanel.cpp21
-rw-r--r--src/history/historypanel.h3
-rw-r--r--src/search/opensearchmanager.cpp4
-rw-r--r--src/search/searchengine.cpp20
-rw-r--r--src/search/searchengine.h7
-rw-r--r--src/urlbar/completionwidget.cpp21
-rw-r--r--src/urlbar/completionwidget.h10
-rw-r--r--src/urlbar/listitem.cpp73
-rw-r--r--src/urlbar/listitem.h5
-rw-r--r--src/urlbar/urlresolver.cpp28
-rw-r--r--src/urlbar/urlresolver.h46
-rw-r--r--src/urlfilterproxymodel.cpp1
-rw-r--r--src/urlfilterproxymodel.h6
-rw-r--r--src/urlpanel.cpp17
-rw-r--r--src/urlpanel.h16
23 files changed, 220 insertions, 175 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
index 2d840f56..f9e64d68 100644
--- a/src/bookmarks/bookmarkowner.cpp
+++ b/src/bookmarks/bookmarkowner.cpp
@@ -29,6 +29,7 @@
// Self Includes
#include "bookmarkowner.h"
+#include "bookmarkowner.moc"
// Local Includes
#include "application.h"
diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h
index 5bc46e63..febff3b0 100644
--- a/src/bookmarks/bookmarkowner.h
+++ b/src/bookmarks/bookmarkowner.h
@@ -40,6 +40,7 @@
// Forward Declarations
class KAction;
+
/**
* Reimplementation of KBookmarkOwner, this class allows to manage
* bookmarks as actions.
@@ -111,14 +112,7 @@ public:
*/
virtual void openFolderinTabs(const KBookmarkGroup &bookmark);
-signals:
- /**
- * This signal is emitted when an url has to be loaded
- * @param url the URL to load
- */
- void openUrl(const KUrl &, const Rekonq::OpenType &);
-
-public slots:
+public Q_SLOTS:
void setCurrentBookmark(const KBookmark &bookmark);
void unsetCurrentBookmark();
@@ -133,16 +127,23 @@ public slots:
void editBookmark(KBookmark bookmark = KBookmark());
bool deleteBookmark(KBookmark bookmark = KBookmark());
-private:
- KBookmarkManager *m_manager;
-
- QVector<KAction*> m_actions;
- KBookmark m_currentBookmark;
+Q_SIGNALS:
+ /**
+ * This signal is emitted when an url has to be loaded
+ * @param url the URL to load
+ */
+ void openUrl(const KUrl &, const Rekonq::OpenType &);
+private:
void setupActions();
void createAction(const BookmarkAction &action,
const QString &text, const QString &icon,
const QString &help, const char *slot);
+
+
+ KBookmarkManager *m_manager;
+ QVector<KAction*> m_actions;
+ KBookmark m_currentBookmark;
};
#endif // BOOKMARKOWNER_H
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp
index 6736f0d7..8089fb6d 100644
--- a/src/bookmarks/bookmarkprovider.cpp
+++ b/src/bookmarks/bookmarkprovider.cpp
@@ -29,13 +29,14 @@
// Self Includes
#include "bookmarkprovider.h"
+#include "bookmarkprovider.moc"
// Local Includes
#include "application.h"
#include "bookmarkspanel.h"
#include "bookmarkstoolbar.h"
#include "bookmarkowner.h"
-#include <iconmanager.h>
+#include "iconmanager.h"
// KDE Includes
#include <KActionCollection>
diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h
index 2f2b7abe..3f7a5c52 100644
--- a/src/bookmarks/bookmarkprovider.h
+++ b/src/bookmarks/bookmarkprovider.h
@@ -54,6 +54,7 @@ class KUrl;
class QAction;
class QPoint;
+
/**
* This class represent the interface to rekonq bookmarks system.
* All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided
@@ -114,14 +115,7 @@ public:
KBookmark bookmarkForUrl(const KUrl &url);
-signals:
- /**
- * @short This signal is emitted when an url has to be loaded
- */
- void openUrl(const KUrl &, const Rekonq::OpenType &);
-
-
-public slots:
+public Q_SLOTS:
/**
* @short Waits for signal that the group with the address has been modified by the caller.
* Waits for signal that the group (or any of its children) with the address
@@ -133,12 +127,17 @@ public slots:
void slotBookmarksChanged();
void fillBookmarkBar(BookmarkToolBar *toolBar);
-private slots:
+private Q_SLOTS:
void slotPanelChanged();
+
+Q_SIGNALS:
+ /**
+ * @short This signal is emitted when an url has to be loaded
+ */
+ void openUrl(const KUrl &, const Rekonq::OpenType &);
private:
void find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text);
-
KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url);
KBookmarkManager *m_manager;
diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp
index e88d3060..27c60e46 100644
--- a/src/bookmarks/bookmarkspanel.cpp
+++ b/src/bookmarks/bookmarkspanel.cpp
@@ -27,6 +27,7 @@
// Self Includes
#include "bookmarkspanel.h"
+#include "bookmarkspanel.moc"
// Auto Includes
#include "rekonq.h"
@@ -43,10 +44,12 @@
BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags)
: UrlPanel(title, parent, flags)
- , m_loadingState(false)
+ , _bkTreeModel(new BookmarksTreeModel(this))
+ , _loadingState(false)
{
setObjectName("bookmarksPanel");
setVisible(ReKonfig::showBookmarksPanel());
+ connect(_bkTreeModel, SIGNAL(bookmarksUpdated()), this, SLOT(startLoadFoldedState()));
}
@@ -58,24 +61,24 @@ BookmarksPanel::~BookmarksPanel()
void BookmarksPanel::startLoadFoldedState()
{
- m_loadingState = true;
+ _loadingState = true;
loadFoldedState(QModelIndex());
- m_loadingState = false;
+ _loadingState = false;
}
void BookmarksPanel::contextMenu(const QPoint &pos)
{
- if (m_loadingState)
+ if (_loadingState)
return;
- BookmarksContextMenu menu(bookmarkForIndex( m_treeView->indexAt(pos) ),
+ BookmarksContextMenu menu(bookmarkForIndex( panelTreeView()->indexAt(pos) ),
Application::bookmarkProvider()->bookmarkManager(),
Application::bookmarkProvider()->bookmarkOwner(),
this
);
- menu.exec(m_treeView->mapToGlobal(pos));
+ menu.exec(panelTreeView()->mapToGlobal(pos));
}
@@ -99,8 +102,8 @@ void BookmarksPanel::contextMenuEmpty(const QPoint &pos)
void BookmarksPanel::deleteBookmark()
{
- QModelIndex index = m_treeView->currentIndex();
- if (m_loadingState || !index.isValid())
+ QModelIndex index = panelTreeView()->currentIndex();
+ if (_loadingState || !index.isValid())
return;
Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(bookmarkForIndex(index));
@@ -109,7 +112,7 @@ void BookmarksPanel::deleteBookmark()
void BookmarksPanel::onCollapse(const QModelIndex &index)
{
- if (m_loadingState)
+ if (_loadingState)
return;
bookmarkForIndex(index).internalElement().setAttribute("folded", "yes");
@@ -119,7 +122,7 @@ void BookmarksPanel::onCollapse(const QModelIndex &index)
void BookmarksPanel::onExpand(const QModelIndex &index)
{
- if (m_loadingState)
+ if (_loadingState)
return;
bookmarkForIndex(index).internalElement().setAttribute("folded", "no");
@@ -129,7 +132,7 @@ void BookmarksPanel::onExpand(const QModelIndex &index)
void BookmarksPanel::loadFoldedState(const QModelIndex &root)
{
- QAbstractItemModel *model = m_treeView->model();
+ QAbstractItemModel *model = panelTreeView()->model();
int count = model->rowCount(root);
QModelIndex index;
@@ -141,7 +144,7 @@ void BookmarksPanel::loadFoldedState(const QModelIndex &root)
KBookmark bm = bookmarkForIndex(index);
if (bm.isGroup())
{
- m_treeView->setExpanded(index, bm.toGroup().isOpen());
+ panelTreeView()->setExpanded(index, bm.toGroup().isOpen());
loadFoldedState(index);
}
}
@@ -154,9 +157,9 @@ void BookmarksPanel::setup()
UrlPanel::setup();
kDebug() << "Bookmarks panel...";
- connect(m_treeView, SIGNAL(delKeyPressed()), this, SLOT(deleteBookmark()));
- connect(m_treeView, SIGNAL(collapsed(const QModelIndex &)), this, SLOT(onCollapse(const QModelIndex &)));
- connect(m_treeView, SIGNAL(expanded(const QModelIndex &)), this, SLOT(onExpand(const QModelIndex &)));
+ connect(panelTreeView(), SIGNAL(delKeyPressed()), this, SLOT(deleteBookmark()));
+ connect(panelTreeView(), SIGNAL(collapsed(const QModelIndex &)), this, SLOT(onCollapse(const QModelIndex &)));
+ connect(panelTreeView(), SIGNAL(expanded(const QModelIndex &)), this, SLOT(onExpand(const QModelIndex &)));
startLoadFoldedState();
}
@@ -177,7 +180,5 @@ KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index)
QAbstractItemModel* BookmarksPanel::getModel()
{
- BookmarksTreeModel *model = new BookmarksTreeModel(this);
- connect(model, SIGNAL(bookmarksUpdated()), this, SLOT(startLoadFoldedState()));
- return model;
+ return _bkTreeModel;
}
diff --git a/src/bookmarks/bookmarkspanel.h b/src/bookmarks/bookmarkspanel.h
index 2418ae81..f042d4c8 100644
--- a/src/bookmarks/bookmarkspanel.h
+++ b/src/bookmarks/bookmarkspanel.h
@@ -37,9 +37,12 @@
#include "urlpanel.h"
// Forward Declarations
+class BookmarksTreeModel;
+
class KBookmark;
class QModelIndex;
+
class REKONQ_TESTS_EXPORT BookmarksPanel : public UrlPanel
{
Q_OBJECT
@@ -48,13 +51,10 @@ public:
explicit BookmarksPanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
virtual ~BookmarksPanel();
-signals:
- void expansionChanged();
-
-public slots:
+public Q_SLOTS:
void startLoadFoldedState();
-private slots:
+private Q_SLOTS:
void contextMenu(const QPoint &pos);
virtual void contextMenuItem(const QPoint &pos);
virtual void contextMenuGroup(const QPoint &pos);
@@ -65,13 +65,17 @@ private slots:
void onExpand(const QModelIndex &index);
void loadFoldedState(const QModelIndex &root);
+Q_SIGNALS:
+ void expansionChanged();
+
private:
virtual void setup();
KBookmark bookmarkForIndex(const QModelIndex &index);
virtual QAbstractItemModel* getModel();
- bool m_loadingState;
+ BookmarksTreeModel *_bkTreeModel;
+ bool _loadingState;
};
#endif // BOOKMARKSPANEL_H
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
index 4e85c422..796208a9 100644
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ b/src/bookmarks/bookmarkstreemodel.cpp
@@ -27,6 +27,7 @@
// Self Includes
#include "bookmarkstreemodel.h"
+#include "bookmarkstreemodel.moc"
// Local Includes
#include "application.h"
diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h
index 6b85365b..7bbce339 100644
--- a/src/bookmarks/bookmarkstreemodel.h
+++ b/src/bookmarks/bookmarkstreemodel.h
@@ -38,6 +38,7 @@
// Qt Includes
#include <QtCore/QAbstractItemModel>
+
class BtmItem
{
public:
@@ -60,10 +61,12 @@ private:
};
+// -------------------------------------------------------------------------------------------------
+
+
class REKONQ_TESTS_EXPORT BookmarksTreeModel : public QAbstractItemModel
{
Q_OBJECT
- Q_DISABLE_COPY(BookmarksTreeModel)
public:
explicit BookmarksTreeModel(QObject *parent = 0);
@@ -95,19 +98,19 @@ public:
virtual Qt::DropActions supportedDropActions() const;
virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
-private slots:
+private Q_SLOTS:
void bookmarksChanged(const QString &groupAddress);
-signals:
+Q_SIGNALS:
void bookmarksUpdated();
private:
- BtmItem *m_root;
-
void resetModel();
void setRoot(KBookmarkGroup bmg);
void populate(BtmItem *node, KBookmarkGroup bmg);
KBookmark bookmarkForIndex(const QModelIndex &index) const;
+
+ BtmItem *m_root;
};
#endif // BOOKMARKSTREEMODEL_H
diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp
index 84f2296e..28f7f4ee 100644
--- a/src/history/historypanel.cpp
+++ b/src/history/historypanel.cpp
@@ -27,6 +27,7 @@
// Self Includes
#include "historypanel.h"
+#include "historypanel.moc"
// Auto Includes
#include "rekonq.h"
@@ -67,22 +68,22 @@ void HistoryPanel::contextMenuItem(const QPoint &pos)
KAction* action;
action = new KAction(KIcon("tab-new"), i18n("Open"), this);
- connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInCurrentTab()));
+ connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(openInCurrentTab()));
menu.addAction(action);
action = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this);
- connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewTab()));
+ connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(openInNewTab()));
menu.addAction(action);
action = new KAction(KIcon("window-new"), i18n("Open in New Window"), this);
- connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewWindow()));
+ connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(openInNewWindow()));
menu.addAction(action);
action = new KAction(KIcon("edit-copy"), i18n("Copy Link Address"), this);
- connect(action, SIGNAL(triggered()), m_treeView, SLOT(copyToClipboard()));
+ connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(copyToClipboard()));
menu.addAction(action);
- menu.exec(m_treeView->mapToGlobal(pos));
+ menu.exec(panelTreeView()->mapToGlobal(pos));
}
@@ -95,7 +96,7 @@ void HistoryPanel::contextMenuGroup(const QPoint &pos)
connect(action, SIGNAL(triggered()), this, SLOT(openAll()));
menu.addAction(action);
- menu.exec(m_treeView->mapToGlobal(pos));
+ menu.exec(panelTreeView()->mapToGlobal(pos));
}
@@ -106,7 +107,7 @@ void HistoryPanel::contextMenuEmpty(const QPoint& /*pos*/)
void HistoryPanel::openAll()
{
- QModelIndex index = m_treeView->currentIndex();
+ QModelIndex index = panelTreeView()->currentIndex();
if (!index.isValid())
return;
@@ -136,10 +137,10 @@ void HistoryPanel::setup()
UrlPanel::setup();
kDebug() << "History panel...";
- m_treeView->header()->hideSection(1);
+ panelTreeView()->header()->hideSection(1);
- const UrlFilterProxyModel *proxy = static_cast<const UrlFilterProxyModel*>(m_treeView->model());
- m_treeView->expand(proxy->index(0, 0));
+ const UrlFilterProxyModel *proxy = static_cast<const UrlFilterProxyModel*>(panelTreeView()->model());
+ panelTreeView()->expand(proxy->index(0, 0));
}
diff --git a/src/history/historypanel.h b/src/history/historypanel.h
index 9c9d4a4e..0a5ae216 100644
--- a/src/history/historypanel.h
+++ b/src/history/historypanel.h
@@ -44,7 +44,7 @@ public:
explicit HistoryPanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
virtual ~HistoryPanel();
-private slots:
+private Q_SLOTS:
virtual void contextMenuItem(const QPoint &pos);
virtual void contextMenuGroup(const QPoint &pos);
virtual void contextMenuEmpty(const QPoint &pos);
@@ -53,7 +53,6 @@ private slots:
private:
virtual void setup();
-
virtual QAbstractItemModel* getModel();
};
diff --git a/src/search/opensearchmanager.cpp b/src/search/opensearchmanager.cpp
index 9670a6a2..c2ac1ddb 100644
--- a/src/search/opensearchmanager.cpp
+++ b/src/search/opensearchmanager.cpp
@@ -114,6 +114,7 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl
{
disconnect(m_currentJob);
m_currentJob->kill();
+ delete m_currentJob;
}
m_jobData.clear();
@@ -149,7 +150,8 @@ void OpenSearchManager::requestSuggestion(const QString &searchText)
if (m_currentJob)
{
disconnect(m_currentJob);
- m_currentJob->kill();
+ m_currentJob->kill();
+ delete m_currentJob;
}
m_jobData.clear();
diff --git a/src/search/searchengine.cpp b/src/search/searchengine.cpp
index 38f063a4..89e62dee 100644
--- a/src/search/searchengine.cpp
+++ b/src/search/searchengine.cpp
@@ -111,7 +111,7 @@ KService::Ptr SearchEngine::defaultEngine()
}
-KService::Ptr SearchEngine::fromString(QString text)
+KService::Ptr SearchEngine::fromString(const QString &text)
{
KService::List providers = KServiceTypeTrader::self()->query("SearchProvider");
int i = 0;
@@ -136,12 +136,22 @@ KService::Ptr SearchEngine::fromString(QString text)
}
-QString SearchEngine::buildQuery(KService::Ptr engine, QString text)
+QString SearchEngine::extractQuery(const QString &text)
{
- QString query = engine->property("Query").toString();
- query = query.replace("\\{@}", KUrl::toPercentEncoding(text));
+ QString query = text;
+ KService::Ptr engine = SearchEngine::fromString(text);
+ if (engine)
+ {
+ query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
+ }
+
return query;
}
-
+QString SearchEngine::buildQuery(KService::Ptr engine, const QString &text)
+{
+ QString query = engine->property("Query").toString();
+ query = query.replace("\\{@}", KUrl::toPercentEncoding(text));
+ return query;
+}
diff --git a/src/search/searchengine.h b/src/search/searchengine.h
index e57b1a5c..d813666b 100644
--- a/src/search/searchengine.h
+++ b/src/search/searchengine.h
@@ -45,9 +45,10 @@ public:
static QString delimiter();
static KService::Ptr defaultEngine();
static KService::List favorites();
- static KService::Ptr fromString(QString text);
- static QString buildQuery(KService::Ptr engine, QString text);
-
+ static KService::Ptr fromString(const QString &text);
+ static QString buildQuery(KService::Ptr engine, const QString &text);
+ static QString extractQuery(const QString &text);
+
private:
static bool m_loaded;
static QString m_delimiter;
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 2199dfdf..a2bf5dbc 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -55,7 +55,6 @@ CompletionWidget::CompletionWidget(QWidget *parent)
: QFrame(parent, Qt::ToolTip)
, _parent(parent)
, _currentIndex(0)
- , _searchEngine(SearchEngine::defaultEngine())
, _hasSuggestions(false)
{
setFrameStyle(QFrame::Panel);
@@ -71,7 +70,7 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString
{
if (!isVisible())
{
- _searchEngine = SearchEngine::defaultEngine();
+ UrlResolver::setSearchEngine(SearchEngine::defaultEngine());
}
_list = list;
@@ -278,14 +277,15 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev)
if( _currentIndex == -1)
_currentIndex = 0;
child = findChild<ListItem *>(QString::number(_currentIndex));
- if(child)
+ if(child && _currentIndex!=0) //the completionwidget is visible and the user had press down
{
+ //we can use the url of the listitem
emit chosenUrl(child->url(), Rekonq::CurrentTab);
}
- else
+ else //the user type too fast (completionwidget not visible or suggestion not downloaded)
{
- // this will be used just on fast typing..
- emit chosenUrl(KUrl(w->text()), Rekonq::CurrentTab);
+ UrlResolver res(w->text());
+ emit chosenUrl(res.orderedSearchItems().first().url, Rekonq::CurrentTab);
}
kev->accept();
hide();
@@ -320,10 +320,15 @@ void CompletionWidget::setVisible(bool visible)
void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button, Qt::KeyboardModifiers modifier)
{
- if (button == Qt::MidButton || modifier == Qt::ControlModifier)
+ if (button == Qt::MidButton
+ || modifier == Qt::ControlModifier)
+ {
emit chosenUrl(item->url(), Rekonq::NewFocusedTab);
+ }
else
+ {
emit chosenUrl(item->url(), Rekonq::CurrentTab);
+ }
hide();
}
@@ -344,6 +349,6 @@ void CompletionWidget::suggestUrls(const QString &text)
UrlResolver *res = new UrlResolver(text);
connect(res, SIGNAL(suggestionsReady(const UrlSearchList &, const QString &)), this, SLOT(updateSearchList(const UrlSearchList &, const QString &)));
+ res->computeSuggestions();
_resList = res->orderedSearchItems();
-
}
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
index 7f6c93f0..6545b11d 100644
--- a/src/urlbar/completionwidget.h
+++ b/src/urlbar/completionwidget.h
@@ -51,16 +51,6 @@ public:
virtual bool eventFilter(QObject *obj, QEvent *ev);
void setVisible(bool visible);
- KService::Ptr searchEngine()
- {
- return _searchEngine;
- };
-
- void setSearchEngine(KService::Ptr engine)
- {
- _searchEngine = engine;
- };
-
void suggestUrls(const QString &text);
private slots:
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index 6c09f9a5..5ff90056 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -212,12 +212,11 @@ TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget
const bool wasItalic = t.startsWith("<i>");
if (wasItalic)
t.remove(QRegExp("<[/ib]*>"));
+
t = Qt::escape(t);
- QStringList words = textToPointOut.split(" ");
- foreach (const QString &wordToPointOut, words) {
- if (!wordToPointOut.isEmpty())
- t.replace(QRegExp('(' + wordToPointOut + ')', Qt::CaseInsensitive), "<b>\\1</b>");
- }
+ QString ss = Qt::escape(textToPointOut);
+ t.replace(QRegExp('(' + ss + ')', Qt::CaseInsensitive), "<b>\\1</b>");
+
if (wasItalic)
t = QL1S("<i>") + t + QL1S("</i>");
@@ -226,6 +225,19 @@ TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget
}
+TextLabel::TextLabel(QWidget *parent)
+ : QLabel(parent)
+{
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
+}
+
+
+void TextLabel::setEngineText(const QString &engine, const QString &text)
+{
+ setText( i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, Qt::escape(text) ) );
+}
+
+
//--------------------------------------------------------------------------------------------
@@ -290,23 +302,11 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q
: ListItem(item, parent)
, m_text(text)
{
- QString query = text;
- KService::Ptr engine = SearchEngine::fromString(text);
- if (engine)
- {
- query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
- }
- else
- {
- engine = qobject_cast<CompletionWidget *>(parent)->searchEngine();
- }
-
- m_url = SearchEngine::buildQuery(engine, query);
-
- KIcon icon = Application::iconManager()->iconForUrl( SearchEngine::defaultEngine()->property("Query").toUrl() );
- m_iconLabel = new IconLabel(icon, this); //TODO: get the default engine icon (will be easy in KDE SC 4.5)
- m_titleLabel = new TextLabel(searchItemTitle(engine->name(), query), query, this);
- m_engineBar = new EngineBar(engine, parent);
+ m_iconLabel = new IconLabel(SearchEngine::buildQuery(UrlResolver::searchEngine(), ""), this);
+ QString query = SearchEngine::extractQuery(text);
+ m_titleLabel = new TextLabel(this);
+ m_titleLabel->setEngineText(item.title, query);
+ m_engineBar = new EngineBar(UrlResolver::searchEngine(), parent);
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->setSpacing(4);
@@ -329,18 +329,18 @@ QString SearchListItem::text()
}
-QString SearchListItem::searchItemTitle(QString engine, QString text)
-{
- return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for %2", engine, Qt::escape(text)));
-}
+// QString SearchListItem::searchItemTitle(QString engine, QString text)
+// {
+// return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for %2", engine, text));
+// }
void SearchListItem::changeSearchEngine(KService::Ptr engine)
{
- m_titleLabel->setText(searchItemTitle(engine->name(), m_text));
+ m_titleLabel->setEngineText(engine->name(), m_text);
m_iconLabel->setPixmap( Application::iconManager()->iconForUrl(KUrl(engine->property("Query").toString())).pixmap(16) );
m_url = SearchEngine::buildQuery(engine, m_text);
- qobject_cast<CompletionWidget *>(parent())->setSearchEngine(engine);
+ UrlResolver::setSearchEngine(engine);
}
@@ -429,21 +429,8 @@ SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->setSpacing(4);
- QString query = item.title;
- KService::Ptr engine = SearchEngine::fromString(query);
- if (engine)
- {
- query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
- }
- else
- {
- engine = qobject_cast<CompletionWidget *>(parent)->searchEngine();
- }
-
- m_url = SearchEngine::buildQuery(engine, query);
-
- hLayout->addWidget(new IconLabel(SearchEngine::buildQuery(engine, ""), this));
- hLayout->addWidget(new TextLabel(item.title, text, this));
+ hLayout->addWidget(new IconLabel(SearchEngine::buildQuery(UrlResolver::searchEngine(), ""), this));
+ hLayout->addWidget(new TextLabel(item.title, SearchEngine::extractQuery(text), this));
hLayout->addWidget(new TypeIconLabel(item.type, this));
setLayout(hLayout);
diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h
index 37b22f47..be5a2569 100644
--- a/src/urlbar/listitem.h
+++ b/src/urlbar/listitem.h
@@ -121,6 +121,9 @@ class TextLabel : public QLabel
public:
explicit TextLabel(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0);
+ explicit TextLabel(QWidget *parent = 0);
+
+ void setEngineText(const QString &engine, const QString &text);
};
@@ -165,8 +168,6 @@ private slots:
void changeSearchEngine(KService::Ptr engine);
private:
- QString searchItemTitle(QString engine, QString text);
-
TextLabel* m_titleLabel;
IconLabel* m_iconLabel;
EngineBar* m_engineBar;
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index b6d7e598..7f6a7f4f 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -26,6 +26,7 @@
// Self Includes
#include "urlresolver.h"
+#include "urlresolver.moc"
// Local Includes
#include "application.h"
@@ -59,14 +60,18 @@
// ------------------------------------------------------------------------
+KService::Ptr UrlResolver::_searchEngine;
QRegExp UrlResolver::_browseRegexp;
QRegExp UrlResolver::_searchEnginesRegexp;
+
UrlResolver::UrlResolver(const QString &typedUrl)
: QObject()
, _typedString(typedUrl.trimmed())
{
+ if (!_searchEngine ) _searchEngine = SearchEngine::defaultEngine();
+
if ( _browseRegexp.isEmpty() )
{
kDebug() << "browse regexp empty. Setting value..";
@@ -107,8 +112,6 @@ UrlResolver::UrlResolver(const QString &typedUrl)
}
_searchEnginesRegexp = QRegExp(reg);
}
-
- computeSuggestions();
}
@@ -330,7 +333,15 @@ void UrlResolver::computeQurlFromUserInput()
//webSearches
void UrlResolver::computeWebSearches()
{
- _webSearches = (UrlSearchList() << UrlSearchItem(UrlSearchItem::Search, QString(), QString()));
+ QString query = _typedString;
+ KService::Ptr engine = SearchEngine::fromString(_typedString);
+ if (engine)
+ {
+ query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1);
+ _searchEngine = engine;
+ }
+
+ _webSearches = (UrlSearchList() << UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), _searchEngine->name()));
}
@@ -367,6 +378,15 @@ void UrlResolver::computeBookmarks()
//opensearch suggestion
void UrlResolver::computeSuggestions()
{
+ // if a string startsWith /, it is probably a local path
+ // so, no need for suggestions...
+ if(_typedString.startsWith('/'))
+ {
+ UrlSearchList list;
+ emit suggestionsReady(list, _typedString);
+ return;
+ }
+
if (Application::opensearchManager()->isSuggestionAvailable())
{
connect(Application::opensearchManager(),
@@ -375,7 +395,7 @@ void UrlResolver::computeSuggestions()
SLOT(suggestionsReceived(const QString &, const QStringList &)));
Application::opensearchManager()->requestSuggestion(_typedString);
- }
+ }
}
diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h
index 4e85e917..f16c44f8 100644
--- a/src/urlbar/urlresolver.h
+++ b/src/urlbar/urlresolver.h
@@ -33,13 +33,14 @@
// KDE Includes
#include <KUrl>
-
+#include <KService>
// Qt Includes
#include <QString>
#include <QList>
#include <QStringList>
+
class UrlSearchItem
{
public:
@@ -104,33 +105,46 @@ public:
UrlSearchList orderedSearchItems();
-private:
- QString _typedString;
+ static KService::Ptr searchEngine()
+ {
+ return _searchEngine;
+ };
- UrlSearchList _webSearches;
- UrlSearchList _qurlFromUserInput;
- UrlSearchList _history;
- UrlSearchList _bookmarks;
- UrlSearchList _suggestions;
-
+ static void setSearchEngine(KService::Ptr engine)
+ {
+ _searchEngine = engine;
+ };
+
+ void computeSuggestions();
+
+private Q_SLOTS:
+ void suggestionsReceived(const QString &text, const QStringList &suggestions);
+
+Q_SIGNALS:
+ void suggestionsReady(const UrlSearchList &, const QString &);
+
+private:
void computeWebSearches();
void computeHistory();
void computeQurlFromUserInput();
void computeBookmarks();
- void computeSuggestions();
UrlSearchItem privilegedItem(UrlSearchList* list);
UrlSearchList orderLists();
- static QRegExp _browseRegexp;
- static QRegExp _searchEnginesRegexp;
-private slots:
- void suggestionsReceived(const QString &text, const QStringList &suggestions);
+ QString _typedString;
-Q_SIGNALS:
- void suggestionsReady(const UrlSearchList &, const QString &);
+ UrlSearchList _webSearches;
+ UrlSearchList _qurlFromUserInput;
+ UrlSearchList _history;
+ UrlSearchList _bookmarks;
+ UrlSearchList _suggestions;
+ static QRegExp _browseRegexp;
+ static QRegExp _searchEnginesRegexp;
+
+ static KService::Ptr _searchEngine;
};
// ------------------------------------------------------------------------------
diff --git a/src/urlfilterproxymodel.cpp b/src/urlfilterproxymodel.cpp
index b8e68342..f1d60002 100644
--- a/src/urlfilterproxymodel.cpp
+++ b/src/urlfilterproxymodel.cpp
@@ -27,6 +27,7 @@
// Self Includes
#include "urlfilterproxymodel.h"
+#include "urlfilterproxymodel.moc"
UrlFilterProxyModel::UrlFilterProxyModel(QObject *parent)
diff --git a/src/urlfilterproxymodel.h b/src/urlfilterproxymodel.h
index f4f15395..06592c27 100644
--- a/src/urlfilterproxymodel.h
+++ b/src/urlfilterproxymodel.h
@@ -35,15 +35,17 @@
// Qt Includes
#include <QtGui/QSortFilterProxyModel>
+
/**
* QSortFilterProxyModel hides all children which parent doesn't
* match the filter. This class is used to change this behavior.
- * If a url matches the filter it'll be shown, even if it's parent doesn't match it.
+ * If a url matches the filter it'll be shown,
+ * even if it's parent doesn't match it.
+ *
*/
class REKONQ_TESTS_EXPORT UrlFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
- Q_DISABLE_COPY(UrlFilterProxyModel)
public:
UrlFilterProxyModel(QObject *parent = 0);
diff --git a/src/urlpanel.cpp b/src/urlpanel.cpp
index 86246fd9..cf6aec7b 100644
--- a/src/urlpanel.cpp
+++ b/src/urlpanel.cpp
@@ -27,6 +27,7 @@
// Self Includes
#include "urlpanel.h"
+#include "urlpanel.moc"
// Auto Includes
#include "rekonq.h"
@@ -47,7 +48,7 @@
UrlPanel::UrlPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags)
: QDockWidget(title, parent, flags)
- , m_treeView(new PanelTreeView(this))
+ , _treeView(new PanelTreeView(this))
, _loaded(false)
{
setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
@@ -88,14 +89,14 @@ void UrlPanel::setup()
searchLabel->setBuddy(search);
// setup tree view
- m_treeView->setUniformRowHeights(true);
- m_treeView->header()->hide();
+ _treeView->setUniformRowHeights(true);
+ _treeView->header()->hide();
// put everything together
QVBoxLayout *vBoxLayout = new QVBoxLayout;
vBoxLayout->setContentsMargins(0, 0, 0, 0);
vBoxLayout->addLayout(searchLayout);
- vBoxLayout->addWidget(m_treeView);
+ vBoxLayout->addWidget(_treeView);
// add it to the UI
ui->setLayout(vBoxLayout);
@@ -104,11 +105,11 @@ void UrlPanel::setup()
QAbstractItemModel *model = getModel();
UrlFilterProxyModel *proxy = new UrlFilterProxyModel(this);
proxy->setSourceModel(model);
- m_treeView->setModel(proxy);
+ _treeView->setModel(proxy);
connect(search, SIGNAL(textChanged(QString)), proxy, SLOT(setFilterFixedString(QString)));
- connect(m_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenuItem(const QPoint &)));
- connect(m_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenuGroup(const QPoint &)));
- connect(m_treeView, SIGNAL(contextMenuEmptyRequested(const QPoint &)), this, SLOT(contextMenuEmpty(const QPoint &)));
+ connect(_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenuItem(const QPoint &)));
+ connect(_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenuGroup(const QPoint &)));
+ connect(_treeView, SIGNAL(contextMenuEmptyRequested(const QPoint &)), this, SLOT(contextMenuEmpty(const QPoint &)));
}
diff --git a/src/urlpanel.h b/src/urlpanel.h
index b4ca2aa5..2bf1c3fe 100644
--- a/src/urlpanel.h
+++ b/src/urlpanel.h
@@ -49,26 +49,26 @@ public:
explicit UrlPanel(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
virtual ~UrlPanel();
-public slots:
+ inline PanelTreeView *panelTreeView() const { return _treeView; };
+
+public Q_SLOTS:
void showing(bool);
-signals:
- void openUrl(const KUrl &, const Rekonq::OpenType &);
- void itemHovered(const QString &);
-
-protected slots:
+protected Q_SLOTS:
virtual void contextMenuItem(const QPoint &pos) = 0;
virtual void contextMenuGroup(const QPoint &pos) = 0;
virtual void contextMenuEmpty(const QPoint &pos) = 0;
protected:
virtual void setup();
-
virtual QAbstractItemModel* getModel() = 0;
- PanelTreeView *m_treeView;
+Q_SIGNALS:
+ void openUrl(const KUrl &, const Rekonq::OpenType &);
+ void itemHovered(const QString &);
private:
+ PanelTreeView *_treeView;
bool _loaded;
};