File indexing completed on 2024-03-24 05:01:12
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org> 0003 SPDX-FileCopyrightText: 2007 Eduardo Robles Elvira <edulix@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KONQCLOSEDITEM_H 0009 #define KONQCLOSEDITEM_H 0010 0011 #include "konqprivate_export.h" 0012 #include <kconfiggroup.h> 0013 #include <QString> 0014 0015 class KConfig; 0016 0017 class KONQ_TESTS_EXPORT KonqClosedItem : public QObject 0018 { 0019 public: 0020 ~KonqClosedItem() override; 0021 virtual KConfigGroup &configGroup() 0022 { 0023 return m_configGroup; 0024 } 0025 virtual const KConfigGroup &configGroup() const 0026 { 0027 return m_configGroup; 0028 } 0029 quint64 serialNumber() const 0030 { 0031 return m_serialNumber; 0032 } 0033 QString title() const 0034 { 0035 return m_title; 0036 } 0037 virtual QPixmap icon() const = 0; 0038 0039 protected: 0040 KonqClosedItem(const QString &title, KConfig *config, const QString &group, quint64 serialNumber); 0041 QString m_title; 0042 KConfigGroup m_configGroup; 0043 quint64 m_serialNumber; 0044 }; 0045 0046 /** 0047 * This class stores all the needed information about a closed tab 0048 * in order to be able to reopen it if requested 0049 */ 0050 class KONQ_TESTS_EXPORT KonqClosedTabItem : public KonqClosedItem 0051 { 0052 public: 0053 KonqClosedTabItem(const QString &url, KConfig *config, const QString &title, int index, quint64 serialNumber); 0054 ~KonqClosedTabItem() override; 0055 QPixmap icon() const override; 0056 QString url() const 0057 { 0058 return m_url; 0059 } 0060 /// The position inside the tabbar that the tab had when it was closed 0061 int pos() const 0062 { 0063 return m_pos; 0064 } 0065 0066 protected: 0067 QString m_url; 0068 int m_pos; 0069 }; 0070 0071 /** 0072 * This class stores all the needed information about a closed tab 0073 * in order to be able to reopen it if requested 0074 */ 0075 class KONQ_TESTS_EXPORT KonqClosedWindowItem : public KonqClosedItem 0076 { 0077 public: 0078 KonqClosedWindowItem(const QString &title, KConfig *config, quint64 serialNumber, int numTabs); 0079 ~KonqClosedWindowItem() override; 0080 QPixmap icon() const override; 0081 int numTabs() const; 0082 0083 protected: 0084 int m_numTabs; 0085 }; 0086 0087 class KONQ_TESTS_EXPORT KonqClosedRemoteWindowItem : public KonqClosedWindowItem 0088 { 0089 public: 0090 KonqClosedRemoteWindowItem(const QString &title, KConfig *config, const QString &groupName, const QString &configFileName, quint64 serialNumber, int numTabs, const QString &dbusService); 0091 ~KonqClosedRemoteWindowItem() override; 0092 KConfigGroup &configGroup() override; 0093 const KConfigGroup &configGroup() const override; 0094 bool equalsTo(const QString &groupName, const QString &configFileName) const; 0095 QString dbusService() const 0096 { 0097 return m_dbusService; 0098 } 0099 const QString &remoteGroupName() const 0100 { 0101 return m_remoteGroupName; 0102 } 0103 const QString &remoteConfigFileName() const 0104 { 0105 return m_remoteConfigFileName; 0106 } 0107 protected: 0108 /** 0109 * Actually reads the config file. Call to this function before calling to 0110 * configGroup(). This function is const so that it can be called by 0111 * configGroup() const. It's used to get delayed initialization so that 0112 * we don't load the config file unless it's needed. 0113 */ 0114 void readConfig() const; 0115 QString m_remoteGroupName; 0116 QString m_remoteConfigFileName; 0117 QString m_dbusService; 0118 mutable KConfigGroup *m_remoteConfigGroup; 0119 mutable KConfig *m_remoteConfig; 0120 }; 0121 0122 #endif /* KONQCLOSEDITEM_H */ 0123