• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kdgantt1

KDGanttViewItemDrag.cpp

Go to the documentation of this file.
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 used under the terms of the GNU General Public
00009  ** License versions 2.0 or 3.0 as published by the Free Software
00010  ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
00011  ** included in the packaging of this file.  Alternatively you may (at
00012  ** your option) use any later version of the GNU General Public
00013  ** License if such license has been publicly approved by
00014  ** Klarälvdalens Datakonsult AB (or its successors, if any).
00015  ** 
00016  ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
00017  ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
00018  ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
00019  ** not expressly granted herein.
00020  ** 
00021  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00022  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00023  **
00024  ** As a special exception, permission is given to link this program
00025  ** with any edition of Qt, and distribute the resulting executable,
00026  ** without including the source code for Qt in the source distribution.
00027  **
00028  **********************************************************************/
00029 
00030 #include <KDGanttView.h>
00031 
00032 #include <KDGanttViewItemDrag.h>
00033 #include <KDGanttViewItem.h>
00034 #include <QPixmap>
00035 
00055 #include <QBitmap>
00056 KDGanttViewItemDrag::KDGanttViewItemDrag( KDGanttViewItem* item , QWidget *source,  const char * name  ) : QStoredDrag("x-application/x-KDGanttViewItemDrag", source,  name )
00057 {
00058     myItem = item;
00059 
00060     QPixmap pix;
00061     if (item->pixmap() ) {
00062         pix = QPixmap(*(item->pixmap())) ;
00063     }
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 = QPixmap(item->myGanttView->getPixmap( start, st, item->myGanttView->lvBackgroundColor(), 10 ));
00070     }
00071     int off = -pix.width()/2 -2;
00072 #ifdef Q_WS_WIN
00073     if ( item->pixmap() )
00074 #endif
00075     setPixmap( pix , QPoint( off, off ) );
00076     QDomDocument doc( "GanttView" );
00077     QString docstart = "<GanttView/>";
00078     doc.setContent( docstart );
00079     QDomElement itemsElement = doc.createElement( "Items" );
00080     doc.documentElement().appendChild( itemsElement );
00081     item->createNode( doc, itemsElement );
00082 #if QT_VERSION < 0x040000
00083     QDataStream s( array, IO_WriteOnly );
00084 #else
00085     QDataStream s( &array, IO_WriteOnly );
00086 #endif
00087     s << doc.toString();
00088 }
00089 
00090 
00097 QByteArray KDGanttViewItemDrag::encodedData( const char * c) const
00098 {
00099     QString s ( c );
00100     if ( s == "x-application/x-KDGanttViewItemDrag" ) {
00101         return array;
00102     }
00103     return QByteArray();
00104 }
00105 
00111 KDGanttViewItem* KDGanttViewItemDrag::getItem()
00112 {
00113     return myItem;
00114 }
00115 
00116 
00123 bool KDGanttViewItemDrag::canDecode (  const QMimeSource * e )
00124 {
00125     if ( QString( e->format() ) == "x-application/x-KDGanttViewItemDrag" )
00126         return true;
00127 
00128     return false;
00129 }
00130 
00131 
00140 bool KDGanttViewItemDrag::decode (  const QMimeSource * e , QString &  string)
00141 {
00142     QByteArray arr;
00143     arr = e->encodedData( "x-application/x-KDGanttViewItemDrag");
00144     //qDebug("KDGanttViewItemDrag::decode length %d ", arr.count());
00145     if ( arr.count() ) {
00146 #if QT_VERSION < 0x040000
00147     QDataStream s( arr, IO_ReadOnly );
00148 #else
00149     QDataStream s( &arr, IO_ReadOnly );
00150 #endif
00151         s >> string;
00152     }
00153     return true;
00154 }
00155 

kdgantt1

Skip menu "kdgantt1"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal