• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
tdemultipledrag.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2001 David Faure <faure@kde.org>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this program; see the file COPYING. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "tdemultipledrag.h"
21 #include "kdebug.h"
22 
23 #ifndef QT_NO_DRAGANDDROP
24 
25 KMultipleDrag::KMultipleDrag( TQWidget *dragSource, const char *name )
26  : TQDragObject( dragSource, name )
27 {
28  m_dragObjects.setAutoDelete( true );
29 }
30 
31 void KMultipleDrag::addDragObject( TQDragObject *dragObject )
32 {
33  //kdDebug() << "KMultipleDrag::addDragObject" << endl;
34  m_dragObjects.append( dragObject );
35  // We need to find out how many formats this dragObject supports
36  int i = 0;
37  while ( dragObject->format( i ) )
38  ++i;
39  m_numberFormats.append( i ); // e.g. if it supports two formats, 0 and 1, store 2.
40 }
41 
42 TQByteArray KMultipleDrag::encodedData( const char *mime ) const
43 {
44  //kdDebug() << "KMultipleDrag::encodedData " << mime << endl;
45  // Iterate over the drag objects, and find the format in the right one
46  TQPtrListIterator<TQDragObject> it( m_dragObjects );
47  for ( ; it.current(); ++it )
48  {
49  for ( int i = 0; it.current()->format( i ); ++i )
50  {
51  if ( ::qstrcmp( it.current()->format( i ), mime ) == 0 )
52  return it.current()->encodedData( mime );
53  }
54  }
55  return TQByteArray();
56 }
57 
58 const char* KMultipleDrag::format( int i ) const
59 {
60  //kdDebug() << "KMultipleDrag::format " << i << endl;
61  // example: m_numberFormats: 1, 4
62  // m_dragObjects: storeddrag, textdrag
63  // i=0 -> storeddrag->format( 0 )
64  // i=1 -> textdrag->format( 0 )
65  // i=2 -> textdrag->format( 1 )
66  // etc.
67  TQValueList<int>::ConstIterator nit = m_numberFormats.begin();
68  TQValueList<int>::ConstIterator nend = m_numberFormats.end();
69  TQPtrListIterator<TQDragObject> it( m_dragObjects );
70  for ( ; nit != nend && i >= *nit ; ++nit, ++it )
71  i -= *nit;
72  if ( it.current() )
73  return it.current()->format( i );
74  return 0;
75 }
76 
77 void KMultipleDrag::virtual_hook( int, void* )
78 { /*BASE::virtual_hook( id, data );*/ }
79 
80 #include "tdemultipledrag.moc"
81 
82 #endif
KMultipleDrag::KMultipleDrag
KMultipleDrag(TQWidget *dragSource=0, const char *name=0)
Create a new KMultipleDrag object.
Definition: tdemultipledrag.cpp:25
KMultipleDrag::encodedData
virtual TQByteArray encodedData(const char *mime) const
Returns the data of a drag object with that supports the given mime type.
Definition: tdemultipledrag.cpp:42
KMultipleDrag::addDragObject
void addDragObject(TQDragObject *dragObject)
Call this to add each underlying drag object to the multiple drag object.
Definition: tdemultipledrag.cpp:31
KMultipleDrag::format
virtual const char * format(int i) const
Returns the i'th supported format, or 0.
Definition: tdemultipledrag.cpp:58

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.