From 8e5c5ae29692e5e8179b17f574d454fab0c90dda Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 17 Feb 2013 18:11:19 +0100 Subject: Closed tabs page, last bits (?) Restore closed tabs on restart --- src/sessionmanager.cpp | 28 +++++++++++++++++++--------- src/sessionmanager.h | 2 +- src/tabwindow/tabwindow.cpp | 12 ++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) (limited to 'src') 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 SessionManager::closedSites() +QList SessionManager::closedSitesForWindow(const QString &windowName) { QList list; QDomDocument document("session"); @@ -351,19 +351,29 @@ QList 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 closedSites(); + QList 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 @@ -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 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); + } } -- cgit v1.2.1