Bug 228480 - sessionmanager about: closedTabs improvement
Summary: sessionmanager about: closedTabs improvement
Status: RESOLVED FIXED
Alias: None
Product: rekonq
Classification: Applications
Component: general (show other bugs)
Version: 0.4.0
Platform: Fedora RPMs Linux
: NOR wishlist
Target Milestone: ---
Assignee: Andrea Diamantini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-25 16:37 UTC by Christian Jann
Modified: 2010-05-11 11:47 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Jann 2010-02-25 16:37:09 UTC
Version:           0.3.95 (using KDE 4.4.0)
OS:                Linux
Installed from:    Fedora RPMs

When i have configured to Open the New Tab Page or Homepage on Startup show the tabs which were closed on last application exit under about:closedTabs

in about:history links are saved when i open them, but if i open 100 tabs and close them randomly until only 4 tabs are open and then close the browser (maybe accidentally)
on startup i could not find out what i was doing before closing the browser
i think this is a better behavior then some stupid dialog "do you really want to close the browser, there are several tabs open"
Comment 1 Andrea Diamantini 2010-05-11 11:47:18 UTC
commit c27d8ff5790382daa69829be74457b919ee06cd6
Author: Andrea Diamantini <adjam7@gmail.com>
Date:   Tue May 11 11:41:59 2010 +0200

    Load old closed tabs from session manager.
    
    This let me think about the need of reimplementing it and all History
    to support more infos (eg: zoom)
    
    closing one bug and opening another :)
    
    BUG:228480

diff --git a/src/mainview.cpp b/src/mainview.cpp
index e703976..84b8795 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -109,6 +109,18 @@ MainView::~MainView()
 
 void MainView::postLaunch()
 {
+    QStringList list = Application::sessionManager()->closedSites();
+    foreach(const QString &line, list)
+    {
+        if(line.startsWith( QL1S("about") ))
+            break;
+        QString title = line;
+        QString url = title;
+        HistoryItem item(url, QDateTime::currentDateTime(), title);
+        m_recentlyClosedTabs.removeAll(item);
+        m_recentlyClosedTabs.prepend(item);
+    }
+    
     // Session Manager
     connect(this, SIGNAL(tabsChanged()), Application::sessionManager(), SLOT(saveSession()));
 
@@ -493,8 +505,7 @@ void MainView::closeTab(int index, bool del)
             return;
     }
 
-    // store close tab except homepage
-    if (!tab->url().prettyUrl().startsWith(QL1S("about:")) && !tab->url().isEmpty())
+    if (!tab->url().isEmpty())
     {
         QString title = tab->view()->title();
         QString url = tab->url().prettyUrl();
diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp
index 0b50791..6aada50 100644
--- a/src/sessionmanager.cpp
+++ b/src/sessionmanager.cpp
@@ -106,15 +106,44 @@ bool SessionManager::restoreSession()
         {
             line = in.readLine();
             kDebug() << "New Window line: " << line;
-            Application::instance()->loadUrl(line, Rekonq::NewWindow);
+            Application::instance()->loadUrl( KUrl(line), Rekonq::NewWindow);
         }
         else
         {
             kDebug() << "New Current Tab line: " << line;
-            Application::instance()->loadUrl(line, Rekonq::NewCurrentTab);
+            Application::instance()->loadUrl( KUrl(line), Rekonq::NewCurrentTab);
         }
     }
     while (!line.isEmpty());
 
     return true;
 }
+
+
+QStringList SessionManager::closedSites()
+{
+    QStringList list;
+    
+    QFile sessionFile(m_sessionFilePath);
+    if (!sessionFile.exists())
+        return list;
+    if (!sessionFile.open(QFile::ReadOnly))
+    {
+        kDebug() << "Unable to open session file" << sessionFile.fileName();
+        return list;
+    }
+
+    QTextStream in(&sessionFile);
+    QString line;
+    do
+    {
+        line = in.readLine();
+        if (line != QString("window"))
+        {
+            list << QString(line);
+        }
+    }
+    while (!line.isEmpty());
+
+    return list;
+}
diff --git a/src/sessionmanager.h b/src/sessionmanager.h
index 7960fc3..a446b53 100644
--- a/src/sessionmanager.h
+++ b/src/sessionmanager.h
@@ -49,6 +49,8 @@ public:
     ~SessionManager();
     bool restoreSession();
 
+    QStringList closedSites();
+    
 private slots:
     void saveSession();