Source Code (Use browser search to find items of interest.)
Class Index
qt'QTextDrag (./qt-2.1.0/src/kernel/qdragobject.h:85)
class Q_EXPORT QTextDrag: public QDragObject {
Q_OBJECT
QTextDragPrivate* d;
public:
QTextDrag( const QString &,
QWidget * dragSource = 0, const char * name = 0 );
QTextDrag( QWidget * dragSource = 0, const char * name = 0 );
~QTextDrag();
virtual void setText( const QString &);
virtual void setSubtype( const QCString &);
const char * format(int i) const;
virtual QByteArray encodedData(const char*) const;
static bool canDecode( const QMimeSource* e );
static bool decode( const QMimeSource* e, QString& s );
static bool decode( const QMimeSource* e, QString& s, QCString& subtype );
};
qt'QTextDrag::setSubtype() (./qt-2.1.0/src/kernel/qdragobject.cpp:522)
void QTextDrag::setSubtype( const QCString & st)
{
d->setSubType(st);
}
/*! \class QTextDrag qdragobject.h
\brief The QTextDrag provides a drag-and-drop object for
transferring plain and Unicode text.
\ingroup draganddrop
Plain text is single- or multi-line 8-bit text in the local encoding.
Qt provides no built-in mechanism for delivering only single-line.
Drag&Drop text does \e not have a NUL terminator when it
is dropped onto the target.
For detailed information about drag-and-drop, see the QDragObject class.
*/
/*! Constructs a text drag object and sets it to \a text. \a dragSource
must be the drag source, \a name is the object name. */
qt'QTextDrag::QTextDrag() (./qt-2.1.0/src/kernel/qdragobject.cpp:548)
QTextDrag::QTextDrag( const QString &text,
QWidget * dragSource, const char * name )
: QDragObject( dragSource, name )
{
d = new QTextDragPrivate;
setText( text );
}
/*! Constructs a default text drag object. \a dragSource must be the drag
source, \a name is the object name.
*/
qt'QTextDrag::QTextDrag() (./qt-2.1.0/src/kernel/qdragobject.cpp:561)
QTextDrag::QTextDrag( QWidget * dragSource, const char * name )
: QDragObject( dragSource, name )
{
d = new QTextDragPrivate;
}
/*! Destroys the text drag object and frees all allocated resources.
*/
qt'QTextDrag::~QTextDrag() (./qt-2.1.0/src/kernel/qdragobject.cpp:570)
QTextDrag::~QTextDrag()
{
delete d;
}
/*!
Sets the text to be dragged. You will need to call this if you did
not pass the text during construction.
*/
qt'QTextDrag::setText() (./qt-2.1.0/src/kernel/qdragobject.cpp:580)
void QTextDrag::setText( const QString &text )
{
d->txt = text;
}
/*!
\reimp
*/
qt'QTextDrag::format() (./qt-2.1.0/src/kernel/qdragobject.cpp:589)
const char * QTextDrag::format(int i) const
{
if ( i >= d->nfmt )
return 0;
return d->fmt[i];
}
static
qt'QTextDrag::encodedData() (./qt-2.1.0/src/kernel/qdragobject.cpp:629)
QByteArray QTextDrag::encodedData(const char* mime) const
{
QCString r;
if ( 0==strnicmp(mime,"text/",5) ) {
QCString m(mime);
m = m.lower();
QTextCodec *codec = findcharset(m);
if ( !codec )
return r;
r = codec->fromUnicode(d->txt);
if (!codec || codec->mibEnum() != 1000) {
// Don't include NUL in size (QCString::resize() adds NUL)
((QByteArray&)r).resize(r.length());
}
}
return r;
}
/*!
Returns TRUE if the information in \a e can be decoded into a QString.
\sa decode()
*/
qt'QTextDrag::canDecode() (./qt-2.1.0/src/kernel/qdragobject.cpp:651)
bool QTextDrag::canDecode( const QMimeSource* e )
{
const char* f;
for (int i=0; (f=e->format(i)); i++) {
if ( 0==strnicmp(f,"text/",5) ) {
return findcodec(e) != 0;
}
}
return 0;
}
/*!
Attempts to decode the dropped information in \a e
into \a str, returning TRUE if successful. If \a subtype is null,
any text subtype is accepted, otherwise only that specified is
accepted. \a subtype is set to the accepted subtype.
\sa canDecode()
*/
qt'QTextDrag::decode() (./qt-2.1.0/src/kernel/qdragobject.cpp:670)
bool QTextDrag::decode( const QMimeSource* e, QString& str, QCString& subtype )
{
const char* mime;
for (int i=0; (mime = e->format(i)); i++) {
if ( 0==strnicmp(mime,"text/",5) ) {
QCString m(mime);
m = m.lower();
int semi = m.find(';');
if ( semi < 0 )
semi = m.length();
QCString foundst = m.mid(5,semi-5);
if ( subtype.isNull() || foundst == subtype ) {
QTextCodec* codec = findcharset(m);
if ( codec ) {
QByteArray payload;
payload = e->encodedData(mime);
if ( payload.size() ) {
int l;
if ( codec->mibEnum() != 1000) {
// length is at NUL or payload.size()
l = 0;
while ( l < (int)payload.size() && payload[l] )
l++;
} else {
l = payload.size();
}
str = codec->toUnicode(payload,l);
if ( subtype.isNull() )
subtype = foundst;
return TRUE;
}
}
}
}
}
return FALSE;
}
/*!
Attempts to decode the dropped information in \a e
into \a str, returning TRUE if successful.
\sa canDecode()
*/
qt'QTextDrag::decode() (./qt-2.1.0/src/kernel/qdragobject.cpp:718)
bool QTextDrag::decode( const QMimeSource* e, QString& str )
{
QCString st;
return decode(e,str,st);
}
/*
QImageDrag could use an internal MIME type for communicating QPixmaps
and QImages rather than always converting to raw data. This is available
for that purpose and others. It is not currently used.
*/