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) by Andrew Stanley-Jones
5 Copyright (C) 2000 by Carsten Pfeiffer <pfeiffer@kde.org>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
25 #include "historystringitem.h"
26 #include "klipperpopup.h"
28 History::History( QObject
* parent
)
30 m_popup( new KlipperPopup( this ) ),
31 m_topIsUserSelected( false )
33 connect( this, SIGNAL( changed() ), m_popup
, SLOT( slotHistoryChanged() ) );
42 History::iterator
History::youngest() {
43 return iterator( itemList
);
46 void History::insert( const HistoryItem
* item
) {
50 m_topIsUserSelected
= false;
52 // Optimization: Compare with top item.
53 if ( !itemList
.isEmpty() && *itemList
.first() == *item
) {
65 void History::forceInsert( const HistoryItem
* item
) {
68 itemList
.prepend( item
);
73 void History::trim() {
74 int i
= itemList
.count() - max_size();
79 itemList
.removeLast();
84 void History::remove( const HistoryItem
* newItem
) {
88 if (itemList
.contains(newItem
)) {
89 itemList
.removeAll(newItem
);
95 void History::slotClear() {
100 void History::slotMoveToTop(QAction
*action
) {
102 int pos
= action
->data().toInt(&ok
);
103 if (!ok
) // not an action from popupproxy
106 if ( pos
< 0 || pos
>= itemList
.count() ) {
107 kDebug() << "Argument pos out of range: " << pos
;
111 m_topIsUserSelected
= true;
113 itemList
.move(pos
, 0);
118 void History::max_size( unsigned max_size
) {
119 m_max_size
= max_size
;
124 KlipperPopup
* History::popup() {
128 #include "history.moc"