summaryrefslogtreecommitdiff
path: root/src/sessionmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sessionmanager.cpp')
-rw-r--r--src/sessionmanager.cpp83
1 files changed, 45 insertions, 38 deletions
diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp
index 5c93e2d0..7e13388e 100644
--- a/src/sessionmanager.cpp
+++ b/src/sessionmanager.cpp
@@ -74,36 +74,43 @@ bool readSessionDocument(QDomDocument & document, const QString & sessionFilePat
}
-int loadTabs(TabWindow *tw, QDomElement & window, bool useFirstTab)
+int loadTabs(TabWindow *tw, QDomElement & window, bool useFirstTab, bool justThePinnedOnes = false)
{
int currentTab = 0;
for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++)
{
QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement();
- if (tab.hasAttribute("currentTab"))
- currentTab = tabNo;
+ bool tabIsPinned = tab.hasAttribute("pinned");
+ kDebug() << "Tab # " << tabNo << " is pinned? " << tabIsPinned;
- KUrl u = KUrl(tab.attribute("url"));
+ if (!justThePinnedOnes || tabIsPinned)
+ {
+ if (tab.hasAttribute("currentTab"))
+ currentTab = tabNo;
- TabHistory tabHistory;
- tabHistory.title = tab.attribute("title");
- tabHistory.url = tab.attribute("url");
- QDomCDATASection historySection = tab.firstChild().toCDATASection();
- tabHistory.history = QByteArray::fromBase64(historySection.data().toAscii());
+ KUrl u = KUrl(tab.attribute("url"));
- if (tabNo == 0 && useFirstTab)
- {
- tw->loadUrl(u, Rekonq::CurrentTab, &tabHistory);
- }
- else
- {
- tw->loadUrl(u, Rekonq::NewTab, &tabHistory);
- }
+ TabHistory tabHistory;
+ tabHistory.title = tab.attribute("title");
+ tabHistory.url = tab.attribute("url");
+ QDomCDATASection historySection = tab.firstChild().toCDATASection();
+ tabHistory.history = QByteArray::fromBase64(historySection.data().toAscii());
- if (tab.hasAttribute("pinned"))
- {
- tw->tabBar()->setTabData(tabNo, true);
+ if (tabNo == 0 && useFirstTab)
+ {
+ tw->loadUrl(u, Rekonq::CurrentTab, &tabHistory);
+ }
+ else
+ {
+ tw->loadUrl(u, Rekonq::NewTab, &tabHistory);
+ }
+
+ if (tabIsPinned)
+ {
+ tw->tabBar()->setTabData(tabNo, true);
+ tw->tabBar()->tabButton(tabNo, QTabBar::RightSide)->hide(); // NOTE: this is not good here: where is its proper place?
+ }
}
}
@@ -230,7 +237,7 @@ bool SessionManager::restoreSessionFromScratch()
TabWindow *tw = rApp->newTabWindow();
- int currentTab = loadTabs(tw, window, false);
+ int currentTab = loadTabs(tw, window, true, false);
tw->setCurrentIndex(currentTab);
}
@@ -239,53 +246,53 @@ bool SessionManager::restoreSessionFromScratch()
}
-void SessionManager::restoreCrashedSession()
+bool SessionManager::restoreJustThePinnedTabs()
{
QDomDocument document("session");
if (!readSessionDocument(document, m_sessionFilePath))
- return;
+ return false;
+ bool done = false;
for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++)
{
+ done = true;
QDomElement window = document.elementsByTagName("window").at(winNo).toElement();
- TabWindow *tw = (winNo == 0)
- ? rApp->tabWindow()
- : rApp->newTabWindow();
+ TabWindow *tw = rApp->newTabWindow();
- KUrl u = tw->currentWebWindow()->url();
- bool useCurrentTab = (u.isEmpty() || u.protocol() == QL1S("about"));
- int currentTab = loadTabs(tw, window, useCurrentTab);
+ int currentTab = loadTabs(tw, window, true, true);
tw->setCurrentIndex(currentTab);
}
- setSessionManagementEnabled(true);
+ return done;
}
-int SessionManager::restoreSavedSession()
+void SessionManager::restoreCrashedSession()
{
QDomDocument document("session");
if (!readSessionDocument(document, m_sessionFilePath))
- return 0;
-
- unsigned int winNo;
+ return;
- for (winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++)
+ for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++)
{
QDomElement window = document.elementsByTagName("window").at(winNo).toElement();
- TabWindow *tw = rApp->newTabWindow();
+ TabWindow *tw = (winNo == 0)
+ ? rApp->tabWindow()
+ : rApp->newTabWindow();
- int currentTab = loadTabs(tw, window, true);
+ KUrl u = tw->currentWebWindow()->url();
+ bool useCurrentTab = (u.isEmpty() || u.protocol() == QL1S("about"));
+ int currentTab = loadTabs(tw, window, useCurrentTab);
tw->setCurrentIndex(currentTab);
}
- return winNo;
+ setSessionManagementEnabled(true);
}