From 7c6db1a17dbede4911d2c13cd36a485272f3e5a4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 13 Sep 2009 18:20:57 +0200 Subject: We have thumbnails! Hugh! --- src/homepage.cpp | 216 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 129 insertions(+), 87 deletions(-) (limited to 'src/homepage.cpp') diff --git a/src/homepage.cpp b/src/homepage.cpp index 6acd4afd..59078c51 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -32,6 +32,7 @@ #include "historymodels.h" #include "bookmarks.h" #include "application.h" +#include "websnap.h" // KDE Includes #include @@ -46,7 +47,6 @@ HomePage::HomePage(QObject *parent) : QObject(parent) { m_homePagePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); - m_imagesPath = "file://" + KStandardDirs::locate("appdata", "pics/"); } @@ -65,114 +65,156 @@ QString HomePage::rekonqHomePage() return QString(""); } - QString history = fillHistory(); - - QString bookmarks = fillBookmarks(); + QString speed = speedDial(); + QString search = searchEngines(); + QString closedtabs = recentlyClosedTabs(); + QString html = QString(QLatin1String(file.readAll())) - .arg(m_imagesPath) - .arg(history) - .arg(bookmarks); + .arg(search) + .arg(closedtabs) + .arg(speed) + ; return html; } -QString HomePage::fillHistory() +QString HomePage::speedDial() { - QString history = QString(); - HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); + KUrl::List ul ; + ul << KUrl("http://www.google.it") << KUrl("http://www.kde.org") << KUrl("http://rekonq.sourceforge.net") + << KUrl("http://www.slacky.eu") << KUrl("http://kde-apps.org") << KUrl("http://www.kernel.org") + << KUrl("http://it.wikipedia.org") << KUrl("http://www.adjam.org") << KUrl("http://adjamblog.wordpress.com"); - int i = 0; - do + QString speed = QString(); + for(int i = 0; i< ul.count(); ++i) { - QModelIndex index = model->index(i, 0, QModelIndex() ); - if(model->hasChildren(index)) - { - QString s = QString::number(i); - history += createSubMenu(index.data().toString(), s); - history += "

"; - for(int j=0; j< model->rowCount(index); ++j) - { - QModelIndex son = model->index(j, 0, index ); -// FIXME add an icon to each history item history += "\"icon\""; - history += QString("") + - son.data().toString() + QString("
"); - } - history += "

"; - } - else + KUrl url = ul.at(i); + QString fileName = QString("thumb") + QString::number(i) + QString(".png"); + QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + fileName, true); + if( !QFile::exists(path) ) { - history += QString("

NO CHILDREN: ") + index.data().toString() + QString("

"); + kDebug() << "websnap"; + WebSnap *ws = new WebSnap(url, fileName); } - i++; + + speed += "\"""; } - while( model->hasIndex( i , 0 , QModelIndex() ) ); - - return history; - + return speed; } -QString HomePage::fillBookmarks() +QString HomePage::searchEngines() { - KBookmarkGroup toolBarGroup = Application::bookmarkProvider()->rootGroup(); - if (toolBarGroup.isNull()) - { - return QString("Error retrieving bookmarks!"); - } - - QString str = QString(""); - KBookmark bookmark = toolBarGroup.first(); - while (!bookmark.isNull()) - { - str += createBookItem(bookmark); - bookmark = toolBarGroup.next(bookmark); - } + QString engines = "engines"; - return str; + return engines; } -QString HomePage::createSubMenu(const QString &item, const QString &s) +QString HomePage::recentlyClosedTabs() { - QString menu = "
"; + QString closedtabs = "closed"; - menu += "

" + item + "

"; - return menu; + return closedtabs; } - -QString HomePage::createBookItem(const KBookmark &bookmark) -{ - static int i = 0; - - if (bookmark.isGroup()) - { - QString result = QString(""); - QString ss = "b" + QString::number(i); - i++; - - KBookmarkGroup group = bookmark.toGroup(); - KBookmark bm = group.first(); - result += createSubMenu( bookmark.text() , ss ); - result += "

"; - - while (!bm.isNull()) - { - result += createBookItem(bm); //menuAction->addAction(fillBookmarkBar(bm)); - bm = group.next(bm); - } - result += "

"; - return result; - } - - if(bookmark.isSeparator()) - { - return QString("
"); - } - - QString str = ""; // FIXME Add icon "\"icon\""; - str += "" + bookmark.text() + "
"; - return str; -} +// QString HomePage::fillHistory() +// { +// QString history = QString(); +// HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); +// +// int i = 0; +// do +// { +// QModelIndex index = model->index(i, 0, QModelIndex() ); +// if(model->hasChildren(index)) +// { +// QString s = QString::number(i); +// history += createSubMenu(index.data().toString(), s); +// history += "

"; +// for(int j=0; j< model->rowCount(index); ++j) +// { +// QModelIndex son = model->index(j, 0, index ); +// // FIXME add an icon to each history item history += "\"icon\""; +// history += QString("") + +// son.data().toString() + QString("
"); +// } +// history += "

"; +// } +// else +// { +// history += QString("

NO CHILDREN: ") + index.data().toString() + QString("

"); +// } +// i++; +// } +// while( model->hasIndex( i , 0 , QModelIndex() ) ); +// +// return history; +// +// } +// +// +// QString HomePage::fillBookmarks() +// { +// KBookmarkGroup toolBarGroup = Application::bookmarkProvider()->rootGroup(); +// if (toolBarGroup.isNull()) +// { +// return QString("Error retrieving bookmarks!"); +// } +// +// QString str = QString(""); +// KBookmark bookmark = toolBarGroup.first(); +// while (!bookmark.isNull()) +// { +// str += createBookItem(bookmark); +// bookmark = toolBarGroup.next(bookmark); +// } +// +// return str; +// } +// +// +// QString HomePage::createSubMenu(const QString &item, const QString &s) +// { +// QString menu = "
"; +// +// menu += "

" + item + "

"; +// return menu; +// } +// +// +// QString HomePage::createBookItem(const KBookmark &bookmark) +// { +// static int i = 0; +// +// if (bookmark.isGroup()) +// { +// QString result = QString(""); +// QString ss = "b" + QString::number(i); +// i++; +// +// KBookmarkGroup group = bookmark.toGroup(); +// KBookmark bm = group.first(); +// result += createSubMenu( bookmark.text() , ss ); +// result += "

"; +// +// while (!bm.isNull()) +// { +// result += createBookItem(bm); //menuAction->addAction(fillBookmarkBar(bm)); +// bm = group.next(bm); +// } +// result += "

"; +// return result; +// } +// +// if(bookmark.isSeparator()) +// { +// return QString("
"); +// } +// +// QString str = ""; // FIXME Add icon "\"icon\""; +// str += "" + bookmark.text() + "
"; +// return str; +// } -- cgit v1.2.1