[3e4acc]: libkwave / KwaveDrag.cpp Maximize Restore History

Download this file

KwaveDrag.cpp    86 lines (71 with data), 3.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***************************************************************************
KwaveDrag.cpp - Drag&Drop container for Kwave's audio data
-------------------
begin : Jan 24 2002
copyright : (C) 2002 by Thomas Eschenbacher
email : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "config.h"
#include <QMimeData>
#include "libkwave/CodecManager.h"
#include "libkwave/KwaveDrag.h"
#include "libkwave/KwaveMimeData.h"
#include "libkwave/MultiTrackReader.h"
// RFC 2361:
#define WAVE_FORMAT_PCM "audio/vnd.wave" // ; codec=001"
//***************************************************************************
KwaveDrag::KwaveDrag(QWidget *dragSource)
:QDrag(dragSource)
{
}
//***************************************************************************
KwaveDrag::~KwaveDrag()
{
}
//***************************************************************************
bool KwaveDrag::canDecode(const QMimeData *data)
{
if (!data) return false;
foreach (QString format, data->formats())
if (CodecManager::canDecode(format)) return true;
return false;
}
//***************************************************************************
bool KwaveDrag::encode(QWidget *widget, MultiTrackReader &src,
const Kwave::MetaDataList &meta_data)
{
Q_ASSERT(src.tracks());
if (!src.tracks()) return false;
Q_ASSERT(src[0]);
if (!src[0]) return false;
// create a mime data container
Kwave::MimeData *mime_data = new Kwave::MimeData;
Q_ASSERT(mime_data);
if (!mime_data) return false;
// encode into the mime data
if (!mime_data->encode(widget, src, meta_data)) {
delete mime_data;
return false;
}
// use it for the drag container
setMimeData(mime_data);
return true;
}
//***************************************************************************
unsigned int KwaveDrag::decode(QWidget *widget, const QMimeData *e,
SignalManager &sig, sample_index_t pos)
{
return Kwave::MimeData::decode(widget, e, sig, pos);
}
//***************************************************************************
#include "KwaveDrag.moc"
//***************************************************************************
//***************************************************************************