summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-05-12 00:48:21 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-05-15 09:53:43 +0200
commita5ac500d91f8f15c5fd8becd3a2a387da633324f (patch)
tree1cc9b75320f03bf4a97fd6c396d72c36ffff03e6 /src
parentNo more lined titles in history and tabs pages (diff)
downloadrekonq-a5ac500d91f8f15c5fd8becd3a2a387da633324f.tar.xz
History search
Diffstat (limited to 'src')
-rw-r--r--src/data/home.html2
-rw-r--r--src/newtabpage.cpp76
-rw-r--r--src/newtabpage.h6
3 files changed, 70 insertions, 14 deletions
diff --git a/src/data/home.html b/src/data/home.html
index 5c2b78e1..73f4e829 100644
--- a/src/data/home.html
+++ b/src/data/home.html
@@ -232,6 +232,8 @@ text-align: center;
</div>
<div id="models" style="display:none">
+ <form></form>
+ <input></input>
<div></div>
<div class="link">
<a href="">
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index 0ed711bf..7cf9a8a4 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -43,6 +43,7 @@
#include "mainwindow.h"
#include "previewselectorbar.h"
#include "thumbupdater.h"
+#include "urlfilterproxymodel.h"
#include "websnap.h"
#include "webpage.h"
#include "webtab.h"
@@ -189,6 +190,14 @@ void NewTabPage::generate(const KUrl &url)
loadPageForUrl(KUrl("about:history"));
return;
}
+
+ if (url.fileName() == QL1S("search"))
+ {
+ QString value = url.queryItemValue( QL1S("q") );
+ loadPageForUrl(KUrl("about:history"), value);
+ return;
+ }
+
}
if (url == KUrl("about:downloads/clear"))
@@ -208,7 +217,7 @@ void NewTabPage::generate(const KUrl &url)
}
-void NewTabPage::loadPageForUrl(const KUrl &url)
+void NewTabPage::loadPageForUrl(const KUrl &url, const QString & filter)
{
// webFrame can be null. See bug:282092
QWebFrame *parentFrame = qobject_cast<QWebFrame *>(parent());
@@ -240,7 +249,7 @@ void NewTabPage::loadPageForUrl(const KUrl &url)
}
else if (encodedUrl == QByteArray("about:history"))
{
- historyPage();
+ historyPage(filter);
updateWindowIcon();
title = i18n("History");
}
@@ -358,10 +367,13 @@ void NewTabPage::favoritesPage()
}
-void NewTabPage::historyPage()
+void NewTabPage::historyPage(const QString & filter)
{
m_root.addClass(QL1S("history"));
+ const QWebElement searchForm = createFormItem(i18n("Search History"), QL1S("about:history/search"));
+ m_root.document().findFirst(QL1S("#actions")).appendInside(searchForm);
+
const QWebElement clearHistory = createLinkItem(i18n("Clear History"),
QL1S("about:history/clear"),
QL1S("edit-clear"),
@@ -369,11 +381,26 @@ void NewTabPage::historyPage()
m_root.document().findFirst(QL1S("#actions")).appendInside(clearHistory);
HistoryTreeModel *model = rApp->historyManager()->historyTreeModel();
+ UrlFilterProxyModel *proxy = new UrlFilterProxyModel(this);
+ proxy->setSourceModel(model);
- if (model->rowCount() == 0)
+ bool filterIsEmpty = filter.isEmpty();
+
+ if (!filterIsEmpty)
+ proxy->setFilterFixedString(filter);
+
+ if (proxy->rowCount() == 0)
{
- m_root.addClass(QL1S("empty"));
- m_root.setPlainText(i18n("Your browsing history is empty"));
+ if (filterIsEmpty)
+ {
+ m_root.addClass(QL1S("empty"));
+ m_root.setPlainText(i18n("Your browsing history is empty"));
+ }
+ else
+ {
+ m_root.addClass(QL1S("empty"));
+ m_root.setPlainText(i18n("No matches for string %1 in history", filter));
+ }
return;
}
@@ -382,17 +409,17 @@ void NewTabPage::historyPage()
const int truncateSize = 100;
do
{
- QModelIndex index = model->index(i, 0, QModelIndex());
- if (model->hasChildren(index))
+ QModelIndex index = proxy->index(i, 0, QModelIndex());
+ if (proxy->hasChildren(index))
{
m_root.appendInside(markup(QL1S("h3")));
m_root.lastChild().setPlainText(index.data().toString());
m_root.appendInside(markup(QL1S(".folder")));
QWebElement little = m_root.lastChild();
- for (int j = 0; j < model->rowCount(index); ++j)
+ for (int j = 0; j < proxy->rowCount(index); ++j)
{
- QModelIndex son = model->index(j, 0, index);
+ QModelIndex son = proxy->index(j, 0, index);
KUrl u = son.data(HistoryModel::UrlStringRole).toUrl();
little.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm"));
@@ -417,7 +444,7 @@ void NewTabPage::historyPage()
}
}
i++;
- if (m_showFullHistory == false && (i == 2))
+ if (filterIsEmpty && m_showFullHistory == false && (i == 2))
{
m_root.appendInside(markup(QL1S("a")));
m_root.lastChild().setAttribute(QL1S("class") , QL1S("greybox"));
@@ -426,7 +453,7 @@ void NewTabPage::historyPage()
return;
}
}
- while (model->hasIndex(i , 0 , QModelIndex()));
+ while (proxy->hasIndex(i , 0 , QModelIndex()));
m_showFullHistory = false;
}
@@ -436,6 +463,9 @@ void NewTabPage::bookmarksPage()
{
m_root.addClass(QL1S("bookmarks"));
+ const QWebElement searchForm = createFormItem(i18n("Search Bookmarks"), QL1S("about:bookmarks/search"));
+ m_root.document().findFirst(QL1S("#actions")).appendInside(searchForm);
+
const QWebElement editBookmarks = createLinkItem(i18n("Edit Bookmarks"),
QL1S("about:bookmarks/edit"),
QL1S("bookmarks-organize"),
@@ -493,6 +523,9 @@ void NewTabPage::downloadsPage()
{
m_root.addClass(QL1S("downloads"));
+ const QWebElement searchForm = createFormItem(i18n("Search Downloads"), QL1S("about:download/search"));
+ m_root.document().findFirst(QL1S("#actions")).appendInside(searchForm);
+
const QWebElement clearDownloads = createLinkItem(i18n("Clear Downloads"),
QL1S("about:downloads/clear"),
QL1S("edit-clear"),
@@ -812,6 +845,25 @@ QWebElement NewTabPage::createLinkItem(const QString &title, const QString &urlS
}
+QWebElement NewTabPage::createFormItem(const QString &title, const QString &urlString) const
+{
+ QWebElement form = markup(QL1S("form"));
+
+ form.setAttribute(QL1S("method"), QL1S("GET"));
+ form.setAttribute(QL1S("action"), urlString);
+
+ form.appendInside(markup(QL1S("input")));
+ form.lastChild().setAttribute(QL1S("type"), QL1S("text"));
+ form.lastChild().setAttribute(QL1S("name"), QL1S("q"));
+
+ form.appendInside(markup(QL1S("input")));
+ form.lastChild().setAttribute(QL1S("type"), QL1S("submit"));
+ form.lastChild().setAttribute(QL1S("value"), title);
+
+ return form;
+}
+
+
void NewTabPage::updateWindowIcon()
{
int currentIndex = rApp->mainWindow()->mainView()->currentIndex();
diff --git a/src/newtabpage.h b/src/newtabpage.h
index 84c9c03e..8d446908 100644
--- a/src/newtabpage.h
+++ b/src/newtabpage.h
@@ -65,13 +65,13 @@ private:
void browsingMenu(const KUrl &currentUrl);
void favoritesPage();
- void historyPage();
+ void historyPage(const QString & filter = QString());
void bookmarksPage();
void closedTabsPage();
void downloadsPage();
void tabsPage();
- void loadPageForUrl(const KUrl &url);
+ void loadPageForUrl(const KUrl &url, const QString & filter = QString());
// --------------------------------------------------------------------------
// "low-level" functions
@@ -118,6 +118,8 @@ private:
private:
QWebElement createLinkItem(const QString &title, const QString &urlString, const QString &iconPath, int groupOrSize) const;
+ QWebElement createFormItem(const QString &title, const QString &urlString) const;
+
QString m_html;
QWebElement m_root;