From 6885b2d1a51dff26fd4286d01fa71d5c39ed7eb9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 12 Dec 2011 18:25:18 +0100 Subject: Small cleanup in history pages - created a "general" folder css class - truncated links titles longer than 100 chars - improved upper margin in titles --- src/data/home.html | 8 ++++---- src/newtabpage.cpp | 38 +++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/data/home.html b/src/data/home.html index df8f4092..13607fb4 100644 --- a/src/data/home.html +++ b/src/data/home.html @@ -33,7 +33,7 @@ margin: 0 1% 2% 1%; h3 { border-bottom-width: 1px; -webkit-border-image: url(%2/category.png) 1 1 1 1 stretch stretch; -padding: 0.2em; margin: 0.5em 0; +padding: 0.2em; margin: 1.5em 0 0.5em; font: normal bold 1em; } @@ -169,9 +169,9 @@ color:#3F7AB7; } /* -------------------------------------------------------- */ -/* Bookmarks page */ +/* General */ -.bookfolder{ +.folder{ margin-left: 2em; margin-bottom: 0.5em; } @@ -241,7 +241,7 @@ text-align: center;
-

+

diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 52b83bbd..f8d8976d 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -418,6 +418,8 @@ void NewTabPage::historyPage() int i = 0; QString faviconsDir = KStandardDirs::locateLocal("cache" , "favicons/" , true); QString icon = QL1S("file://") + KGlobal::dirs()->findResource("icon", "oxygen/16x16/mimetypes/text-html.png"); + const int maxTextSize = 103; + const int truncateSize = 100; do { QModelIndex index = model->index(i, 0, QModelIndex()); @@ -426,6 +428,8 @@ void NewTabPage::historyPage() 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) { QModelIndex son = model->index(j, 0, index); @@ -435,17 +439,25 @@ void NewTabPage::historyPage() if (QFile::exists(b)) icon = QL1S("file://") + b; - m_root.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm")); - m_root.appendInside(QL1S(" ")); - m_root.appendInside(markup(QL1S("img"))); - m_root.lastChild().setAttribute(QL1S("src"), icon); - m_root.lastChild().setAttribute(QL1S("width"), QL1S("16")); - m_root.lastChild().setAttribute(QL1S("height"), QL1S("16")); - m_root.appendInside(QL1S(" ")); - m_root.appendInside(markup(QL1S("a"))); - m_root.lastChild().setAttribute(QL1S("href") , u.url()); - m_root.lastChild().appendInside(son.data().toString()); - m_root.appendInside(QL1S("
")); + little.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm")); + little.appendInside(QL1S("  ")); + little.appendInside(markup(QL1S("img"))); + little.lastChild().setAttribute(QL1S("src"), icon); + little.lastChild().setAttribute(QL1S("width"), QL1S("16")); + little.lastChild().setAttribute(QL1S("height"), QL1S("16")); + little.appendInside(QL1S("  ")); + little.appendInside(markup(QL1S("a"))); + little.lastChild().setAttribute(QL1S("href") , u.url()); + + QString shownUrl = son.data().toString(); + if (shownUrl.length() > maxTextSize) + { + shownUrl.truncate(truncateSize); + shownUrl += QL1S("..."); + } + little.lastChild().appendInside(shownUrl); + + little.appendInside(QL1S("
")); } } i++; @@ -491,10 +503,10 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) KBookmark bm = group.first(); parent.appendInside(markup(QL1S("h3"))); parent.lastChild().setPlainText(group.fullText()); - parent.appendInside(markup(QL1S(".bookfolder"))); + parent.appendInside(markup(QL1S(".folder"))); while (!bm.isNull()) { - createBookItem(bm, parent.lastChild()); // it is .bookfolder + createBookItem(bm, parent.lastChild()); // it is .folder bm = group.next(bm); } } -- cgit v1.2.1