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>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
20 #ifndef _HISTORYITEM_H_
21 #define _HISTORYITEM_H_
29 * An entry in the clipboard history.
35 virtual ~HistoryItem();
38 * Return the current item as text
39 * An image would be returned as a descriptive
40 * text, such as 32x43 image.
42 virtual QString
text() const = 0;
45 * Return the current item as text
46 * A text would be returned as a null pixmap,
47 * which is also the default implementation
49 inline virtual const QPixmap
& image() const;
52 * Returns a pointer to a QMimeData suitable for QClipboard::setMimeData().
54 virtual QMimeData
* mimeData() const = 0;
57 * Write object on datastream
59 virtual void write( QDataStream
& stream
) const = 0;
64 virtual bool operator==(const HistoryItem
& rhs
) const = 0;
67 * Create an HistoryItem from MimeSources (i.e., clipboard data)
68 * returns null if create fails (e.g, unsupported mimetype)
70 static HistoryItem
* create( const QMimeData
* data
);
73 * Create an HistoryItem from MimeSources (i.e., clipboard data)
74 * returns null if creation fails. In this case, the datastream
75 * is left in an undefined state.
77 static HistoryItem
* create( QDataStream
& aSource
);
81 const QPixmap
& HistoryItem::image() const {
82 static QPixmap nullPixmap
;
87 QDataStream
& operator<<( QDataStream
& lhs
, HistoryItem
const * const rhs
) {