korganizer
koeditorattachments.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef KOEDITORATTACHMENTS_H
00026 #define KOEDITORATTACHMENTS_H
00027
00028 #include <qwidget.h>
00029 #include <qmap.h>
00030 #include <kdialogbase.h>
00031 #include <kmimetype.h>
00032 #include <kurl.h>
00033 #include <kiconview.h>
00034
00035 #include <set>
00036
00037 class AttachmentListItem;
00038 class AttachmentIconView;
00039
00040 namespace KCal {
00041 class Incidence;
00042 class Attachment;
00043 }
00044
00045 class QCheckBox;
00046 class QIconViewItem;
00047 class QLabel;
00048 class QMimeSource;
00049 class QPushButton;
00050 class QPopupMenu;
00051
00052 class KAction;
00053 class KLineEdit;
00054 class KURLRequester;
00055 class KTempDir;
00056
00057 class AttachmentEditDialog : public KDialogBase
00058 {
00059 Q_OBJECT
00060 public:
00061 AttachmentEditDialog( AttachmentListItem *item, QWidget *parent=0 );
00062
00063 void accept();
00064
00065 protected slots:
00066 void urlSelected( const QString &url );
00067 void urlChanged( const QString & url );
00068 virtual void slotApply();
00069
00070 private:
00071 friend class KOEditorAttachments;
00072 KMimeType::Ptr mMimeType;
00073 AttachmentListItem *mItem;
00074 QLabel *mTypeLabel, *mIcon;
00075 QCheckBox *mInline;
00076 KLineEdit *mLabelEdit;
00077 KURLRequester *mURLRequester;
00078 };
00079
00080 class KOEditorAttachments : public QWidget
00081 {
00082 Q_OBJECT
00083 public:
00084 KOEditorAttachments( int spacing = 8, QWidget *parent = 0,
00085 const char *name = 0 );
00086 ~KOEditorAttachments();
00087
00088 void addUriAttachment( const QString &uri,
00089 const QString &mimeType = QString(),
00090 const QString &label = QString(),
00091 bool inLine = false );
00092 void addAttachment( KCal::Attachment *attachment );
00093 void addDataAttachment( const QByteArray &data,
00094 const QString &mimeType = QString(),
00095 const QString &label = QString() );
00096
00098 void setDefaults();
00100 void readIncidence( KCal::Incidence * );
00102 void writeIncidence( KCal::Incidence * );
00103
00104 bool hasAttachments();
00105
00106 protected slots:
00107 void showAttachment( QIconViewItem *item );
00108 void saveAttachment( QIconViewItem *item );
00109 void slotAdd();
00110 void slotAddData();
00111 void slotEdit();
00112 void slotRemove();
00113 void slotShow();
00114 void slotSaveAs();
00115 void dragEnterEvent( QDragEnterEvent *event );
00116 void dragMoveEvent( QDragMoveEvent *event );
00117 void dropEvent( QDropEvent *event );
00118 void slotCopy();
00119 void slotCut();
00120 void slotPaste();
00121 void selectionChanged();
00122 void contextMenu( QIconViewItem* item, const QPoint &pos );
00123
00124 signals:
00125 void openURL( const KURL &url );
00126
00127 protected:
00128 enum {
00129 DRAG_COPY = 0,
00130 DRAG_LINK = 1,
00131 DRAG_CANCEL = 2
00132 };
00133
00134 private:
00135 friend class AttachmentIconView;
00136 void handlePasteOrDrop( QMimeSource* source );
00137 QString randomString( int length ) const;
00138 AttachmentIconView *mAttachments;
00139 QPushButton *mRemoveBtn;
00140 QPopupMenu *mContextMenu, *mAddMenu;
00141 KAction *mOpenAction;
00142 KAction *mSaveAsAction;
00143 KAction *mCopyAction;
00144 KAction *mCutAction;
00145 KAction *mDeleteAction;
00146 KAction *mEditAction;
00147 };
00148
00149
00150 class AttachmentIconView : public KIconView
00151 {
00152 Q_OBJECT
00153
00154 friend class KOEditorAttachments;
00155 public:
00156 AttachmentIconView( KOEditorAttachments* parent=0 );
00157 KURL tempFileForAttachment( KCal::Attachment *attachment );
00158 QDragObject *mimeData();
00159 ~AttachmentIconView();
00160
00161 protected:
00162 QDragObject * dragObject();
00163
00164 void dragMoveEvent( QDragMoveEvent *event );
00165 void contentsDragMoveEvent( QDragMoveEvent *event );
00166 void contentsDragEnterEvent( QDragEnterEvent *event );
00167 void dragEnterEvent( QDragEnterEvent *event );
00168
00169 protected slots:
00170
00171 void handleDrop( QDropEvent *event, const QValueList<QIconDragItem> & list );
00172
00173 private:
00174 std::set<KTempDir*> mTempDirs;
00175 QMap<KCal::Attachment *, KURL> mTempFiles;
00176 KOEditorAttachments* mParent;
00177 };
00178
00179 #endif
|