diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-10 00:18:25 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-10 00:18:25 +0000 |
commit | f21e5792b5084f5d008bf46f6316030c6dfb31e5 (patch) | |
tree | d51583b36aa1672bac78d98a682cdc330df27e4d /src/notedrag.h | |
download | basket-f21e5792b5084f5d008bf46f6316030c6dfb31e5.tar.gz basket-f21e5792b5084f5d008bf46f6316030c6dfb31e5.zip |
Add author-abandoned basket application
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/basket@1072339 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/notedrag.h')
-rw-r--r-- | src/notedrag.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/notedrag.h b/src/notedrag.h new file mode 100644 index 0000000..6dd9c62 --- /dev/null +++ b/src/notedrag.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright (C) 2003 by Sébastien Laoût * + * slaout@linux62.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef NOTEDRAG_H +#define NOTEDRAG_H + +#include <qstring.h> +#include <qdragobject.h> +#include <qdatastream.h> +#include <qpixmap.h> +#include <qvaluelist.h> +#include <kmultipledrag.h> + +class QDataStream; + +class Basket; +class Note; +class NoteSelection; + +/** Dragging/Copying/Cutting Scenario: + * - User select some notes and cut them; + * - NoteDrag::toMultipleDrag() is called with a tree of the selected notes (see Basket::toSelectionTree()): + * - This method create a new KMultipleDrag object, create a stream, + * - And then browse all notes and call the virtual Note::serialize() with the stream as parameter for them to serialize theire content in the "native format". + * - This give the MIME type "application/x-basket-note" that will be used by the application to paste the notes exactly as they were. + * - Then the method try to set alterante formats for the dragged objects: + * - It call successively toText() for each notes and stack up the result so theire is ONE big text flavour to add to the KMultipleDrag object + * - It do the same with toHtml(), toImage() and toLink() to have those flavours as well, if possible... + * - If there is only ONE copied note, addAlternateDragObjects() is called on it, so that Unknown objects can be dragged "as is". + * - It's OK for the flavours. The method finally set the drag feedback pixmap by asking every selected notes to draw the content to a small pixmap. + * - The pixmaps are joined to one big pixmap (but it should not exceed a defined size) and a border is drawn on this image. + * + * Pasting/Dropping Scenario: + * + * @author Sébastien Laoût + */ +class NoteDrag +{ + protected: + static void serializeNotes( NoteSelection *noteList, QDataStream &stream, bool cutting ); + static void serializeText( NoteSelection *noteList, KMultipleDrag *multipleDrag ); + static void serializeHtml( NoteSelection *noteList, KMultipleDrag *multipleDrag ); + static void serializeImage( NoteSelection *noteList, KMultipleDrag *multipleDrag ); + static void serializeLinks( NoteSelection *noteList, KMultipleDrag *multipleDrag, bool cutting ); + static void setFeedbackPixmap( NoteSelection *noteList, KMultipleDrag *multipleDrag ); + static Note* decodeHierarchy(QDataStream &stream, Basket *parent, bool moveFiles, bool moveNotes, Basket *originalBasket); + public: + static QPixmap feedbackPixmap(NoteSelection *noteList); + static QDragObject* dragObject(NoteSelection *noteList, bool cutting, QWidget *source = 0); + static bool canDecode(QMimeSource *source); + static Note* decode(QMimeSource *source, Basket *parent, bool moveFiles, bool moveNotes); + static Basket* basketOf(QMimeSource *source); + static QValueList<Note*> notesOf(QMimeSource *source); + static void createAndEmptyCuttingTmpFolder(); + + static const char *NOTE_MIME_STRING; +}; + +/** QTextDrag with capabilities to drop GNOME and Mozilla texts + * as well as UTF-16 texts even if it was supposed to be encoded + * with local encoding! + * @author Sébastien Laoût + */ +class ExtendedTextDrag : public QTextDrag +{ + Q_OBJECT + public: + static bool decode(const QMimeSource *e, QString &str); + static bool decode(const QMimeSource *e, QString &str, QCString &subtype); +}; + +// Support KDE 3.3 and older PROTECTED KURLDrag::encodedData()! + +#include <kurldrag.h> +class KURLDrag2 : public KURLDrag +{ + Q_OBJECT + public: + KURLDrag2(const KURL::List &urls) : KURLDrag(urls) {} + QByteArray encodedData2(const char *mime) const + { + return encodedData(mime); + } +}; + +#endif // NOTEDRAG_H |