summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-05-13 11:24:15 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-05-15 09:53:43 +0200
commit77cce058a4b5922916e364a1d0a57728b98e9cf3 (patch)
treef3627f0f6d9356d1498c0a5512a0325e18b2c5e6
parentDownloads search (diff)
downloadrekonq-77cce058a4b5922916e364a1d0a57728b98e9cf3.tar.xz
New Bookmarks page
-rw-r--r--src/data/home.html36
-rw-r--r--src/newtabpage.cpp52
-rw-r--r--src/newtabpage.h12
3 files changed, 72 insertions, 28 deletions
diff --git a/src/data/home.html b/src/data/home.html
index 73f4e829..f4b4d12d 100644
--- a/src/data/home.html
+++ b/src/data/home.html
@@ -47,6 +47,13 @@ margin: 1.5em 0 0.5em;
font: normal bold 1em;
}
+h4 {
+padding: 0.2em;
+margin: 1em 0 0.5em;
+font: normal bold 1em;
+border-bottom: 1px solid black;
+}
+
a {
color: #3F7AB7;
text-decoration: none;
@@ -181,11 +188,16 @@ color:#3F7AB7;
}
/* -------------------------------------------------------- */
-/* General */
+/* Bookmarks page */
-.folder {
-margin-left: 4em;
-margin-bottom: 1em;
+.bookmarkfolder {
+display: inline-block;
+background: #BBB;
+border-radius: 15px;
+padding: 0px 15px 15px 15px;
+float:left;
+margin: 1em;
+width: 28%;
}
/* -------------------------------------------------------- */
@@ -212,8 +224,15 @@ background: #CCC;
padding: 5px 10px;
}
+.historyfolder {
+margin-left: 4em;
+margin-bottom: 1em;
+}
+
+
/* -------------------------------------------------------- */
/* Empty pages : in the end : need to overwrite */
+
#content.empty {
margin-top: 10%;
text-align: center;
@@ -231,6 +250,11 @@ text-align: center;
<div id="content"></div>
</div>
+<!--
+NOTE: These models are NOT directly shown inside the page.
+They are just used inside NewTabPage::markup function to ease
+elements creation, cloning one of these.
+-->
<div id="models" style="display:none">
<form></form>
<input></input>
@@ -256,10 +280,12 @@ text-align: center;
</div>
</div>
<h3></h3>
+ <h4></h4>
<a></a>
<br />
<img />
- <p class="folder"></p>
+ <p class="historyfolder"></p>
+ <p class="bookmarkfolder"></p>
</div>
</body>
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index 153755fc..1cf003ae 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -427,7 +427,7 @@ void NewTabPage::historyPage(const QString & filter)
m_root.appendInside(markup(QL1S("h3")));
m_root.lastChild().setPlainText(index.data().toString());
- m_root.appendInside(markup(QL1S(".folder")));
+ m_root.appendInside(markup(QL1S(".historyfolder")));
QWebElement little = m_root.lastChild();
for (int j = 0; j < proxy->rowCount(index); ++j)
{
@@ -490,9 +490,15 @@ void NewTabPage::bookmarksPage()
}
KBookmark bookmark = bookGroup.first();
+
+ m_root.appendInside(markup(QL1S(".bookmarkfolder")));
+ QWebElement rootFolder = m_root.lastChild();
+ rootFolder.appendInside(markup(QL1S("h4")));
+ rootFolder.lastChild().setPlainText(i18n("ROOT"));
+
while (!bookmark.isNull())
{
- createBookItem(bookmark, m_root);
+ createBookmarkItem(bookmark, rootFolder);
bookmark = bookGroup.next(bookmark);
}
}
@@ -801,25 +807,37 @@ void NewTabPage::removePreview(int index)
}
-void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent)
+void NewTabPage::createBookmarkGroup(const KBookmark &bookmark, QWebElement parent)
+{
+ KBookmarkGroup group = bookmark.toGroup();
+ KBookmark bm = group.first();
+
+ parent.appendInside(markup(QL1S(".bookmarkfolder")));
+ QWebElement folder = parent.lastChild();
+ folder.appendInside(markup(QL1S("h4")));
+ folder.lastChild().setPlainText(group.fullText());
+
+ while (!bm.isNull())
+ {
+ createBookmarkItem(bm, folder);
+ bm = group.next(bm);
+ }
+}
+
+
+void NewTabPage::createBookmarkItem(const KBookmark &bookmark, QWebElement parent)
{
QString cacheDir = QL1S("file://") + KStandardDirs::locateLocal("cache" , "" , true);
QString icon = QL1S("file://") + KGlobal::dirs()->findResource("icon", "oxygen/16x16/mimetypes/text-html.png");
+
if (bookmark.isGroup())
{
- KBookmarkGroup group = bookmark.toGroup();
- KBookmark bm = group.first();
- parent.appendInside(markup(QL1S("h3")));
- parent.lastChild().setPlainText(group.fullText());
- parent.appendInside(markup(QL1S(".folder")));
- while (!bm.isNull())
- {
- createBookItem(bm, parent.lastChild()); // it is .folder
- bm = group.next(bm);
- }
+ createBookmarkGroup(bookmark, m_root);
+ return;
}
else if (bookmark.isSeparator())
{
+ kDebug() << "SEPARATOR";
parent.appendInside(QL1S("<hr />"));
}
else
@@ -835,18 +853,18 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent)
parent.appendInside(QL1S(" "));
parent.appendInside(markup(QL1S("a")));
parent.lastChild().setAttribute(QL1S("href") , bookmark.url().prettyUrl());
- parent.lastChild().setPlainText(bookmark.fullText());
+ parent.lastChild().setPlainText( checkTitle(bookmark.fullText(), 40) );
parent.appendInside(QL1S("<br />"));
}
}
-QString NewTabPage::checkTitle(const QString &title)
+QString NewTabPage::checkTitle(const QString &title, int max)
{
QString t(title);
- if (t.length() > 23)
+ if (t.length() > max)
{
- t.truncate(20);
+ t.truncate(max - 3);
t += QL1S("...");
}
return t;
diff --git a/src/newtabpage.h b/src/newtabpage.h
index a9e618db..857e0db6 100644
--- a/src/newtabpage.h
+++ b/src/newtabpage.h
@@ -96,8 +96,12 @@ private:
void setupPreview(QWebElement e, int index);
void setupTabPreview(QWebElement e, int winIndex, int tabIndex);
- void createBookItem(const KBookmark &bookmark, QWebElement parent);
+ void createBookmarkItem(const KBookmark &bookmark, QWebElement parent);
+ void createBookmarkGroup(const KBookmark &bookmark, QWebElement parent);
+ QWebElement createLinkItem(const QString &title, const QString &urlString, const QString &iconPath, int groupOrSize) const;
+ QWebElement createFormItem(const QString &title, const QString &urlString) const;
+
/**
* This function helps to get faster a new markup of one type,
* it isn't easy to create one with QWebElement.
@@ -111,15 +115,11 @@ private:
return m_root.document().findFirst("#models > " + selector).clone();
}
- QString checkTitle(const QString &title);
+ QString checkTitle(const QString &title, int max = 23);
void updateWindowIcon();
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;