CVS commit by faure: Let the user choose which format to use when dropping or pasting data. If this doesn't compile: update kdelibs/kio! Note that this reverts the hack for #38688 (crash when dragging the *text* of an icon, after starting a rename operation), which is in fact a Qt bug, which I reported (together with a patch). M +9 -9 konq_iconviewwidget.cc 1.314 M +9 -45 konq_operations.cc 1.162 M +4 -5 konq_operations.h 1.38 --- kdebase/libkonq/konq_iconviewwidget.cc #1.313:1.314 @@ -1232,5 +1232,5 @@ void KonqIconViewWidget::contentsDropEve { KIconView::contentsDropEvent( ev ); - emit dropped(); // What is this for ? (David) + emit dropped(); // What is this for ? (David) KDE4: remove } // Don't do this here, it's too early ! --- kdebase/libkonq/konq_operations.cc #1.161:1.162 @@ -137,5 +137,4 @@ void KonqOperations::doPaste( QWidget * KIO::CopyJob * copyJob = static_cast(job); KIOPasteInfo * pi = new KIOPasteInfo; - pi->destURL = destURL; pi->mousePos = pos; op->setPasteInfo( pi ); @@ -382,50 +381,15 @@ void KonqOperations::doDrop( const KFile else { - QStrList formats; - - for ( int i = 0; ev->format( i ); i++ ) - if ( *( ev->format( i ) ) ) - formats.append( ev->format( i ) ); - if ( formats.count() >= 1 ) - { //kdDebug(1203) << "Pasting to " << dest.url() << endl; - - QByteArray data; - - QString text; - if ( QTextDrag::canDecode( ev ) && QTextDrag::decode( ev, text ) ) - { - QTextStream txtStream( data, IO_WriteOnly ); - txtStream << text; - } - else - data = ev->data( formats.first() ); - - // Delay the call to KIO::pasteData so that the event filters can return. See #38688. KonqOperations * op = new KonqOperations(parent); - KIOPasteInfo * pi = new KIOPasteInfo; - pi->data = data; - pi->destURL = dest; - pi->mousePos = ev->pos(); - pi->dialogText = i18n( "File name for dropped contents:" ); - op->setPasteInfo( pi ); - QTimer::singleShot( 0, op, SLOT( slotKIOPaste() ) ); - } - ev->acceptAction(); - } -} - -void KonqOperations::slotKIOPaste() -{ - assert(m_pasteInfo); // setPasteInfo should have been called before - KIO::CopyJob *job = KIO::pasteDataAsync( m_pasteInfo->destURL, m_pasteInfo->data, m_pasteInfo->dialogText ); - if ( job ) + KIO::CopyJob* job = KIO::pasteMimeSource( ev, dest, + i18n( "File name for dropped contents:" ), + parent ); + if ( job ) // 0 if canceled by user { - setOperation( job, COPY, KURL::List(), job->destURL() ); - (void) new KonqCommandRecorder( KonqCommand::COPY, KURL::List(), m_destURL, job ); + op->setOperation( job, COPY, KURL::List(), job->destURL() ); + (void) new KonqCommandRecorder( KonqCommand::COPY, KURL::List(), dest, job ); } - else - { - delete this; + ev->acceptAction(); } } --- kdebase/libkonq/konq_operations.h #1.37:1.38 @@ -144,10 +144,10 @@ protected: void setDropInfo( DropInfo * info ) { m_info = info; } - struct KIOPasteInfo + struct KIOPasteInfo // KDE4: remove and use DropInfo instead or a QPoint member { - QByteArray data; - KURL destURL; + QByteArray data; // unused + KURL destURL; // unused QPoint mousePos; - QString dialogText; + QString dialogText; // unused }; void setPasteInfo( KIOPasteInfo * info ) { m_pasteInfo = info; } @@ -159,5 +159,4 @@ protected slots: void slotStatResult( KIO::Job * job ); void asyncDrop( const KFileItem * item ); - void slotKIOPaste(); void doFileCopy();