summaryrefslogtreecommitdiffstats
path: root/buildtools/autotools/tdefilednddetailview.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:06:29 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:06:29 -0600
commitc0b24fe164924298d7e6ae33964b3c65fadbcba3 (patch)
tree2ba50375d78b077b266b224e4413150ef3e60a15 /buildtools/autotools/tdefilednddetailview.cpp
parent33d15e862e09fbcbb05e209f832414bd8a01291e (diff)
downloadtdevelop-c0b24fe164924298d7e6ae33964b3c65fadbcba3.tar.gz
tdevelop-c0b24fe164924298d7e6ae33964b3c65fadbcba3.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'buildtools/autotools/tdefilednddetailview.cpp')
-rw-r--r--buildtools/autotools/tdefilednddetailview.cpp212
1 files changed, 212 insertions, 0 deletions
diff --git a/buildtools/autotools/tdefilednddetailview.cpp b/buildtools/autotools/tdefilednddetailview.cpp
new file mode 100644
index 00000000..74492577
--- /dev/null
+++ b/buildtools/autotools/tdefilednddetailview.cpp
@@ -0,0 +1,212 @@
+/***************************************************************************
+* tdefilednddetailview.cpp - description
+* -------------------
+* begin : Wed Nov 1 2000
+* copyright : (C) 2000 by Bj�n Sahlstr�
+* email : kbjorn@users.sourceforge.net
+***************************************************************************/
+
+/***************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+***************************************************************************/
+
+//////////////////////////////////////////////////////
+// TQt specific includes
+#include <tqptrlist.h>
+#include <tqapplication.h>
+//////////////////////////////////////////////////////
+// KDE specific includes
+#include <tdefileitem.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+//////////////////////////////////////////////////////
+// Application specific includes
+#include "tdefilednddetailview.h"
+
+#ifndef AUTO_OPEN_TIME
+#define AUTO_OPEN_TIME
+ static int autoOpenTime = 750;
+#endif
+//-----------------------------------------------
+KFileDnDDetailView::KFileDnDDetailView(TQWidget *parent, const char *name )
+ : KFileDetailView(parent,name), m_autoOpenTimer( this ),
+ m_autoOpenTime( autoOpenTime ), m_useAutoOpenTimer( true ),
+ m_dropItem(0), m_dndEnabled( true )
+{
+ setAutoUpdate( true );
+ setDnDEnabled( true );
+ useAutoOpenTimer( true );
+}
+//-----------------------------------------------
+KFileDnDDetailView::~KFileDnDDetailView(){
+}
+//-----------------------------------------------
+void KFileDnDDetailView::readConfig( TDEConfig* config, const TQString& group ) {
+ TDEConfigGroupSaver cs( config, group );
+ bool dnd = config->readBoolEntry("DragAndDrop", true );
+ setDnDEnabled( dnd );
+ KFileDetailView::readConfig( config, group );
+}
+//-----------------------------------------------
+void KFileDnDDetailView::writeConfig( TDEConfig* config, const TQString& group ) {
+ TDEConfigGroupSaver cs( config, group );
+ config->writeEntry("DragAndDrop", m_dndEnabled );
+ KFileDetailView::writeConfig( config, group );
+}
+//-----------------------------------------------
+void KFileDnDDetailView::slotOpenFolder(){
+ if( m_useAutoOpenTimer ) {
+ m_autoOpenTimer.stop();
+ if( !m_dropItem )
+ return;
+ }
+ KFileItemListIterator it( * KFileView::items() );
+ for( ; it.current() ;++it ){
+ if( (*it)->name() == m_dropItem->text(0) ) {
+ if( (*it)->isFile() )
+ return;
+ else if( (*it)->isDir() || (*it)->isLink()) {
+ sig->activate( (*it) );
+ return;
+ }
+ }
+ }
+}
+//-----------------------------------------------
+void KFileDnDDetailView::contentsDragEnterEvent( TQDragEnterEvent *e ) {
+
+ kdDebug (9020) << "KFileDnDDetailView::contentsDragEnterEvent" << endl;
+
+ if ( ! acceptDrag( e ) ) {
+ e->accept( false );
+ return;
+ }
+ e->acceptAction();
+ TQListViewItem *i = itemAt( contentsToViewport( e->pos() ) );
+ if ( i && m_useAutoOpenTimer ) {
+ m_dropItem = i;
+ m_autoOpenTimer.start( m_autoOpenTime );
+ }
+}
+//-----------------------------------------------
+void KFileDnDDetailView::contentsDragMoveEvent( TQDragMoveEvent *e ) {
+
+ kdDebug (9020) << "KFileDnDDetailView::contentsDragMoveEvent" << endl;
+
+ if ( ! acceptDrag( e ) ) {
+ e->accept( false );
+ return;
+ }
+ e->acceptAction();
+ TQListViewItem *i = itemAt( contentsToViewport( e->pos() ) );
+ if( ! m_useAutoOpenTimer )
+ return;
+ if ( i ) {
+ if ( i != m_dropItem ) {
+ m_autoOpenTimer.stop();
+ m_dropItem = i;
+ m_autoOpenTimer.start( m_autoOpenTime );
+ }
+ }
+ else
+ m_autoOpenTimer.stop();
+}
+//-----------------------------------------------
+void KFileDnDDetailView::contentsDragLeaveEvent( TQDragLeaveEvent* ) {
+
+ kdDebug (9020) << "KFileDnDDetailView::contentsDragLeaveEvent" << endl;
+
+ if( m_useAutoOpenTimer ) {
+ m_autoOpenTimer.stop();
+ m_dropItem = 0L;
+ }
+}
+//-----------------------------------------------
+void KFileDnDDetailView::contentsDropEvent( TQDropEvent* e ) {
+
+ kdDebug (9020) << "KFileDndDetailView::contentsDropEvent" << endl;
+
+ if( m_useAutoOpenTimer ) {
+ m_autoOpenTimer.stop();
+ m_dropItem = 0L;
+ }
+ if( ! acceptDrag( e ) ) {
+ e->acceptAction( false );
+ return;
+ }
+ e->acceptAction();
+ // the drop was accepted so lets emit this to the outside world
+ KURL::List urls;
+ KURLDrag::decode( e, urls );
+ emit dropped( e );
+ emit dropped( this, e );
+ emit dropped( this, urls );
+}
+//-----------------------------------------------
+void KFileDnDDetailView::startDrag(){
+
+ kdDebug (9020) << "KFileDnDDetailView::startDrag()" << endl;
+
+ // create a list of the URL:s that we want to drag
+ KURL::List urls;
+ KFileItemListIterator it( * KFileView::selectedItems() );
+ for ( ; it.current(); ++it ){
+ urls.append( (*it)->url() );
+ }
+ TQPixmap pixmap;
+ if( urls.count() > 1 ){
+ pixmap = DesktopIcon( "tdemultiple", 16 );
+ }
+ if( pixmap.isNull() )
+ pixmap = currentFileItem()->pixmap( 16 );
+ TQPoint hotspot;
+ hotspot.setX( pixmap.width() / 2 );
+ hotspot.setY( pixmap.height() / 2 );
+ m_dragObject = KURLDrag::newDrag( urls, widget() );
+ m_dragObject->setPixmap( pixmap, hotspot );
+ m_dragObject->drag(); // start the drag
+}
+//-----------------------------------------------
+TQDragObject* KFileDnDDetailView::dragObject() const {
+ return m_dragObject;
+}
+//-----------------------------------------------
+bool KFileDnDDetailView::acceptDrag(TQDropEvent* e ) const {
+ return KURLDrag::canDecode( e ) &&
+ ( e->action() == TQDropEvent::Copy
+ || e->action() == TQDropEvent::Move
+ || e->action() == TQDropEvent::Link );
+}
+//-----------------------------------------------
+void KFileDnDDetailView::setAutoOpenTime( const int& time ){
+ m_autoOpenTime = time;
+ useAutoOpenTimer();
+}
+//-----------------------------------------------
+void KFileDnDDetailView::useAutoOpenTimer( bool use ){
+ m_useAutoOpenTimer = use;
+ if( use )
+ connect( &m_autoOpenTimer, TQT_SIGNAL( timeout() ),this, TQT_SLOT( slotOpenFolder() ) );
+ else {
+ disconnect( &m_autoOpenTimer, TQT_SIGNAL( timeout() ),this, TQT_SLOT( slotOpenFolder() ) );
+ m_dropItem = 0L;
+ m_autoOpenTimer.stop();
+ }
+}
+//-----------------------------------------------
+void KFileDnDDetailView::setDnDEnabled( bool useDnD ){
+ m_dndEnabled = useDnD;
+ setDragEnabled( useDnD );
+ setDropVisualizer( useDnD );
+ setAcceptDrops( useDnD );
+ viewport()->setAcceptDrops( useDnD );
+}
+//-----------------------------------------------
+#ifndef NO_INCLUDE_MOCFILES
+#include "tdefilednddetailview.moc"
+#endif