summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2013-02-17 18:11:19 +0100
committerAndrea Diamantini <adjam7@gmail.com>2013-02-17 18:11:19 +0100
commit8e5c5ae29692e5e8179b17f574d454fab0c90dda (patch)
tree9379436bce60ce7c272ea6984b11ee6c442f0757
parentClosed Tabs page return, first bits (diff)
downloadrekonq-8e5c5ae29692e5e8179b17f574d454fab0c90dda.tar.xz
Closed tabs page, last bits (?)
Restore closed tabs on restart
-rw-r--r--src/sessionmanager.cpp28
-rw-r--r--src/sessionmanager.h2
-rw-r--r--src/tabwindow/tabwindow.cpp12
3 files changed, 32 insertions, 10 deletions
diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp
index 850a709e..e9ea5bf5 100644
--- a/src/sessionmanager.cpp
+++ b/src/sessionmanager.cpp
@@ -343,7 +343,7 @@ bool SessionManager::restoreTabWindow(TabWindow* window)
}
-QList<TabHistory> SessionManager::closedSites()
+QList<TabHistory> SessionManager::closedSitesForWindow(const QString &windowName)
{
QList<TabHistory> list;
QDomDocument document("session");
@@ -351,19 +351,29 @@ QList<TabHistory> SessionManager::closedSites()
if (!readSessionDocument(document, m_sessionFilePath))
return list;
- for (unsigned int tabNo = 0; tabNo < document.elementsByTagName("tab").length(); tabNo++)
+ for (unsigned int winNo = 0; winNo < document.elementsByTagName("tab").length(); winNo++)
{
- QDomElement tab = document.elementsByTagName("tab").at(tabNo).toElement();
+ QDomElement windowElement = document.elementsByTagName("window").at(winNo).toElement();
- TabHistory tabHistory;
+ if (windowName != windowElement.attribute("name", ""))
+ continue;
+
+ for (unsigned int tabNo = 0; tabNo < windowElement.elementsByTagName("tab").length(); tabNo++)
+ {
+ QDomElement tab = windowElement.elementsByTagName("tab").at(tabNo).toElement();
- tabHistory.title = tab.attribute("title");
- tabHistory.url = tab.attribute("url");
+ TabHistory tabHistory;
+
+ tabHistory.title = tab.attribute("title");
+ tabHistory.url = tab.attribute("url");
- QDomCDATASection historySection = tab.firstChild().toCDATASection();
- tabHistory.history = QByteArray::fromBase64(historySection.data().toAscii());
+ QDomCDATASection historySection = tab.firstChild().toCDATASection();
+ tabHistory.history = QByteArray::fromBase64(historySection.data().toAscii());
- list << tabHistory;
+ list << tabHistory;
+ }
+
+ return list;
}
return list;
diff --git a/src/sessionmanager.h b/src/sessionmanager.h
index c1ae88f1..344f3b8a 100644
--- a/src/sessionmanager.h
+++ b/src/sessionmanager.h
@@ -65,7 +65,7 @@ public:
m_isSessionEnabled = on;
}
- QList<TabHistory> closedSites();
+ QList<TabHistory> closedSitesForWindow(const QString &);
// This method restores a single TabWindow
bool restoreTabWindow(TabWindow * window);
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 6865ca97..47b3f254 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -41,6 +41,7 @@
#include "bookmarkmanager.h"
#include "iconmanager.h"
+#include "sessionmanager.h"
// KDE Includes
#include <KAction>
@@ -208,6 +209,17 @@ void TabWindow::init()
connect(favoritesSignalMapper, SIGNAL(mapped(int)), this, SLOT(loadFavorite(int)));
_ac->readSettings();
+
+ // ----------------------------------------------------------------------------------------------
+ int n = rApp->tabWindowList().count() + 1;
+ QList<TabHistory> list = SessionManager::self()->closedSitesForWindow( QL1S("win") + QString::number(n) );
+ Q_FOREACH(const TabHistory & tab, list)
+ {
+ if (tab.url.startsWith(QL1S("about")))
+ continue;
+ m_recentlyClosedTabs.removeAll(tab);
+ m_recentlyClosedTabs.prepend(tab);
+ }
}