summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-09-29 13:24:29 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-09-29 13:24:29 +0200
commit765d552196d75c22792c1fe073baad64ebe46945 (patch)
tree915e7de14fcb26f4723ae75f57ecdc4b4c48cf28
parentInitial fixes (diff)
downloadrekonq-765d552196d75c22792c1fe073baad64ebe46945.tar.xz
a lot fo changes in the history/bookmarks page (restored initial method rewamped)
-rw-r--r--data/home.html6
-rw-r--r--src/homepage.cpp74
-rw-r--r--src/homepage.h8
3 files changed, 62 insertions, 26 deletions
diff --git a/data/home.html b/data/home.html
index e1cd8905..c0d71f21 100644
--- a/data/home.html
+++ b/data/home.html
@@ -48,9 +48,9 @@ background: #3F7AB7;
margin: 2em 0;
}
-#thumbs {
+#content {
width: 100%;
-text-align: center;
+text-align: left;
}
/* -------------------------------------------------------- */
@@ -107,7 +107,7 @@ text-decoration:none;
<div id="container">
<div id="header"><h1>rekonq</h1></div>
<div id="navigation">%2</div>
-%3
+<div id="content">%3</div>
</div>
</body>
diff --git a/src/homepage.cpp b/src/homepage.cpp
index f79a3446..c57661c4 100644
--- a/src/homepage.cpp
+++ b/src/homepage.cpp
@@ -76,11 +76,11 @@ QString HomePage::rekonqHomePage(const KUrl &url)
QString speed;
if(url == KUrl("about:lastSites"))
- speed = fillRecentHistory();
+ speed = lastVisitedSites();
if(url == KUrl("about:history"))
- speed = history();
+ speed = fillHistory();
if(url == KUrl("about:bookmarks"))
- speed = bookmarks();
+ speed = fillBookmarks();
if(url == KUrl("about:home") || url == KUrl("about:preferred"))
speed = speedDial();
@@ -141,7 +141,7 @@ QString HomePage::recentlyClosedTabs()
}
-QString HomePage::fillRecentHistory()
+QString HomePage::lastVisitedSites()
{
QString history = "<h2>" + i18n("Last 20 visited sites") + "</h2>";
history += "<ul>";
@@ -186,41 +186,75 @@ QString HomePage::homePageMenu()
}
-QString HomePage::history()
+QString HomePage::fillHistory()
{
- QString history = "<h2>" + i18n("History") + "</h2>";
- history += "<ul>";
+ QString history = QString();
HistoryTreeModel *model = Application::historyManager()->historyTreeModel();
+
int i = 0;
do
{
QModelIndex index = model->index(i, 0, QModelIndex() );
if(model->hasChildren(index))
{
- for(int j=0; j< model->rowCount(index) && i<20 ; ++j)
+ history += "<tr colspan=\"2\"><td><h3>" + index.data().toString() + "</h3></td></tr>";
+ for(int j=0; j< model->rowCount(index); ++j)
{
QModelIndex son = model->index(j, 0, index );
-
- history += "<li>";
- history += QString("<a href=\"") + son.data(HistoryModel::UrlStringRole).toString() + QString("\">");
- history += son.data().toString();
- history += QString("</a>");
- history += "</li>";
-
- i++;
+ history += QString("<tr><td>") + son.data().toString() + QString("</td>");
+ history += QString("<td><a href=\"") + son.data(HistoryModel::UrlStringRole).toString() + QString("\">") +
+ son.data(HistoryModel::UrlStringRole).toString() + QString("</a></td></tr>");
}
}
i++;
}
- while( i<20 || model->hasIndex( i , 0 , QModelIndex() ) );
+ while( model->hasIndex( i , 0 , QModelIndex() ) );
- history += "<ul>";
return history;
+
}
-QString HomePage::bookmarks()
+QString HomePage::fillBookmarks()
{
- return QString("");
+ KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup();
+ if (bookGroup.isNull())
+ {
+ return QString("Error retrieving bookmarks!");
+ }
+
+ QString str = QString("<table>");
+ KBookmark bookmark = bookGroup.first();
+ while (!bookmark.isNull())
+ {
+ str += createBookItem(bookmark);
+ bookmark = bookGroup.next(bookmark);
+ }
+ str += QString("</table>");
+ return str;
}
+
+QString HomePage::createBookItem(const KBookmark &bookmark)
+{
+ if (bookmark.isGroup())
+ {
+ QString result = QString("");
+ KBookmarkGroup group = bookmark.toGroup();
+ KBookmark bm = group.first();
+ result += "<tr colspan=\"2\"><td><h3>" + bookmark.text() + "</h3></td></tr>";
+
+ while (!bm.isNull())
+ {
+ result += createBookItem(bm);
+ bm = group.next(bm);
+ }
+ return result;
+ }
+
+ if(bookmark.isSeparator())
+ {
+ return QString("<hr />");
+ }
+ return "<tr><td>" + bookmark.text() + "</td><td><a href=\"" + bookmark.url().prettyUrl() + "\">" + bookmark.url().prettyUrl() + "</a></td></tr>";
+}
diff --git a/src/homepage.h b/src/homepage.h
index 48fc4fa6..3c57f164 100644
--- a/src/homepage.h
+++ b/src/homepage.h
@@ -53,10 +53,12 @@ public:
private:
QString speedDial();
QString recentlyClosedTabs();
- QString fillRecentHistory();
- QString history();
- QString bookmarks();
+ QString lastVisitedSites();
+ QString fillHistory();
+ QString fillBookmarks();
+ QString createBookItem(const KBookmark &bookmark);
+
QString m_homePagePath;
};