blob: f8cc2c79825714cce4b18a778a70a85231a4e319 (
plain)
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
86
87
88
89
90
91
92
93
|
/***************************************************************************
station-drag-object.cpp - description
-------------------
begin : Sun Aug 28 2005
copyright : (C) 2005 by Martin Witte
email : witte@kawo1.rwth-aachen.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 "include/station-drag-object.h"
#include "include/errorlog-interfaces.h"
#include <klocale.h>
#define STATION_LIST_MIME_TYPE "multimedia/kradio-stationids"
StationDragObject::StationDragObject(const TQStringList &stationIDs, TQWidget *dragSource, const char * name)
: TQStoredDrag(STATION_LIST_MIME_TYPE, dragSource, name)
{
setStations(stationIDs);
}
StationDragObject::StationDragObject(TQWidget *dragSource, const char * name)
: TQStoredDrag(STATION_LIST_MIME_TYPE, dragSource, name)
{
}
StationDragObject::~StationDragObject()
{
}
const char *StationDragObject::format(int i) const
{
if (i == 0)
return STATION_LIST_MIME_TYPE;
else
return NULL;
}
void StationDragObject::setStations(const TQStringList &stationIDs)
{
TQByteArray tmp;
int pos = 0;
for (TQValueListConstIterator<TQString> it=stationIDs.begin(); it != stationIDs.end(); ++it) {
const TQString &s = *it;
tmp.resize(tmp.size()+s.length() + 1);
for (unsigned int k = 0; k < s.length(); ++k) {
tmp[pos++] = s[k].latin1();
}
tmp[pos++] = 0;
}
setEncodedData(tmp);
}
bool StationDragObject::canDecode (const TQMimeSource *e)
{
IErrorLogClient::staticLogDebug(e->format(0));
bool retval = (e && e->format(0) == TQString(STATION_LIST_MIME_TYPE));
if (retval)
IErrorLogClient::staticLogDebug(i18n("canDecode = true"));
return retval;
}
bool StationDragObject::decode (const TQMimeSource *e, TQStringList &stationIDs)
{
stationIDs.clear();
if (canDecode(e)) {
const TQByteArray &tmp = e->encodedData(e->format(0));
TQString str = "";
for (unsigned int pos = 0; pos < tmp.size(); ++pos) {
if (tmp[pos]) {
str.append(tmp[pos]);
} else {
stationIDs.append(str);
str = "";
}
}
}
return true;
}
|