blob: fd12aed387f5052f526c433fa326124262dba629 (
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
|
/***************************************************************************
* $Id$
**
* Custom MIME type implementation example
**
* Created : 979899
**
* Copyright (C) 1997 by Trolltech AS. All rights reserved.
**
* This file is part of an example program for Qt. This example
* program may be used, distributed and modified without limitation.
**
****************************************************************************/
import org.kde.qt.*;
class SecretDrag extends QStoredDrag {
//create the object withe the secret byte
public SecretDrag( byte secret, QWidget parent, String name )
{
super( "secret/magic", parent, name );
byte[] data = { 0 };
data[0]= secret;
setEncodedData( data );
}
public SecretDrag( byte secret, QWidget parent )
{
this(secret, parent, null);
}
public static boolean canDecode( QDragMoveEvent e )
{
return e.provides( "secret/magic" );
}
//decode it into a string
public static boolean decode( QDropEvent e, StringBuffer str )
{
byte[] payload = e.data( "secret/magic" );
if ( payload.length > 0 ) {
e.accept();
String msg = "The secret number is " + payload[0];
str.setLength(0);
str.append(msg);
return true;
}
return false;
}
}
|