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/newtabpage.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'src/newtabpage.cpp') 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