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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/****************************************************************************
** Copyright (C) 2002-2004 Klar�lvdalens Datakonsult AB. All rights reserved.
**
** This file is part of the KDGantt library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDGantt licenses may use this file in
** accordance with the KDGantt Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
** information about KDGantt Commercial License Agreements.
**
** Contact [email protected] if any conditions of this
** licensing are not clear to you.
**
** As a special exception, permission is given to link this program
** with any edition of TQt, and distribute the resulting executable,
** without including the source code for TQt in the source distribution.
**
**********************************************************************/
#include <KDGanttViewItemDrag.h>
#include <KDGanttViewItem.h>
#include <tqpixmap.h>
#include <KDGanttView.h>
/*!
\class KDGanttViewItemDrag KDGanttViewItemDrag.h
\brief Drag and drop of KD Gantt items.
This class implements drag and drop of KD Gantt items within a Gantt
chart. It is mainly used for internal purposes, but made a part of
the public API nevertheless, as you may want to subclass it for some
specialized functionality.
*/
/*!
The constructor. Creates a KDGanttViewItemDrag object and
initializes the drag data in the form of an XML document.
\param item the item that is dragged
\param source the source widget
\param name the internal object name
*/
KDGanttViewItemDrag::KDGanttViewItemDrag( KDGanttViewItem* item , TQWidget *source, const char * name ) : TQStoredDrag("x-application/x-KDGanttViewItemDrag", source, name )
{
myItem = item;
TQPixmap pix;
if (item->pixmap() )
pix = *(item->pixmap()) ;
else {
KDGanttViewItem::Shape start, middle, end;
item->shapes( start, middle, end );
TQColor st, mi, en;
item->colors( st, mi, en );
pix =item->myGanttView->getPixmap( start, st, item->myGanttView->lvBackgroundColor(), 11 );
}
setPixmap( pix , TQPoint( -10,-10 ));
TQDomDocument doc( "GanttView" );
TQString docstart = "<GanttView/>";
doc.setContent( docstart );
TQDomElement itemsElement = doc.createElement( "Items" );
doc.documentElement().appendChild( itemsElement );
item->createNode( doc, itemsElement );
TQDataStream s( array, IO_WriteOnly );
s << doc.toString();
}
/*!
Returns the encoded data of the drag object.
\param c the format of the data
\return the encoded data of the drag object
*/
TQByteArray KDGanttViewItemDrag::encodedData( const char * c) const
{
TQString s ( c );
if ( s == "x-application/x-KDGanttViewItemDrag" ) {
return array;
}
return TQByteArray();
}
/*!
Returns the dragged item
\return the dragged item
*/
KDGanttViewItem* KDGanttViewItemDrag::getItem()
{
return myItem;
}
/*!
Returns whether this drag object class can decode the data passed in \a e.
\param e the mime source that has been dragged
\return true if KDGanttViewItemDrag can decode the data in \a e.
*/
bool KDGanttViewItemDrag::canDecode ( const TQMimeSource * e )
{
if ( TQString( e->format() ) == "x-application/x-KDGanttViewItemDrag" )
return true;
return false;
}
/*!
Decodes the data passed in \a e into an XML string that is written
into \a string.
\param e the data to decode
\param string the resulting XML string
\return true if the operation succeeded
*/
bool KDGanttViewItemDrag::decode ( const TQMimeSource * e , TQString & string)
{
TQByteArray arr;
arr = e->encodedData( "x-application/x-KDGanttViewItemDrag");
TQDataStream s( arr, IO_ReadOnly );
s >> string;
return true;
}
|