File indexing completed on 2024-04-28 15:29:20
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2001 Carsten Pfeiffer <pfeiffer@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KHISTORYPROVIDER_H 0009 #define KHISTORYPROVIDER_H 0010 0011 #include <kparts/kparts_export.h> 0012 0013 #include <QObject> 0014 0015 namespace KParts 0016 { 0017 class HistoryProviderPrivate; 0018 0019 /** 0020 * @class HistoryProvider historyprovider.h <KParts/HistoryProvider> 0021 * 0022 * @short Basic class to manage a history of "items". This class is only meant 0023 * for fast lookup, if an item is in the history or not. 0024 * 0025 * May be subclassed to implement a persistent history for example. 0026 * For usage with khtml, just create your provider and call the 0027 * HistoryProvider constructor _before_ you do any khtml stuff. That way, 0028 * khtml, using the self()-method, will use your subclassed provider. 0029 * 0030 * @author Carsten Pfeiffer <pfeiffer@kde.org> 0031 */ 0032 class KPARTS_EXPORT HistoryProvider : public QObject 0033 { 0034 Q_OBJECT 0035 friend class ::KParts::HistoryProviderPrivate; 0036 0037 public: 0038 static HistoryProvider *self(); 0039 0040 /** 0041 * @returns true if a provider has already been created. 0042 * @since 4.4 0043 */ 0044 static bool exists(); 0045 0046 /** 0047 * @returns true if @p item is present in the history. 0048 */ 0049 virtual bool contains(const QString &item) const; 0050 0051 /** 0052 * Inserts @p item into the history. 0053 */ 0054 virtual void insert(const QString &item); 0055 0056 /** 0057 * Removes @p item from the history. 0058 */ 0059 virtual void remove(const QString &item); 0060 0061 /** 0062 * Clears the history. The cleared() signal is emitted after clearing. 0063 */ 0064 virtual void clear(); 0065 0066 Q_SIGNALS: 0067 /** 0068 * Emitted after the history has been cleared. 0069 */ 0070 void cleared(); 0071 0072 /** 0073 * This signal is never emitted from this class, it is only meant as an 0074 * interface for subclasses. Emit this signal to notify others that the 0075 * history has changed. Put those items that were added or removed from the 0076 * history into @p items. 0077 */ 0078 void updated(const QStringList &items); 0079 0080 /** 0081 * Emitted after the item has been inserted 0082 */ 0083 void inserted(const QString &item); 0084 0085 protected: 0086 /** 0087 * Creates a KHistoryProvider with an optional parent and name 0088 */ 0089 HistoryProvider(QObject *parent = nullptr); 0090 0091 /** 0092 * Destroys the provider. 0093 */ 0094 ~HistoryProvider() override; 0095 0096 private: 0097 HistoryProviderPrivate *const d; 0098 }; 0099 0100 } 0101 0102 #endif // KHISTORYPROVIDER_H