From 696743557de6a6b82303618d8f60f08f8978e650 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 26 Nov 2018 00:58:19 +0100 Subject: Add Session::view and Session::restoreView --- src/session.cpp | 80 --------------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 src/session.cpp (limited to 'src/session.cpp') diff --git a/src/session.cpp b/src/session.cpp deleted file mode 100644 index 4e1c6d6..0000000 --- a/src/session.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "session.h" -#include "mainwindow/mainwindow.h" -#include "subwindow/subwindow.h" -#include -#include -#include "webengine/webview.h" -#include "profilemanager.h" -#include "browser.h" - -QJsonObject Session::session(QVector windows) -{ - QJsonObject obj; - - QJsonArray windowsArray; - for(const MainWindow *window : windows) { - windowsArray.append(Session::window(window)); - } - obj.insert("windows", windowsArray); - - return obj; -} - -QJsonObject Session::window(const MainWindow *window) -{ - QJsonObject obj; - auto *profileManager = dynamic_cast(qApp)->getProfileManager(); - - QJsonArray subwindows; - for(const SubWindow *subwindow : window->subWindows()) { - QJsonObject window; - window.insert("profile", profileManager->id(subwindow->profile())); - - QJsonArray tabs; - for(int i = 0; i < subwindow->tabCount(); ++i) { - QJsonObject tab; - tab.insert("url", subwindow->view(i)->url().toString()); - tab.insert("profile", profileManager->id(subwindow->view(i)->profile())); - tabs.append(tab); - } - window.insert("tabs", tabs); - - subwindows.append(window); - } - obj.insert("subwindows", subwindows); - - return obj; -} - -QJsonObject Session::window(const QString &profile, const QStringList &urls) -{ - QJsonObject session; - - QJsonArray subwindows; - { - QJsonObject window; - window.insert("profile", profile); - - QJsonArray tabs; - for(const auto &url : urls) { - QJsonObject tab; - tab.insert("url", url); - tab.insert("profile", profile); - tabs.append(tab); - } - window.insert("tabs", tabs); - - subwindows.append(window); - } - session.insert("subwindows", subwindows); - - return session; -} -- cgit v1.2.1