Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / klipper / historyitem.h
blobf3ed457aae9c26cb657f1ecf3841ba26e9555d6a
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_
22 #include <QPixmap>
24 class QString;
25 class QMimeData;
26 class QDataStream;
28 /**
29 * An entry in the clipboard history.
31 class HistoryItem
33 public:
34 HistoryItem( );
35 virtual ~HistoryItem();
37 /**
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;
44 /**
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;
51 /**
52 * Returns a pointer to a QMimeData suitable for QClipboard::setMimeData().
54 virtual QMimeData* mimeData() const = 0;
56 /**
57 * Write object on datastream
59 virtual void write( QDataStream& stream ) const = 0;
61 /**
62 * Equality.
64 virtual bool operator==(const HistoryItem& rhs) const = 0;
66 /**
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 );
72 /**
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 );
80 inline
81 const QPixmap& HistoryItem::image() const {
82 static QPixmap nullPixmap;
83 return nullPixmap;
86 inline
87 QDataStream& operator<<( QDataStream& lhs, HistoryItem const * const rhs ) {
88 if ( rhs ) {
89 rhs->write( lhs );
91 return lhs;
95 #endif