1/* This file is part of the KDE project
2 Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KHISTORYPROVIDER_H
21#define KHISTORYPROVIDER_H
22
23#include <QtCore/QObject>
24
25#include <kparts/kparts_export.h>
26
27namespace KParts {
28
29class HistoryProviderPrivate;
30
31/**
32 * Basic class to manage a history of "items". This class is only meant
33 * for fast lookup, if an item is in the history or not.
34 *
35 * May be subclassed to implement a persistent history for example.
36 * For usage with khtml, just create your provider and call the
37 * HistoryProvider constructor _before_ you do any khtml stuff. That way,
38 * khtml, using the self()-method, will use your subclassed provider.
39 *
40 * @author Carsten Pfeiffer <pfeiffer@kde.org>
41 */
42class KPARTS_EXPORT HistoryProvider : public QObject
43{
44 Q_OBJECT
45 friend class ::KParts::HistoryProviderPrivate;
46
47public:
48 static HistoryProvider * self();
49
50 /**
51 * @returns true if a provider has already been created.
52 * @since 4.4
53 */
54 static bool exists();
55
56 /**
57 * @returns true if @p item is present in the history.
58 */
59 virtual bool contains( const QString& item ) const;
60
61 /**
62 * Inserts @p item into the history.
63 */
64 virtual void insert( const QString& item );
65
66 /**
67 * Removes @p item from the history.
68 */
69 virtual void remove( const QString& item );
70
71 /**
72 * Clears the history. The cleared() signal is emitted after clearing.
73 */
74 virtual void clear();
75
76Q_SIGNALS:
77 /**
78 * Emitted after the history has been cleared.
79 */
80 void cleared();
81
82 /**
83 * This signal is never emitted from this class, it is only meant as an
84 * interface for subclasses. Emit this signal to notify others that the
85 * history has changed. Put those items that were added or removed from the
86 * history into @p items.
87 */
88 void updated( const QStringList& items );
89
90 /**
91 * Emitted after the item has been inserted
92 */
93 void inserted( const QString& item );
94
95protected:
96 /**
97 * Creates a KHistoryProvider with an optional parent and name
98 */
99 HistoryProvider(QObject *parent = 0);
100
101 /**
102 * Destroys the provider.
103 */
104 virtual ~HistoryProvider();
105
106private:
107 HistoryProviderPrivate* const d;
108};
109
110}
111
112#endif // KHISTORYPROVIDER_H
113