• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • kde3support
  • kdecore
k3multipledrag.cpp
Go to the documentation of this file.
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 "k3multipledrag.h"
21#include "kdebug.h"
22
23#ifndef QT_NO_DRAGANDDROP
24
25K3MultipleDrag::K3MultipleDrag( QWidget *dragSource, const char *name )
26 : Q3DragObject( dragSource, name )
27{
28 m_dragObjects.setAutoDelete( true );
29}
30
31void K3MultipleDrag::addDragObject( Q3DragObject *dragObject )
32{
33 //kDebug() << "K3MultipleDrag::addDragObject";
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
42QByteArray K3MultipleDrag::encodedData( const char *mime ) const
43{
44 //kDebug() << "K3MultipleDrag::encodedData " << mime;
45 // Iterate over the drag objects, and find the format in the right one
46 Q3PtrListIterator<Q3DragObject> 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 QByteArray();
56}
57
58const char* K3MultipleDrag::format( int i ) const
59{
60 //kDebug() << "K3MultipleDrag::format " << i;
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 QList<int>::ConstIterator nit = m_numberFormats.begin();
68 QList<int>::ConstIterator nend = m_numberFormats.end();
69 Q3PtrListIterator<Q3DragObject> 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
77void K3MultipleDrag::virtual_hook( int, void* )
78{ /*BASE::virtual_hook( id, data );*/ }
79
80#include "k3multipledrag.moc"
81
82#endif
K3MultipleDrag::encodedData
virtual QByteArray encodedData(const char *mime) const
Returns the data of a drag object with that supports the given mime type.
Definition: k3multipledrag.cpp:42
K3MultipleDrag::K3MultipleDrag
K3MultipleDrag(QWidget *dragSource=0, const char *name=0)
Create a new K3MultipleDrag object.
Definition: k3multipledrag.cpp:25
K3MultipleDrag::format
virtual const char * format(int i) const
Returns the i'th supported format, or 0.
Definition: k3multipledrag.cpp:58
K3MultipleDrag::addDragObject
void addDragObject(Q3DragObject *dragObject)
Call this to add each underlying drag object to the multiple drag object.
Definition: k3multipledrag.cpp:31
K3MultipleDrag::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition: k3multipledrag.cpp:77
Q3DragObject
QList
QWidget
k3multipledrag.h
kdebug.h
name
const char * name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal