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 <tqwidget.h>
00029 #include <tqmap.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 TQCheckBox;
00046 class TQIconViewItem;
00047 class TQLabel;
00048 class TQMimeSource;
00049 class TQPushButton;
00050 class TQPopupMenu;
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, TQWidget *parent=0 );
00062
00063 void accept();
00064
00065 protected slots:
00066 void urlSelected( const TQString &url );
00067 void urlChanged( const TQString & url );
00068 virtual void slotApply();
00069
00070 private:
00071 friend class KOEditorAttachments;
00072 KMimeType::Ptr mMimeType;
00073 AttachmentListItem *mItem;
00074 TQLabel *mTypeLabel, *mIcon;
00075 TQCheckBox *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, TQWidget *parent = 0,
00085 const char *name = 0 );
00086 ~KOEditorAttachments();
00087
00088 void addUriAttachment( const TQString &uri,
00089 const TQString &mimeType = TQString(),
00090 const TQString &label = TQString(),
00091 bool inLine = false );
00092 void addAttachment( KCal::Attachment *attachment );
00093 void addDataAttachment( const TQByteArray &data,
00094 const TQString &mimeType = TQString(),
00095 const TQString &label = TQString() );
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( TQIconViewItem *item );
00108 void saveAttachment( TQIconViewItem *item );
00109 void slotAdd();
00110 void slotAddData();
00111 void slotEdit();
00112 void slotRemove();
00113 void slotShow();
00114 void slotSaveAs();
00115 void dragEnterEvent( TQDragEnterEvent *event );
00116 void dragMoveEvent( TQDragMoveEvent *event );
00117 void dropEvent( TQDropEvent *event );
00118 void slotCopy();
00119 void slotCut();
00120 void slotPaste();
00121 void selectionChanged();
00122 void contextMenu( TQIconViewItem* item, const TQPoint &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( TQMimeSource* source );
00137 TQString randomString( int length ) const;
00138 AttachmentIconView *mAttachments;
00139 TQPushButton *mRemoveBtn;
00140 TQPopupMenu *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 TQDragObject *mimeData();
00159 ~AttachmentIconView();
00160
00161 protected:
00162 TQDragObject * dragObject();
00163
00164 void dragMoveEvent( TQDragMoveEvent *event );
00165 void contentsDragMoveEvent( TQDragMoveEvent *event );
00166 void contentsDragEnterEvent( TQDragEnterEvent *event );
00167 void dragEnterEvent( TQDragEnterEvent *event );
00168
00169 protected slots:
00170
00171 void handleDrop( TQDropEvent *event, const TQValueList<TQIconDragItem> & list );
00172
00173 private:
00174 std::set<KTempDir*> mTempDirs;
00175 TQMap<KCal::Attachment *, KURL> mTempFiles;
00176 KOEditorAttachments* mParent;
00177 };
00178
00179 #endif
|