kdgantt
KDGanttViewItemDrag.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <KDGanttViewItemDrag.h>
00034 #include <KDGanttViewItem.h>
00035 #include <qpixmap.h>
00036 #include <KDGanttView.h>
00037
00057 KDGanttViewItemDrag::KDGanttViewItemDrag( KDGanttViewItem* item , QWidget *source, const char * name ) : QStoredDrag("x-application/x-KDGanttViewItemDrag", source, name )
00058 {
00059 myItem = item;
00060
00061 QPixmap pix;
00062 if (item->pixmap() )
00063 pix = *(item->pixmap()) ;
00064 else {
00065 KDGanttViewItem::Shape start, middle, end;
00066 item->shapes( start, middle, end );
00067 QColor st, mi, en;
00068 item->colors( st, mi, en );
00069 pix =item->myGanttView->getPixmap( start, st, item->myGanttView->lvBackgroundColor(), 11 );
00070 }
00071 setPixmap( pix , QPoint( -10,-10 ));
00072 QDomDocument doc( "GanttView" );
00073 QString docstart = "<GanttView/>";
00074 doc.setContent( docstart );
00075 QDomElement itemsElement = doc.createElement( "Items" );
00076 doc.documentElement().appendChild( itemsElement );
00077 item->createNode( doc, itemsElement );
00078 QDataStream s( array, IO_WriteOnly );
00079 s << doc.toString();
00080 }
00081
00082
00089 QByteArray KDGanttViewItemDrag::encodedData( const char * c) const
00090 {
00091 QString s ( c );
00092 if ( s == "x-application/x-KDGanttViewItemDrag" ) {
00093 return array;
00094 }
00095 return QByteArray();
00096 }
00097
00103 KDGanttViewItem* KDGanttViewItemDrag::getItem()
00104 {
00105 return myItem;
00106 }
00107
00108
00115 bool KDGanttViewItemDrag::canDecode ( const QMimeSource * e )
00116 {
00117 if ( QString( e->format() ) == "x-application/x-KDGanttViewItemDrag" )
00118 return true;
00119
00120 return false;
00121 }
00122
00123
00132 bool KDGanttViewItemDrag::decode ( const QMimeSource * e , QString & string)
00133 {
00134 QByteArray arr;
00135 arr = e->encodedData( "x-application/x-KDGanttViewItemDrag");
00136 QDataStream s( arr, IO_ReadOnly );
00137 s >> string;
00138 return true;
00139 }
00140
|