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 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/sessionmanager.cpp') 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; -- cgit v1.2.1