File indexing completed on 2024-04-28 16:54:24

0001 /*
0002     SPDX-FileCopyrightText: 2004 Esben Mose Hansen <kde@mosehansen.dk>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include <QMimeData>
0009 
0010 #include "historyitem.h"
0011 
0012 /**
0013  * A string entry in the clipboard history.
0014  */
0015 class HistoryStringItem : public HistoryItem
0016 {
0017 public:
0018     explicit HistoryStringItem(const QString &data);
0019     ~HistoryStringItem() override
0020     {
0021     }
0022 
0023     HistoryItemType type() const override
0024     {
0025         return HistoryItemType::Text;
0026     }
0027 
0028     QString text() const override;
0029     bool operator==(const HistoryItem &rhs) const override
0030     {
0031         if (const HistoryStringItem *casted_rhs = dynamic_cast<const HistoryStringItem *>(&rhs)) {
0032             return casted_rhs->m_data == m_data;
0033         }
0034         return false;
0035     }
0036     QMimeData *mimeData() const override;
0037 
0038     /**
0039      * Write object on datastream
0040      */
0041     void write(QDataStream &stream) const override;
0042 
0043 private:
0044     QString m_data;
0045 };
0046 
0047 inline QString HistoryStringItem::text() const
0048 {
0049     return m_data;
0050 }