From b0d671fede5adfadad2b465fb4c8ae50b40516f3 Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 10 Apr 2014 16:14:32 +0200 Subject: Implement Drag and Drop in Movie Archive Well, this was actually a bit of a drag. You have read the docs very carefully to get it right. For one, don't construct the drag object in mousePressEvent if you also want a double click, otherwise you end up with very weird behavior. Same goes for the receiving end. Differentiate between dragEnterEvent and dragMoveEvent, otherwise you'll only be able to drop items if you hit the right row on entering. There are some artefacts during the drag, but I guess that's a Qt bug. Didn't bother to look into it. --- archivemodel.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'archivemodel.h') diff --git a/archivemodel.h b/archivemodel.h index a9a11eb..20f878c 100644 --- a/archivemodel.h +++ b/archivemodel.h @@ -31,6 +31,8 @@ class ArchiveModel : public SmTreeModel { enum NodeType { SeriesNode = 1, SeriesPartNode = 2, GenreNode = 4, ActorNode = 8, AllNodes = 15 }; explicit ArchiveModel(const QStringList &headers, QObject *parent = 0); virtual ~ArchiveModel(); + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + virtual Qt::DropActions supportedDragActions() const; const QStringList availableOrders() const; const QHash availableOrdersHash() const { return mAvailableOrders; } virtual QVariant data(const QModelIndex &index, int role) const; @@ -103,6 +105,7 @@ class ArchiveFilesModel : public SmTreeModel { bool isMovie(const QModelIndex &idx) const; void populate(const QSet &seriesPartIds); QStringList filesForSeriespart(int seriesPartId) const; + void updateSeriesPartForFile(const QString &md5sum, int newSeriesPart); public slots: void refresh(); -- cgit v1.2.3-70-g09d2