kdgantt

KDGanttViewItemDrag.cpp
1 
2 
3 /****************************************************************************
4  ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
5  **
6  ** This file is part of the KDGantt library.
7  **
8  ** This file may be distributed and/or modified under the terms of the
9  ** GNU General Public License version 2 as published by the Free Software
10  ** Foundation and appearing in the file LICENSE.GPL included in the
11  ** packaging of this file.
12  **
13  ** Licensees holding valid commercial KDGantt licenses may use this file in
14  ** accordance with the KDGantt Commercial License Agreement provided with
15  ** the Software.
16  **
17  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  **
20  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
21  ** information about KDGantt Commercial License Agreements.
22  **
23  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
24  ** licensing are not clear to you.
25  **
26  ** As a special exception, permission is given to link this program
27  ** with any edition of TQt, and distribute the resulting executable,
28  ** without including the source code for TQt in the source distribution.
29  **
30  **********************************************************************/
31 
32 
33 #include <KDGanttViewItemDrag.h>
34 #include <KDGanttViewItem.h>
35 #include <tqpixmap.h>
36 #include <KDGanttView.h>
37 
57 KDGanttViewItemDrag::KDGanttViewItemDrag( KDGanttViewItem* item , TQWidget *source, const char * name ) : TQStoredDrag("x-application/x-KDGanttViewItemDrag", source, name )
58 {
59  myItem = item;
60 
61  TQPixmap pix;
62  if (item->pixmap() )
63  pix = *(item->pixmap()) ;
64  else {
65  KDGanttViewItem::Shape start, middle, end;
66  item->shapes( start, middle, end );
67  TQColor st, mi, en;
68  item->colors( st, mi, en );
69  pix =item->myGanttView->getPixmap( start, st, item->myGanttView->lvBackgroundColor(), 11 );
70  }
71  setPixmap( pix , TQPoint( -10,-10 ));
72  TQDomDocument doc( "GanttView" );
73  TQString docstart = "<GanttView/>";
74  doc.setContent( docstart );
75  TQDomElement itemsElement = doc.createElement( "Items" );
76  doc.documentElement().appendChild( itemsElement );
77  item->createNode( doc, itemsElement );
78  TQDataStream s( array, IO_WriteOnly );
79  s << doc.toString();
80 }
81 
82 
89 TQByteArray KDGanttViewItemDrag::encodedData( const char * c) const
90 {
91  TQString s ( c );
92  if ( s == "x-application/x-KDGanttViewItemDrag" ) {
93  return array;
94  }
95  return TQByteArray();
96 }
97 
104 {
105  return myItem;
106 }
107 
108 
115 bool KDGanttViewItemDrag::canDecode ( const TQMimeSource * e )
116 {
117  if ( TQString( e->format() ) == "x-application/x-KDGanttViewItemDrag" )
118  return true;
119 
120  return false;
121 }
122 
123 
132 bool KDGanttViewItemDrag::decode ( const TQMimeSource * e , TQString & string)
133 {
134  TQByteArray arr;
135  arr = e->encodedData( "x-application/x-KDGanttViewItemDrag");
136  TQDataStream s( arr, IO_ReadOnly );
137  s >> string;
138  return true;
139 }
140 
KDGanttViewItemDrag(KDGanttViewItem *item, TQWidget *source, const char *name)
KDGanttViewItem * getItem()
static bool decode(const TQMimeSource *e, TQString &)
static bool canDecode(const TQMimeSource *e)
TQByteArray encodedData(const char *c) const
const TQPixmap * pixmap(int column=0) const
void createNode(TQDomDocument &doc, TQDomElement &parentElement)
KDGanttView * myGanttView
void colors(TQColor &start, TQColor &middle, TQColor &end) const
void shapes(Shape &start, Shape &middle, Shape &end) const
static TQPixmap getPixmap(KDGanttViewItem::Shape shape, const TQColor &shapeColor, const TQColor &backgroundColor, int itemSize)
TQColor lvBackgroundColor() const