Sayonara Player
CustomMimeData.h
1/* CustomMimeData.h */
2
3/* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef _CUSTOMMIMEDATA_H
22#define _CUSTOMMIMEDATA_H
23
24#include "Utils/Pimpl.h"
25
26#include <QMimeData>
27
28
29namespace Gui
30{
31 class AsyncDropHandler;
36 class CustomMimeData : public QMimeData
37 {
38
39 private:
40 PIMPL(CustomMimeData)
41
42 CustomMimeData(const void* data);
43 const void* ptr() const;
44
45 public:
50 template<typename T>
51 CustomMimeData(const T* class_instance) :
52 CustomMimeData(static_cast<const void*>(class_instance))
53 {}
54
55 virtual ~CustomMimeData() override;
56
61 void setMetadata(const MetaDataList& v_md);
62
68 const MetaDataList& metadata() const;
69
74 bool hasMetadata() const;
75
76 void setPlaylistSourceIndex(int playlistIndex);
77 int playlistSourceIndex() const;
78
79 QString coverUrl() const;
80 void setCoverUrl(const QString& url);
81
82 template<typename T>
83 bool hasSource(const T* classInstance) const
84 {
85 const void* voidPtr = ptr();
86 const T* p = static_cast<const T*>(voidPtr);
87 if(!p){
88 return false;
89 }
90
91 return (p == classInstance);
92 }
93
94 void setAsyncDropHandler(Gui::AsyncDropHandler* handler);
95 Gui::AsyncDropHandler* asyncDropHandler() const;
96 };
97}
98
99#endif
Definition: DragDropAsyncHandler.h:12
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:37
const MetaDataList & metadata() const
get metadata from drag and drop
bool hasMetadata() const
check, if the custom mimedata has metadata
CustomMimeData(const T *class_instance)
Constructor.
Definition: CustomMimeData.h:51
void setMetadata(const MetaDataList &v_md)
Set metadata you want to drag and drop.
The MetaDataList class.
Definition: MetaDataList.h:37