1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

WebTab: Add sessionData property

This commit is contained in:
David Rosca 2018-02-04 12:01:29 +01:00
parent 62264501e2
commit 095e0ff517
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
2 changed files with 24 additions and 2 deletions

View File

@ -36,7 +36,7 @@
#include <QTimer>
#include <QSplitter>
static const int savedTabVersion = 5;
static const int savedTabVersion = 6;
WebTab::SavedTab::SavedTab()
: isPinned(false)
@ -60,6 +60,8 @@ WebTab::SavedTab::SavedTab(WebTab* webTab)
for (WebTab *child : children) {
childTabs.append(child->tabIndex());
}
sessionData = webTab->sessionData();
}
bool WebTab::SavedTab::isValid() const
@ -77,6 +79,7 @@ void WebTab::SavedTab::clear()
zoomLevel = qzSettings->defaultZoomLevel;
parentTab = -1;
childTabs.clear();
sessionData.clear();
}
QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
@ -90,6 +93,7 @@ QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
stream << tab.zoomLevel;
stream << tab.parentTab;
stream << tab.childTabs;
stream << tab.sessionData;
return stream;
}
@ -120,6 +124,9 @@ QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
if (version >= 5)
stream >> tab.childTabs;
if (version >= 6)
stream >> tab.sessionData;
tab.icon = QIcon(pixmap);
return stream;
@ -498,6 +505,16 @@ QVector<WebTab*> WebTab::childTabs() const
return m_childTabs;
}
QHash<QString, QVariant> WebTab::sessionData() const
{
return m_sessionData;
}
void WebTab::setSessionData(const QString &key, const QVariant &value)
{
m_sessionData[key] = value;
}
bool WebTab::isRestored() const
{
return !m_savedTab.isValid();
@ -508,6 +525,7 @@ void WebTab::restoreTab(const WebTab::SavedTab &tab)
Q_ASSERT(m_tabBar);
setPinned(tab.isPinned);
m_sessionData = tab.sessionData;
if (!isPinned() && qzSettings->loadTabsOnActivation) {
m_savedTab = tab;

View File

@ -48,6 +48,7 @@ public:
int zoomLevel;
int parentTab;
QVector<int> childTabs;
QHash<QString, QVariant> sessionData;
SavedTab();
SavedTab(WebTab* webTab);
@ -73,9 +74,11 @@ public:
WebTab *parentTab() const;
void setParentTab(WebTab *tab);
void addChildTab(WebTab *tab, int index = -1);
QVector<WebTab*> childTabs() const;
QHash<QString, QVariant> sessionData() const;
void setSessionData(const QString &key, const QVariant &value);
QUrl url() const;
QString title(bool allowEmpty = false) const;
QIcon icon(bool allowNull = false) const;
@ -160,6 +163,7 @@ private:
WebTab *m_parentTab = nullptr;
QVector<WebTab*> m_childTabs;
QHash<QString, QVariant> m_sessionData;
SavedTab m_savedTab;
bool m_isPinned = false;