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.
27
#include "historyitem.h"
31
class History : public QObject
35
History( QObject* parent );
39
* Return (toplevel) popup menu (or default view, of you like)
41
KlipperPopup* popup();
44
* Inserts item into clipboard history top
45
* if duplicate entry exist, the older duplicate is deleted.
46
* The duplicate concept is "deep", so that two text string
47
* are considerd duplicate if identical.
49
void insert( HistoryItem* item );
52
* Inserts item into clipboard without any checks
53
* Used when restoring a saved history and internally.
54
* Don't use this unless you're reasonable certain
55
* that no duplicates are introduced
57
void forceInsert( HistoryItem* item );
60
* Remove (first) history item equal to item from history
62
void remove( const HistoryItem* item );
65
* Traversal: Get first item
67
const HistoryItem* first() const;
70
* Get item identified by uuid
72
const HistoryItem* find(const QByteArray& uuid) const;
75
* @return next item in cycle, or null if at end
77
const HistoryItem* nextInCycle() const;
80
* @return previous item in cycle, or null if at top
82
const HistoryItem* prevInCycle() const;
85
* True if no history items
87
bool empty() const { return m_items.isEmpty(); }
90
* Set maximum history size
92
void setMaxSize( unsigned max_size );
95
* Get the maximum history size
97
unsigned maxSize() const { return m_max_size; }
100
* returns true if the user has selected the top item
102
bool topIsUserSelected() {
103
return m_topIsUserSelected;
118
* move the history in position pos to top
120
void slotMoveToTop(QAction *action);
123
* move the history in position pos to top
125
void slotMoveToTop(const QByteArray& uuid);
136
* Emitted when the first history item has changed.
142
* ensure that the number of items does not exceed max_size()
143
* Deletes items from the end as necessary.
148
typedef QHash<QByteArray, HistoryItem*> items_t;
160
* "Default view" --- a popupmenu containing the clipboard history.
162
KlipperPopup* m_popup;
166
* The number of clipboard items stored.
171
* True if the top is selected by the user
173
bool m_topIsUserSelected;
176
* The "next" when cycling through the
177
* history. May be 0, if history is empty
179
HistoryItem* m_nextCycle;
182
inline const HistoryItem* History::first() const { return m_top; }