kwave  18.07.70
FileDrag.h
Go to the documentation of this file.
1 /***************************************************************************
2  FileDrag.h - check if Kwave can handle a mime type per drag&drop
3  -------------------
4  begin : Sat Feb 26 2011
5  copyright : (C) 2011 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef FILE_DRAG_H
19 #define FILE_DRAG_H
20 
21 #include "config.h"
22 
23 #include <QMimeData>
24 #include <QString>
25 #include <QUrl>
26 
27 #include "libkwave/CodecManager.h"
28 #include "libkwave/String.h"
29 
30 namespace Kwave
31 {
32  namespace FileDrag
33  {
34  static inline bool canDecode(const QMimeData *source) {
35  if (!source) return false;
36 
37  if (source->hasUrls()) {
38  // dropping URLs
39  foreach (QUrl url, source->urls()) {
40  QString mimetype =
42  if (Kwave::CodecManager::canDecode(mimetype)) {
43  return true;
44  }
45  }
46  }
47 
48  foreach (QString format, source->formats()) {
49  // dropping known mime type
50  if (Kwave::CodecManager::canDecode(format)) {
51  qDebug("Kwave::FileDrag::canDecode(%s)",
52  DBG(QString(format)));
53  return true;
54  }
55  }
56  return false;
57  }
58  }
59 }
60 
61 #endif /* FILE_DRAG_H */
62 
63 //***************************************************************************
64 //***************************************************************************
Definition: App.h:33
static QString mimeTypeOf(const QUrl &url)
static bool canDecode(const QMimeData *source)
Definition: FileDrag.h:34
#define DBG(qs)
Definition: String.h:55
static bool canDecode(const QString &mimetype_name)