attachmenticonview.h 2.25 KB
Newer Older
1
/*
2
3
4
5
6
7
8
  SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org>
  SPDX-FileCopyrightText: 2005 Reinhold Kainhofer <reinhold@kainhofer.com>
  SPDX-FileCopyrightText: 2005 Rafal Rzepecki <divide@users.sourceforge.net>
  SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org>
  SPDX-FileCopyrightText: 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>

  SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
9
10
11
12
13
14
15
16

  NOTE: May, 2010. Extracted this code from
        kdepim/incidenceeditors/editorattachments.{h,cpp}
*/

#ifndef INCIDENCEEDITOR_ATTACHMENTICONVIEW_H
#define INCIDENCEEDITOR_ATTACHMENTICONVIEW_H

17
#include <KCalendarCore/Attachment>
18
19
20
21
22
23

#include <QMimeType>
#include <QUrl>

#include <QListWidget>

Laurent Montel's avatar
Laurent Montel committed
24
25
namespace IncidenceEditorNG
{
26
27
class AttachmentIconView : public QListWidget
{
Laurent Montel's avatar
Laurent Montel committed
28
    Q_OBJECT
29
    friend class EditorAttachments;
Laurent Montel's avatar
Laurent Montel committed
30

31
public:
Laurent Montel's avatar
Laurent Montel committed
32
    explicit AttachmentIconView(QWidget *parent = nullptr);
33

Laurent Montel's avatar
Laurent Montel committed
34
    Q_REQUIRED_RESULT QMimeData *mimeData() const;
35
36

protected:
37
38
39
    QMimeData *mimeData(const QList<QListWidgetItem *> items) const override;
    void startDrag(Qt::DropActions supportedActions) override;
    void keyPressEvent(QKeyEvent *event) override;
40
41
42
43
44
};

class AttachmentIconItem : public QListWidgetItem
{
public:
45
    AttachmentIconItem(const KCalendarCore::Attachment &att, QListWidget *parent);
Laurent Montel's avatar
Laurent Montel committed
46
    ~AttachmentIconItem() override;
47

Laurent Montel's avatar
Laurent Montel committed
48
    Q_REQUIRED_RESULT KCalendarCore::Attachment attachment() const;
Laurent Montel's avatar
Laurent Montel committed
49
50
    Q_REQUIRED_RESULT const QString uri() const;
    Q_REQUIRED_RESULT const QString savedUri() const;
51
52
53
54
55
56
    void setUri(const QString &uri);

    using QListWidgetItem::setData;

    void setData(const QByteArray &data);

Laurent Montel's avatar
Laurent Montel committed
57
    Q_REQUIRED_RESULT const QString mimeType() const;
58
59
    void setMimeType(const QString &mime);

Laurent Montel's avatar
Laurent Montel committed
60
    Q_REQUIRED_RESULT const QString label() const;
61
62
    void setLabel(const QString &description);

Laurent Montel's avatar
Laurent Montel committed
63
    Q_REQUIRED_RESULT bool isBinary() const;
64
65

    static QPixmap icon(const QMimeType &mimeType, const QString &uri, bool binary = false);
Laurent Montel's avatar
Laurent Montel committed
66
    Q_REQUIRED_RESULT QPixmap icon() const;
67
68
69

    void readAttachment();

70
71
    Q_REQUIRED_RESULT QUrl tempFileForAttachment();

72
private:
73
    KCalendarCore::Attachment mAttachment;
74
    QString mSaveUri;
75
    QUrl mTempFile;
76
77
78
79
};
}

#endif // INCIDENCEEDITOR_ATTACHMENTICONVIEW_H