Falkon Develop
Cross-platform Qt-based web browser
closedtabsmanager.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "closedtabsmanager.h"
19#include "mainapplication.h"
20#include "qztools.h"
21
22#include <QWebEngineHistory>
23
25= default;
26
28{
29 if (mApp->isPrivate()) {
30 return;
31 }
32
33 // Don't save empty tab
34 if (tab->url().isEmpty() && tab->history()->items().isEmpty()) {
35 return;
36 }
37
38 Tab closedTab;
39 closedTab.position = tab->tabIndex();
40 closedTab.parentTab = tab->parentTab();
41 closedTab.tabState = WebTab::SavedTab(tab);
42 m_closedTabs.prepend(closedTab);
43}
44
46{
47 return !m_closedTabs.isEmpty();
48}
49
51{
52 Tab tab;
53 if (!m_closedTabs.isEmpty()) {
54 tab = m_closedTabs.takeFirst();
55 }
56 return tab;
57}
58
60{
61 Tab tab;
62 if (QzTools::containsIndex(m_closedTabs, index)) {
63 tab = m_closedTabs.takeAt(index);
64 }
65 return tab;
66}
67
68QVector<ClosedTabsManager::Tab> ClosedTabsManager::closedTabs() const
69{
70 return m_closedTabs;
71}
72
74{
75 m_closedTabs.clear();
76}
bool isClosedTabAvailable() const
Tab takeTabAt(int index)
void saveTab(WebTab *tab)
QVector< Tab > closedTabs() const
static bool containsIndex(const T &container, int index)
Definition: qztools.h:95
Definition: webtab.h:40
int tabIndex() const
Definition: webtab.cpp:710
QUrl url() const
Definition: webtab.cpp:263
QWebEngineHistory * history() const
Definition: webtab.cpp:299
WebTab * parentTab() const
Definition: webtab.cpp:469
#define mApp
QPointer< WebTab > parentTab
WebTab::SavedTab tabState