Sayonara Player
CustomMimeData.h
1 /* CustomMimeData.h */
2 
3 /* Copyright 2011-2019 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:
45 
46 // class AsyncDropHandler
47 // {};
48 
53  template<typename T>
54  CustomMimeData(const T* class_instance) :
55  CustomMimeData(static_cast<const void*>(class_instance))
56  {}
57 
58  virtual ~CustomMimeData();
59 
64  void set_metadata(const MetaDataList& v_md);
65 
71  const MetaDataList& metadata() const;
72 
77  bool has_metadata() const;
78 
79  void set_playlist_source_index(int playlist_idx);
80  int playlist_source_index() const;
81 
82  QString cover_url() const;
83  void set_cover_url(const QString& url);
84 
85 
86 // void set_drop_handler(AsyncDropHandler* handler);
87 // AsyncDropHandler* drop_handler() const;
88 
89  template<typename T>
90  bool has_source(const T* class_instance) const
91  {
92  const void* void_ptr = ptr();
93  const T* p = static_cast<const T*>(void_ptr);
94  if(!p){
95  return false;
96  }
97 
98  return (p == class_instance);
99  }
100  };
101 }
102 
103 #endif
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:35
bool has_metadata() const
check, if the custom mimedata has metadata
The MetaDataList class.
Definition: MetaDataList.h:37
void set_metadata(const MetaDataList &v_md)
Set metadata you want to drag and drop.
CustomMimeData(const T *class_instance)
Constructor.
Definition: CustomMimeData.h:54
const MetaDataList & metadata() const
get metadata from drag and drop