File indexing completed on 2024-05-12 04:58:26
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #ifndef CLOSEDTABSMANAGER_H 0019 #define CLOSEDTABSMANAGER_H 0020 0021 #include <QVector> 0022 #include <QPointer> 0023 0024 #include "webtab.h" 0025 #include "qzcommon.h" 0026 0027 class WebTab; 0028 0029 class FALKON_EXPORT ClosedTabsManager 0030 { 0031 public: 0032 struct Tab { 0033 int position = -1; 0034 QPointer<WebTab> parentTab; 0035 WebTab::SavedTab tabState; 0036 0037 bool isValid() const { 0038 return position > -1; 0039 } 0040 }; 0041 0042 explicit ClosedTabsManager(); 0043 0044 void saveTab(WebTab *tab); 0045 bool isClosedTabAvailable() const; 0046 0047 // Takes tab that was most recently closed 0048 Tab takeLastClosedTab(); 0049 // Takes tab at given index 0050 Tab takeTabAt(int index); 0051 0052 QVector<Tab> closedTabs() const; 0053 void clearClosedTabs(); 0054 0055 private: 0056 QVector<Tab> m_closedTabs; 0057 }; 0058 0059 // Hint to Qt to use std::realloc on item moving 0060 Q_DECLARE_TYPEINFO(ClosedTabsManager::Tab, Q_MOVABLE_TYPE); 0061 0062 #endif // CLOSEDTABSMANAGER_H