summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newtabpage.cpp19
-rw-r--r--src/newtabpage.h44
2 files changed, 37 insertions, 26 deletions
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index 6fd5160d..69a80b29 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -79,7 +79,7 @@ NewTabPage::~NewTabPage()
}
-void NewTabPage::generate(KUrl url)
+void NewTabPage::generate(const KUrl &url)
{
if(KUrl("about:preview").isParentOf(url))
{
@@ -171,7 +171,7 @@ QWebElement NewTabPage::emptyPreview(int index)
}
-QWebElement NewTabPage::loadingPreview(int index, KUrl url)
+QWebElement NewTabPage::loadingPreview(int index, const KUrl &url)
{
QWebElement prev = markup(".thumbnail");
@@ -189,7 +189,7 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url)
}
-QWebElement NewTabPage::validPreview(int index, KUrl url, QString title)
+QWebElement NewTabPage::validPreview(int index, const KUrl &url, const QString &title)
{
QWebElement prev = markup(".thumbnail");
KUrl previewPath = WebSnap::fileForUrl(url);
@@ -237,7 +237,7 @@ void NewTabPage::setupPreview(QWebElement e, int index)
}
-void NewTabPage::snapFinished(int index, KUrl url, QString title)
+void NewTabPage::snapFinished(int index, const KUrl &url, const QString &title)
{
// do not try to modify the page if it isn't the newTabPage
if(m_root.document().findAll("#rekonq-newtabpage").count() == 0)
@@ -432,12 +432,13 @@ void NewTabPage::closedTabsPage()
}
-QString NewTabPage::checkTitle(QString title)
+QString NewTabPage::checkTitle(const QString &title)
{
- if(title.length() > 23)
+ QString t(title);
+ if(t.length() > 23)
{
- title.truncate(20);
- title += "...";
+ t.truncate(20);
+ t += "...";
}
- return title;
+ return t;
}
diff --git a/src/newtabpage.h b/src/newtabpage.h
index fd04e60a..6d3a7ea9 100644
--- a/src/newtabpage.h
+++ b/src/newtabpage.h
@@ -57,13 +57,15 @@ public:
* This method takes an about: url and loads
* the corresponding part of the new tab page
*/
- void generate(KUrl url = KUrl("about:home"));
+ void generate(const KUrl &url = KUrl("about:home"));
- void snapFinished(int index, KUrl url, QString title);
- void removePreview(int index);
+ void snapFinished(int index, const KUrl &url, const QString &title);
+
-protected:
- // these are the functions to build the new tab page
+private:
+ // these are the "high-level" functions to build the new tab page
+ // basically, you call browsingMenu + one the the *Page methods
+ // to load a page
void browsingMenu(const KUrl &currentUrl);
void favoritesPage();
@@ -71,38 +73,46 @@ protected:
void bookmarksPage();
void closedTabsPage();
+ // --------------------------------------------------------------------------
+ // "low-level" functions
+ // we use these to create the pages over
+
// Previews handling
QWebElement emptyPreview(int index);
- QWebElement loadingPreview(int index, KUrl url);
- QWebElement validPreview(int index, KUrl url, QString title);
+ QWebElement loadingPreview(int index, const KUrl &url);
+ QWebElement validPreview(int index, const KUrl &url, const QString &title);
+
+ void removePreview(int index);
- /** This function takes a QwebElement with the .thumbnail structure,
- * hiding the "remove" and "modify" buttons
+ /**
+ * This function takes a QwebElement with the .thumbnail structure,
+ * hiding the "remove" and "modify" buttons
*
*/
void hideControls(QWebElement e);
void showControls(QWebElement e);
void setupPreview(QWebElement e, int index);
-private:
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.
+ /**
+ * 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.
+ * It gets it in the #models div of home.html.
+ * It works for all elements defined here.
*
*/
- inline QWebElement markup(QString selector)
+ inline QWebElement markup(const QString &selector)
{
return m_root.document().findFirst("#models > " + selector).clone();
}
- QString checkTitle(QString title);
+ QString checkTitle(const QString &title);
- QString m_html;
+private:
+ QString m_html;
QWebElement m_root;
};