Ejemplo n.º 1
0
/*!
  Sets the text to be dragged.  You will need to call this if you did
  not pass the text during construction.
*/
void QTextDrag::setText( const char * text )
{
    int l = qstrlen(text);
    QByteArray tmp(l);
    memcpy(tmp.data(),text,l);
    setEncodedData( tmp );
}
Ejemplo n.º 2
0
//create the object withe the secret byte
SecretDrag::SecretDrag( uchar secret, QWidget * parent, const char * name )
    : QStoredDrag( "secret/magic", parent, name )
{
    QByteArray data(1);
    data[0]= secret;
    setEncodedData( data );
}
void KstPlotDrag::setPlots(const KstViewObjectList& l) {
  QByteArray a;
  QDataStream ds(a, IO_WriteOnly);
  ds << l.count();
  for (KstViewObjectList::ConstIterator i = l.begin(); i != l.end(); ++i) {
    ds << *i;
  }
  setEncodedData(a);
}
Ejemplo n.º 4
0
PopupMenuEditorItemPtrDrag::PopupMenuEditorItemPtrDrag( PopupMenuEditorItem * item,
							QWidget * parent, const char * name )
    : QStoredDrag( "qt/popupmenueditoritemptr", parent, name )
{
    QByteArray data( sizeof( Q_LONG ) );
    QDataStream stream( data, IO_WriteOnly );
    stream << ( Q_LONG ) item;
    setEncodedData( data );
}
Ejemplo n.º 5
0
ContactDragObject::ContactDragObject(ListView *dragSource, Contact *contact)
        : QStoredDrag(CONTACT_MIME, dragSource)
{
    QByteArray data;
    m_id = contact->id();
    data.resize(sizeof(m_id));
    memcpy(data.data(), &m_id, sizeof(m_id));
    setEncodedData(data);
}
Ejemplo n.º 6
0
ButtonDrag::ButtonDrag( Button btn, QWidget* parent, const char* name)
	: QStoredDrag( BUTTONDRAGMIMETYPE, parent, name)
{
	QByteArray data;
	QDataStream stream(data, IO_WriteOnly);
	stream << btn.name;
	stream << btn.icon;
	stream << btn.type.unicode();
	stream << (int) btn.duplicate;
	stream << (int) btn.supported;
	setEncodedData( data );
}
Ejemplo n.º 7
0
void QColorDrag::setColor( const QColor &col )
{
    QByteArray data;
    ushort rgba[ 4 ];
    data.resize( sizeof( rgba ) );
    rgba[ 0 ] = col.red()  * 0xFF;
    rgba[ 1 ] = col.green() * 0xFF;
    rgba[ 2 ] = col.blue()  * 0xFF;
    rgba[ 3 ] = 0xFFFF; // Alpha not supported yet.
    memcpy( data.data(), rgba, sizeof( rgba) );
    setEncodedData( data );
}
Ejemplo n.º 8
0
UmlDrag::UmlDrag(BrowserNode * bn, QWidget * parent, const char * name)
    : QStoredDrag(UmlDrag::Key + bn->drag_key(), parent, name) {
  // stay in the same application : can use address directly
  QByteArray a(sizeof(bn));
  
  memcpy(a.data(), &bn, sizeof(bn));
  setEncodedData(a);
  
  postfix = bn->drag_postfix();
  ro = ((bn->parent() != 0) &&
	!((BrowserNode *) bn->parent())->is_writable());
}
Ejemplo n.º 9
0
/*!
  Changes the list of \a urls to be dragged.
*/
void QUrlDrag::setUrls( QStrList urls )
{
    QByteArray a;
    int c=0;
    for (const char* s = urls.first(); s; s = urls.next() ) {
	int l = strlen(s)+1;
	a.resize(c+l);
	memcpy(a.data()+c,s,l);
	c+=l;
    }
    a.resize(c-1); // chop off last nul
    setEncodedData(a);
}
Ejemplo n.º 10
0
/*!
  Changes the list of \a uris to be dragged.
*/
void QUriDrag::setUris( QStrList uris )
{
    QByteArray a;
    int c=0;
    for ( const char* s = uris.first(); s; s = uris.next() ) {
	int l = qstrlen(s);
	a.resize(c+l+2);
	memcpy(a.data()+c,s,l);
	memcpy(a.data()+c+l,"\r\n",2);
	c+=l+2;
    }
    setEncodedData(a);
}
Ejemplo n.º 11
0
void
K3ColorDrag::setColor( const QColor &color)
{
     Q3ColorDrag tmp(color, 0, 0);
     setEncodedData(tmp.encodedData(color_mime_string));

     QPixmap colorpix( 25, 20);
     colorpix.fill( color);
     QPainter p( &colorpix );
     p.setPen( Qt::black );
     p.drawRect(0,0,25,20);
     p.end();
     setPixmap(colorpix, QPoint(-5,-7));
}
Ejemplo n.º 12
0
ListBoxItemDrag::ListBoxItemDrag( ListBoxItemList & items, bool sendPtr, QListBox * parent, const char * name )
    : QStoredDrag( "qt/listboxitem", parent, name )
{
    // ### FIX!
    QByteArray data( sizeof( Q_INT32 ) + sizeof( QListBoxItem ) * items.count() );
    QDataStream stream( data, IO_WriteOnly );

    stream << items.count();
    stream << (Q_UINT8) sendPtr; // just transfer item pointer; omit data

    QListBoxItem * i = items.first();

    if ( sendPtr ) {
	
	while ( i ) {
	    
	    stream << (unsigned long) i; //###FIX: demands sizeof(ulong) >= sizeof(void*)
	    i = items.next();
	    
	}
	
    } else {
  
	while ( i ) {
	
	    Q_UINT8 b = 0;

	    b = (Q_UINT8) ( i->text() != QString::null ); // does item have text ?
	    stream << b;
	    if ( b ) {
		stream << i->text();
	    }
    
	    b = (Q_UINT8) ( !!i->pixmap() ); // does item have a pixmap ?
	    stream << b;
	    if ( b ) {
		stream << ( *i->pixmap() );
	    }

	    stream << (Q_UINT8) i->isSelectable();
	    
	    i = items.next();
	}
    
    }

    setEncodedData( data );
}
Ejemplo n.º 13
0
ListViewItemDrag::ListViewItemDrag( ListViewItemList & items, QWidget * parent, const char * name )
    : QStoredDrag( "qt/listviewitem", parent, name )
{
    // ### FIX!
    QByteArray data( sizeof( Q_INT32 ) + sizeof( QListViewItem ) * items.count() );
    QDataStream stream( data, IO_WriteOnly );

    stream << items.count();

    QListViewItem *i = items.first();
    while ( i ) {
        stream << *i;
	i = items.next();
    }

    setEncodedData( data );
}