Sayonara Player
CustomMimeData.h
1 /* CustomMimeData.h */
2 
3 /* Copyright 2011-2017 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 #include "Utils/MetaData/MetaDataFwd.h"
26 
27 #include <QMimeData>
28 
33 class CustomMimeData : public QMimeData
34 {
35 
36 private:
37  PIMPL(CustomMimeData)
38 
39  CustomMimeData(const void* p);
40  const void* ptr() const;
41 
42 public:
47  template<typename T>
48  CustomMimeData(const T* class_instance) :
49  CustomMimeData(static_cast<const void*>(class_instance))
50  {}
51 
52  virtual ~CustomMimeData();
53 
58  void set_metadata(const MetaDataList& v_md);
59 
65  const MetaDataList& metadata() const;
66 
71  bool has_metadata() const;
72 
73  void set_playlist_source_index(int playlist_idx);
74  int playlist_source_index() const;
75 
76  QString cover_url() const;
77  void set_cover_url(const QString& url);
78 
79  template<typename T>
80  bool has_source(const T* class_instance) const
81  {
82  const void* void_ptr = ptr();
83  const T* p = static_cast<const T*>(void_ptr);
84  if(!p){
85  return false;
86  }
87 
88  return (p == class_instance);
89  }
90 };
91 
92 #endif
const MetaDataList & metadata() const
get metadata from drag and drop
The MetaDataList class.
Definition: MetaDataList.h:38
void set_metadata(const MetaDataList &v_md)
Set metadata you want to drag and drop.
CustomMimeData(const T *class_instance)
Constructor.
Definition: CustomMimeData.h:48
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:33
bool has_metadata() const
check, if the custom mimedata has metadata