libkdepim

maillistdrag.h

00001 /*
00002     This file is part of libkdepim.
00003 
00004     Copyright (c) 2003 Don Sanders <sanders@kde.org>
00005     Copyright (c) 2005 George Staikos <staikos@kde.org.
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library 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 GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #ifndef maillistdrag_h
00023 #define maillistdrag_h
00024 
00025 #include "qdragobject.h"
00026 #include "qvaluelist.h"
00027 #include "qglobal.h"
00028 #include "time.h"
00029 
00030 #include <kdepimmacros.h>
00031 
00045 namespace KPIM {
00046 
00047 class KDE_EXPORT MailSummary
00048 {
00049 public:
00050     MailSummary( Q_UINT32 serialNumber, QString messageId, QString subject,
00051          QString from, QString to, time_t date );
00052     MailSummary() {}
00053     ~MailSummary() {}
00054 
00055     /*** Set fields for this mail summary  ***/
00056     void set( Q_UINT32, QString, QString, QString, QString, time_t );
00057 
00058     /*** KMail unique identification number ***/
00059     Q_UINT32 serialNumber() const;
00060 
00061     /*** MD5 checksum of message identification string ***/
00062     QString messageId();
00063 
00064     /*** Subject of the message including prefixes ***/
00065     QString subject();
00066 
00067     /*** Simplified from address ***/
00068     QString from();
00069 
00071     QString to();
00072 
00073     /*** Date the message was sent ***/
00074     time_t date();
00075 
00076 private:
00077     Q_UINT32 mSerialNumber;
00078     QString mMessageId, mSubject, mFrom, mTo;
00079     time_t mDate;
00080 };
00081 
00082 // List of mail summaries
00083 typedef QValueList<MailSummary> MailList;
00084 
00085 // Object for the drag object to call-back for message fulltext
00086 class KDE_EXPORT MailTextSource {
00087 public:
00088     MailTextSource() {}
00089     virtual ~MailTextSource() {}
00090 
00091     virtual QCString text(Q_UINT32 serialNumber) const = 0;
00092 };
00093 
00094 // Drag and drop object for mails
00095 class KDE_EXPORT MailListDrag : public QDragObject
00096 {
00097 public:
00098     // Takes ownership of "src" and deletes it when done
00099     MailListDrag( const MailList& mails, QWidget * parent, MailTextSource *src );
00100     ~MailListDrag();
00101 
00102     const char *format(int i) const;
00103 
00104     QByteArray encodedData(const char *) const;
00105 
00106     /* Reset the list of mail summaries */
00107     void setMailList( const MailList& mails );
00108 
00109     /* The format for this drag - "x-kmail-drag/message-list" */
00110     static const char* format();
00111 
00112     /* Returns TRUE if the information in e can be decoded into a QString;
00113        otherwsie returns FALSE */
00114     static bool canDecode( QMimeSource* e );
00115 
00116     /* Attempts to decode the dropped information;
00117        Returns TRUE if successful; otherwise return false */
00118     static bool decode( QDropEvent* e, MailList& s );
00119 
00120     /* Attempts to decode the serialNumbers of the dropped information;
00121        Returns TRUE if successful; otherwise return false */
00122     static bool decode( QDropEvent* e, QByteArray& a );
00123 
00124     /* Attempts to decode the encoded MailList;
00125        Returns TRUE if successful; otherwise return false */
00126     static bool decode( QByteArray& a, MailList& s );
00127 
00128 private:
00129     MailTextSource *_src;
00130     MailList _mailList;
00131 };
00132 
00133 }
00134 #endif /*maillistdrag_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys