korganizer

koeditorattachments.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (c) 2005 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 #ifndef KOEDITORATTACHMENTS_H
00026 #define KOEDITORATTACHMENTS_H
00027 
00028 #include <qwidget.h>
00029 #include <kurl.h>
00030 #include <kiconview.h>
00031 
00032 #include <set>
00033 
00034 namespace KCal {
00035 class Incidence;
00036 class Attachment;
00037 }
00038 
00039 class QIconViewItem;
00040 class AttachmentIconView;
00041 class QMimeSource;
00042 class QPushButton;
00043 class QPopupMenu;
00044 class KAction;
00045 class KTempDir;
00046 
00047 class KOEditorAttachments : public QWidget
00048 {
00049     Q_OBJECT
00050   public:
00051     KOEditorAttachments( int spacing = 8, QWidget *parent = 0,
00052                          const char *name = 0 );
00053     ~KOEditorAttachments();
00054 
00055     void addAttachment( const KURL &uri,
00056                         const QString &mimeType = QString::null, bool asUri = true );
00057     void addAttachment( KCal::Attachment *attachment );
00058 
00060     void setDefaults();
00062     void readIncidence( KCal::Incidence * );
00064     void writeIncidence( KCal::Incidence * );
00065 
00066     bool hasAttachments();
00067 
00068   protected slots:
00069     void showAttachment( QIconViewItem *item );
00070     void slotAdd();
00071     void slotAddData();
00072     void slotEdit();
00073     void slotRemove();
00074     void slotShow();
00075     void dragEnterEvent( QDragEnterEvent *event );
00076     void dragMoveEvent( QDragMoveEvent *event );
00077     void dropEvent( QDropEvent *event );
00078     void slotCopy();
00079     void slotCut();
00080     void slotPaste();
00081     void selectionChanged();
00082     void contextMenu( QIconViewItem* item, const QPoint &pos );
00083   signals:
00084     void openURL( const KURL &url );
00085 
00086   private:
00087     friend class AttachmentIconView;
00088     void handlePasteOrDrop( QMimeSource* source );
00089 
00090     AttachmentIconView *mAttachments;
00091     QPushButton *mRemoveBtn;
00092     QPopupMenu *mContextMenu, *mAddMenu;
00093     KAction *mOpenAction, *mCopyAction, *mCutAction;
00094 };
00095 
00096 
00097 class AttachmentIconView : public KIconView
00098 {
00099   Q_OBJECT
00100 
00101   friend class KOEditorAttachments;
00102   public:
00103     AttachmentIconView( KOEditorAttachments* parent=0 );
00104 
00105     ~AttachmentIconView();
00106 
00107   protected:
00108     QDragObject * dragObject();
00109 
00110     void dragMoveEvent( QDragMoveEvent *event );
00111     void contentsDragMoveEvent( QDragMoveEvent *event );
00112     void contentsDragEnterEvent( QDragEnterEvent *event );
00113     void dragEnterEvent( QDragEnterEvent *event );
00114 
00115   protected slots:
00116 
00117     void handleDrop( QDropEvent *event, const QValueList<QIconDragItem> & list );
00118 
00119   private:
00120     std::set<KTempDir*> mTempDirs;
00121     KOEditorAttachments* mParent;
00122 };
00123 
00124 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys