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 
29 namespace Gui
30 {
35  class CustomMimeData : public QMimeData
36  {
37 
38  private:
39  PIMPL(CustomMimeData)
40 
41  CustomMimeData(const void* p);
42  const void* ptr() const;
43 
44  public:
49  template<typename T>
50  CustomMimeData(const T* class_instance) :
51  CustomMimeData(static_cast<const void*>(class_instance))
52  {}
53 
54  virtual ~CustomMimeData() override;
55 
60  void setMetadata(const MetaDataList& v_md);
61 
67  const MetaDataList& metadata() const;
68 
73  bool hasMetadata() const;
74 
75  void setPlaylistSourceIndex(int playlistIndex);
76  int playlistSourceIndex() const;
77 
78  QString coverUrl() const;
79  void setCoverUrl(const QString& url);
80 
81  template<typename T>
82  bool hasSource(const T* classInstance) const
83  {
84  const void* voidPtr = ptr();
85  const T* p = static_cast<const T*>(voidPtr);
86  if(!p){
87  return false;
88  }
89 
90  return (p == classInstance);
91  }
92  };
93 }
94 
95 #endif
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:35
void setMetadata(const MetaDataList &v_md)
Set metadata you want to drag and drop.
The MetaDataList class.
Definition: MetaDataList.h:35
CustomMimeData(const T *class_instance)
Constructor.
Definition: CustomMimeData.h:50
bool hasMetadata() const
check, if the custom mimedata has metadata
const MetaDataList & metadata() const
get metadata from drag and drop