You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.7 KiB
83 lines
2.7 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2001 David Faure <faure@kde.org>
|
||
|
|
||
|
This program is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this program; see the file COPYING. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "kmultipledrag.h"
|
||
|
#include "kdebug.h"
|
||
|
|
||
|
#ifndef QT_NO_DRAGANDDROP
|
||
|
|
||
14 years ago
|
KMultipleDrag::KMultipleDrag( TQWidget *dragSource, const char *name )
|
||
|
: TQDragObject( dragSource, name )
|
||
15 years ago
|
{
|
||
|
m_dragObjects.setAutoDelete( true );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KMultipleDrag::addDragObject( TQDragObject *dragObject )
|
||
15 years ago
|
{
|
||
|
//kdDebug() << "KMultipleDrag::addDragObject" << endl;
|
||
|
m_dragObjects.append( dragObject );
|
||
14 years ago
|
// We need to find out how many formats this dragObject supports
|
||
15 years ago
|
int i = 0;
|
||
|
while ( dragObject->format( i ) )
|
||
|
++i;
|
||
|
m_numberFormats.append( i ); // e.g. if it supports two formats, 0 and 1, store 2.
|
||
|
}
|
||
|
|
||
14 years ago
|
TQByteArray KMultipleDrag::tqencodedData( const char *mime ) const
|
||
15 years ago
|
{
|
||
14 years ago
|
//kdDebug() << "KMultipleDrag::tqencodedData " << mime << endl;
|
||
14 years ago
|
// Iterate over the drag objects, and find the format in the right one
|
||
14 years ago
|
TQPtrListIterator<TQDragObject> it( m_dragObjects );
|
||
15 years ago
|
for ( ; it.current(); ++it )
|
||
|
{
|
||
|
for ( int i = 0; it.current()->format( i ); ++i )
|
||
|
{
|
||
|
if ( ::qstrcmp( it.current()->format( i ), mime ) == 0 )
|
||
14 years ago
|
return it.current()->tqencodedData( mime );
|
||
15 years ago
|
}
|
||
|
}
|
||
14 years ago
|
return TQByteArray();
|
||
15 years ago
|
}
|
||
|
|
||
|
const char* KMultipleDrag::format( int i ) const
|
||
|
{
|
||
|
//kdDebug() << "KMultipleDrag::format " << i << endl;
|
||
|
// example: m_numberFormats: 1, 4
|
||
|
// m_dragObjects: storeddrag, textdrag
|
||
|
// i=0 -> storeddrag->format( 0 )
|
||
|
// i=1 -> textdrag->format( 0 )
|
||
|
// i=2 -> textdrag->format( 1 )
|
||
|
// etc.
|
||
14 years ago
|
TQValueList<int>::ConstIterator nit = m_numberFormats.begin();
|
||
|
TQValueList<int>::ConstIterator nend = m_numberFormats.end();
|
||
|
TQPtrListIterator<TQDragObject> it( m_dragObjects );
|
||
15 years ago
|
for ( ; nit != nend && i >= *nit ; ++nit, ++it )
|
||
|
i -= *nit;
|
||
|
if ( it.current() )
|
||
|
return it.current()->format( i );
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void KMultipleDrag::virtual_hook( int, void* )
|
||
|
{ /*BASE::virtual_hook( id, data );*/ }
|
||
|
|
||
|
#include "kmultipledrag.moc"
|
||
|
|
||
|
#endif
|