KParts

historyprovider.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 2001 Carsten Pfeiffer <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KHISTORYPROVIDER_H
9 #define KHISTORYPROVIDER_H
10 
11 #include <kparts/kparts_export.h>
12 
13 #include <QObject>
14 
15 namespace KParts
16 {
17 class HistoryProviderPrivate;
18 
19 /**
20  * @class HistoryProvider historyprovider.h <KParts/HistoryProvider>
21  *
22  * @short Basic class to manage a history of "items". This class is only meant
23  * for fast lookup, if an item is in the history or not.
24  *
25  * May be subclassed to implement a persistent history for example.
26  * For usage with khtml, just create your provider and call the
27  * HistoryProvider constructor _before_ you do any khtml stuff. That way,
28  * khtml, using the self()-method, will use your subclassed provider.
29  *
30  * @author Carsten Pfeiffer <[email protected]>
31  */
32 class KPARTS_EXPORT HistoryProvider : public QObject
33 {
34  Q_OBJECT
35  friend class ::KParts::HistoryProviderPrivate;
36 
37 public:
38  static HistoryProvider *self();
39 
40  /**
41  * @returns true if a provider has already been created.
42  * @since 4.4
43  */
44  static bool exists();
45 
46  /**
47  * @returns true if @p item is present in the history.
48  */
49  virtual bool contains(const QString &item) const;
50 
51  /**
52  * Inserts @p item into the history.
53  */
54  virtual void insert(const QString &item);
55 
56  /**
57  * Removes @p item from the history.
58  */
59  virtual void remove(const QString &item);
60 
61  /**
62  * Clears the history. The cleared() signal is emitted after clearing.
63  */
64  virtual void clear();
65 
66 Q_SIGNALS:
67  /**
68  * Emitted after the history has been cleared.
69  */
70  void cleared();
71 
72  /**
73  * This signal is never emitted from this class, it is only meant as an
74  * interface for subclasses. Emit this signal to notify others that the
75  * history has changed. Put those items that were added or removed from the
76  * history into @p items.
77  */
78  void updated(const QStringList &items);
79 
80  /**
81  * Emitted after the item has been inserted
82  */
83  void inserted(const QString &item);
84 
85 protected:
86  /**
87  * Creates a KHistoryProvider with an optional parent and name
88  */
89  HistoryProvider(QObject *parent = nullptr);
90 
91  /**
92  * Destroys the provider.
93  */
94  ~HistoryProvider() override;
95 
96 private:
97  HistoryProviderPrivate *const d;
98 };
99 
100 }
101 
102 #endif // KHISTORYPROVIDER_H
Basic class to manage a history of "items". This class is only meant for fast lookup,...
The KParts namespace,.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 9 2022 03:51:33 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.