File indexing completed on 2024-04-28 05:11:32
0001 /* 0002 SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org> 0003 SPDX-FileCopyrightText: 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "incidenceeditor-ng.h" 0011 class QUrl; 0012 class KJob; 0013 namespace Ui 0014 { 0015 class EventOrTodoDesktop; 0016 } 0017 0018 class QMenu; 0019 0020 class QListWidgetItem; 0021 class QMimeData; 0022 class QAction; 0023 namespace IncidenceEditorNG 0024 { 0025 class AttachmentIconView; 0026 0027 class IncidenceAttachment : public IncidenceEditor 0028 { 0029 Q_OBJECT 0030 public: 0031 using IncidenceEditorNG::IncidenceEditor::load; // So we don't trigger -Woverloaded-virtual 0032 using IncidenceEditorNG::IncidenceEditor::save; // So we don't trigger -Woverloaded-virtual 0033 0034 explicit IncidenceAttachment(Ui::EventOrTodoDesktop *ui); 0035 0036 ~IncidenceAttachment() override; 0037 0038 void load(const KCalendarCore::Incidence::Ptr &incidence) override; 0039 void save(const KCalendarCore::Incidence::Ptr &incidence) override; 0040 [[nodiscard]] bool isDirty() const override; 0041 0042 [[nodiscard]] int attachmentCount() const; 0043 0044 Q_SIGNALS: 0045 void attachmentCountChanged(int newCount); 0046 0047 private: 0048 void addAttachment(); 0049 void copyToClipboard(); /// Copies selected items to clip board 0050 void cutToClipboard(); /// Copies selected items to clipboard and removes them from the list 0051 void editSelectedAttachments(); 0052 void openURL(const QUrl &url); 0053 void pasteFromClipboard(); 0054 void removeSelectedAttachments(); 0055 void saveAttachment(QListWidgetItem *item); 0056 void saveSelectedAttachments(); 0057 void showAttachment(QListWidgetItem *item); 0058 void showContextMenu(const QPoint &pos); 0059 void showSelectedAttachments(); 0060 void slotItemRenamed(QListWidgetItem *item); 0061 void slotSelectionChanged(); 0062 void downloadComplete(KJob *); 0063 0064 private: 0065 // void addAttachment( KCalendarCore::Attachment *attachment ); 0066 void addDataAttachment(const QByteArray &data, const QString &mimeType = QString(), const QString &label = QString()); 0067 void addUriAttachment(const QString &uri, const QString &mimeType = QString(), const QString &label = QString(), bool inLine = false); 0068 void handlePasteOrDrop(const QMimeData *mimeData); 0069 void setupActions(); 0070 void setupAttachmentIconView(); 0071 0072 private: 0073 AttachmentIconView *mAttachmentView = nullptr; 0074 Ui::EventOrTodoDesktop *const mUi; 0075 0076 QMenu *const mPopupMenu; 0077 QAction *mOpenAction = nullptr; 0078 QAction *mSaveAsAction = nullptr; 0079 #ifndef QT_NO_CLIPBOARD 0080 QAction *mCopyAction = nullptr; 0081 QAction *mCutAction = nullptr; 0082 #endif 0083 QAction *mDeleteAction = nullptr; 0084 QAction *mEditAction = nullptr; 0085 }; 0086 }