Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / klipper / history.h
blob0cdf6931062ebfad5543203f5ea2fd2e15b0f7c1
1 // -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
2 /* This file is part of the KDE project
3 Copyright (C) 2004 Esben Mose Hansen <kde@mosehansen.dk>
4 Copyright (C) Andrew Stanley-Jones
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
21 #ifndef HISTORY_H
22 #define HISTORY_H
24 #include <QAction>
25 #include <QList>
27 #include "historyitem.h"
29 class KlipperPopup;
31 class History : public QObject
33 Q_OBJECT
34 public:
35 History( QObject* parent );
36 ~History();
37 /**
38 * Iterator for history
40 typedef QListIterator<const HistoryItem*> iterator;
42 /**
43 * Return (toplevel) popup menu (or default view, of you like)
45 KlipperPopup* popup();
47 /**
48 * Inserts item into clipboard history top
49 * if duplicate entry exist, the older duplicate is deleted.
50 * The duplicate concept is "deep", so that two text string
51 * are considerd duplicate if identical.
53 void insert( const HistoryItem* item );
55 /**
56 * Inserts item into clipboard without any checks
57 * Used when restoring a saved history and internally.
58 * Don't use this unless you're reasonable certain
59 * that no duplicates are introduced
61 void forceInsert( const HistoryItem* item );
63 /**
64 * Remove (first) history item equal to item from history
66 void remove( const HistoryItem* item );
68 /**
69 * Traversal: Get first item
71 const HistoryItem* first();
73 /**
74 * Get an iterator pointing to the first (most recent) item
75 * This iterator should probably be a constant iterator, but
76 * the QTL doesn't support this easily.
78 * Anyway, if you modify the items via. the iterator, call changed()
79 * when you're done. Calling changed() multiple times doesn't hurt.
81 * iterator could be made into a proxy class that did the right thing.
83 iterator youngest();
85 /**
86 * True if no history items
88 bool empty() const { return itemList.isEmpty(); }
90 /**
91 * Set maximum history size
93 void max_size( unsigned max_size );
95 /**
96 * Get the maximum history size
98 unsigned max_size() const { return m_max_size; }
101 * returns true if the user has selected the top item
103 bool topIsUserSelected() {
104 return m_topIsUserSelected;
107 public Q_SLOTS:
109 * move the history in position pos to top
111 void slotMoveToTop(QAction *action);
114 * Clear history
116 void slotClear();
118 Q_SIGNALS:
119 void changed();
122 * Emitted when the first history item has changed.
124 void topChanged();
126 private:
129 * The history
131 QList<const HistoryItem*> itemList;
134 * ensure that the number of items does not exceed max_size()
135 * Deletes items from the end as necessary.
137 void trim();
139 private:
141 * "Default view" --- a popupmenu containing the clipboard history.
143 KlipperPopup* m_popup;
147 * The number of clipboard items stored.
149 unsigned m_max_size;
152 * True if the top is selected by the user
154 bool m_topIsUserSelected;
158 inline const HistoryItem* History::first() { return itemList.count() > 0 ? itemList.first() : 0; }
160 #endif