From 66836b1ca6d8d5dfcdf4d48dabc51b7709d6e456 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Wed, 9 Dec 2009 17:12:38 +0100 Subject: Rewrite NewTabPage to use QWebElement for page generation --- src/rekonqpage/newtabpage.h | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'src/rekonqpage/newtabpage.h') diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 2d8d50bd..62baf79e 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -28,12 +28,16 @@ #define REKONQ_NEW_TAB_PAGE +// rekonq Includes +#include + // KDE Includes #include // Qt Includes #include #include +#include // Forward Includes class KBookmark; @@ -43,7 +47,7 @@ class NewTabPage { public: - NewTabPage(); + NewTabPage(WebPage *page); ~NewTabPage(); /** @@ -51,22 +55,32 @@ public: * about: url and loads the corresponding part of the * new tab page */ - QString newTabPageCode(const KUrl &url = KUrl("about:home")); + void generate(const KUrl &url = KUrl("about:home")); protected: // these are the function to build the new tab page - - QString browsingMenu(const KUrl ¤tUrl); + void browsingMenu(const KUrl ¤tUrl); - QString favoritesPage(); - QString lastVisitedPage(); - QString historyPage(); - QString bookmarksPage(); - QString closedTabsPage(); + void favoritesPage(); + //QString lastVisitedPage(); + void historyPage(); + void bookmarksPage(); + void closedTabsPage(); private: - QString createBookItem(const KBookmark &bookmark); + void createBookItem(const KBookmark &bookmark, QWebElement parent); + + /** This function helps to get faster a new markup of one type,it isn't easy to create one with QWebElement. + It gets it in the #models div of home.html. + It works for all elements defined here. + */ + inline QWebElement markup(QString selector) + { + return m_root.document().findFirst("#models > " + selector).clone(); + } - QString m_htmlFilePath; + QString m_html; + + QWebElement m_root; }; #endif // REKONQ_NEW_TAB_PAGE -- cgit v1.2.1