kdgantt

KDGanttViewItemDrag.cpp

00001 
00002 
00003 /****************************************************************************
00004  ** Copyright (C)  2002-2004 Klarälvdalens Datakonsult AB.  All rights reserved.
00005  **
00006  ** This file is part of the KDGantt library.
00007  **
00008  ** This file may be distributed and/or modified under the terms of the
00009  ** GNU General Public License version 2 as published by the Free Software
00010  ** Foundation and appearing in the file LICENSE.GPL included in the
00011  ** packaging of this file.
00012  **
00013  ** Licensees holding valid commercial KDGantt licenses may use this file in
00014  ** accordance with the KDGantt Commercial License Agreement provided with
00015  ** the Software.
00016  **
00017  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00018  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00019  **
00020  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
00021  **   information about KDGantt Commercial License Agreements.
00022  **
00023  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
00024  ** licensing are not clear to you.
00025  **
00026  ** As a special exception, permission is given to link this program
00027  ** with any edition of Qt, and distribute the resulting executable,
00028  ** without including the source code for Qt in the source distribution.
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 
KDE Home | KDE Accessibility Home | Description of Access Keys