From f59b52ea590fcef4f76b8691edec542e133c1b78 Mon Sep 17 00:00:00 2001
From: Andrea Diamantini <adjam7@gmail.com>
Date: Mon, 14 Sep 2009 00:24:08 +0200
Subject: Recently closed tabs: first implementation

---
 src/homepage.cpp | 12 ++++++++++--
 src/mainview.cpp | 12 +++++++++++-
 src/mainview.h   |  4 ++++
 3 files changed, 25 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/homepage.cpp b/src/homepage.cpp
index 20276f57..6a327b3a 100644
--- a/src/homepage.cpp
+++ b/src/homepage.cpp
@@ -32,6 +32,8 @@
 #include "historymodels.h"
 #include "bookmarks.h"
 #include "application.h"
+#include "mainwindow.h"
+#include "mainview.h"
 #include "websnap.h"
 
 // KDE Includes
@@ -143,9 +145,15 @@ QString HomePage::searchEngines()
 
 QString HomePage::recentlyClosedTabs()
 {
-    QString closedtabs = "<h2>Recently closed tabs</h2>";
+    QString closed = "<h2>Recently closed tabs</h2>";
 
-    return closedtabs;
+    KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs();
+    
+    foreach(const KUrl &url, links)
+    {
+        closed += "<a href=\"" + url.prettyUrl() + "\">" + url.prettyUrl() + "</a><br />";
+    }
+    return closed;
 }
 
 // QString HomePage::fillHistory()
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 3836ddd0..a40729a3 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -176,6 +176,8 @@ void MainView::clear()
     /// TODO What exactly do we need to clear here?
     m_urlBar->clearHistory();
     m_urlBar->clear();
+
+    m_recentlyClosedTabs.clear();
 }
 
 
@@ -403,11 +405,13 @@ void MainView::slotCloseTab(int index)
             int risp = KMessageBox::questionYesNo(this,
                         i18n("You have modified this page and when closing it you would lose the modifications.\n"
                              "Do you really want to close this page?\n"),
-                        i18n("Do you really want to close this page?"));
+                        i18n("Closing tab confirmation"));
             if (risp == KMessageBox::No)
                 return;
         }
         hasFocus = tab->hasFocus();
+        
+        m_recentlyClosedTabs.prepend(tab->url());
     }
 
     QWidget *webView = widget(index);
@@ -583,3 +587,9 @@ void MainView::resizeEvent(QResizeEvent *event)
 {
     KTabWidget::resizeEvent(event);
 }
+
+
+KUrl::List MainView::recentlyClosedTabs()
+{
+    return m_recentlyClosedTabs;
+}
diff --git a/src/mainview.h b/src/mainview.h
index c59cca1a..ba79d9f8 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -71,6 +71,8 @@ public:
     WebView *currentWebView() const;
     int webViewIndex(WebView *webView) const;
 
+    KUrl::List recentlyClosedTabs();
+    
     /**
      * show and hide TabBar if user doesn't choose
      * "Always Show TabBar" option
@@ -158,6 +160,8 @@ private:
     QString m_loadingGitPath;
     
     int m_currentTabIndex;
+
+    KUrl::List m_recentlyClosedTabs;
 };
 
 #endif // MAINVIEW_H
-- 
cgit v1.2.1