summaryrefslogtreecommitdiffstats
path: root/kio/kfile/kfilemetapreview.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:04:16 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:04:16 -0600
commit5159cd2beb2e87806a5b54e9991b7895285c9d3e (patch)
tree9b70e8be47a390f8f4d56ead812ab0c9dad88709 /kio/kfile/kfilemetapreview.cpp
parentc17cb900dcf52b8bd6dc300d4f103392900ec2b4 (diff)
downloadtdelibs-5159cd2beb2e87806a5b54e9991b7895285c9d3e.tar.gz
tdelibs-5159cd2beb2e87806a5b54e9991b7895285c9d3e.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'kio/kfile/kfilemetapreview.cpp')
-rw-r--r--kio/kfile/kfilemetapreview.cpp196
1 files changed, 0 insertions, 196 deletions
diff --git a/kio/kfile/kfilemetapreview.cpp b/kio/kfile/kfilemetapreview.cpp
deleted file mode 100644
index 155e1194c..000000000
--- a/kio/kfile/kfilemetapreview.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * This file is part of the KDE project.
- * Copyright (C) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
- *
- * You can Freely distribute this program under the GNU Library General Public
- * License. See the file "COPYING" for the exact licensing terms.
- */
-
-#include "kfilemetapreview.h"
-
-#include <tqlayout.h>
-
-#include <kio/previewjob.h>
-#include <klibloader.h>
-#include <kimagefilepreview.h>
-#include <kmimetype.h>
-
-bool KFileMetaPreview::s_tryAudioPreview = true;
-
-KFileMetaPreview::KFileMetaPreview( TQWidget *parent, const char *name )
- : KPreviewWidgetBase( parent, name ),
- haveAudioPreview( false )
-{
- TQHBoxLayout *layout = new TQHBoxLayout( this, 0, 0 );
- m_stack = new TQWidgetStack( this );
- layout->addWidget( m_stack );
-
- // ###
-// m_previewProviders.setAutoDelete( true );
- initPreviewProviders();
-}
-
-KFileMetaPreview::~KFileMetaPreview()
-{
-}
-
-void KFileMetaPreview::initPreviewProviders()
-{
- m_previewProviders.clear();
- // hardcoded so far
-
- // image previews
- KImageFilePreview *imagePreview = new KImageFilePreview( m_stack );
- (void) m_stack->addWidget( imagePreview );
- m_stack->raiseWidget( imagePreview );
- resize( imagePreview->sizeHint() );
-
- TQStringList mimeTypes = imagePreview->supportedMimeTypes();
- TQStringList::ConstIterator it = mimeTypes.begin();
- for ( ; it != mimeTypes.end(); ++it )
- {
-// tqDebug(".... %s", (*it).latin1());
- m_previewProviders.insert( *it, imagePreview );
- }
-}
-
-KPreviewWidgetBase * KFileMetaPreview::previewProviderFor( const TQString& mimeType )
-{
-// tqDebug("### looking for: %s", mimeType.latin1());
- // often the first highlighted item, where we can be sure, there is no plugin
- // (this "folders reflect icons" is a konq-specific thing, right?)
- if ( mimeType == "inode/directory" )
- return 0L;
-
- KPreviewWidgetBase *provider = m_previewProviders.find( mimeType );
- if ( provider )
- return provider;
-
-//tqDebug("#### didn't find anything for: %s", mimeType.latin1());
-
- if ( s_tryAudioPreview &&
- !mimeType.startsWith("text/") && !mimeType.startsWith("image/") )
- {
- if ( !haveAudioPreview )
- {
- KPreviewWidgetBase *audioPreview = createAudioPreview( m_stack );
- if ( audioPreview )
- {
- haveAudioPreview = true;
- (void) m_stack->addWidget( audioPreview );
- TQStringList mimeTypes = audioPreview->supportedMimeTypes();
- TQStringList::ConstIterator it = mimeTypes.begin();
- for ( ; it != mimeTypes.end(); ++it )
- m_previewProviders.insert( *it, audioPreview );
- }
- }
- }
-
- // with the new mimetypes from the audio-preview, try again
- provider = m_previewProviders.find( mimeType );
- if ( provider )
- return provider;
-
- // ### mimetype may be image/* for example, try that
- int index = mimeType.find( '/' );
- if ( index > 0 )
- {
- provider = m_previewProviders.find( mimeType.left( index + 1 ) + "*" );
- if ( provider )
- return provider;
- }
-
- KMimeType::Ptr mimeInfo = KMimeType::mimeType( mimeType );
- if ( mimeInfo )
- {
- // check mime type inheritance
- TQString parentMimeType = mimeInfo->parentMimeType();
- while ( !parentMimeType.isEmpty() )
- {
- provider = m_previewProviders.find( parentMimeType );
- if ( provider )
- return provider;
-
- KMimeType::Ptr parentMimeInfo = KMimeType::mimeType( parentMimeType );
- if ( !parentMimeInfo ) break;
-
- parentMimeType = parentMimeInfo->parentMimeType();
- }
-
- // check X-TDE-Text property
- TQVariant textProperty = mimeInfo->property( "X-TDE-text" );
- if ( textProperty.isValid() && textProperty.type() == TQVariant::Bool )
- {
- if ( textProperty.toBool() )
- {
- provider = m_previewProviders.find( "text/plain" );
- if ( provider )
- return provider;
-
- provider = m_previewProviders.find( "text/*" );
- if ( provider )
- return provider;
- }
- }
- }
-
- return 0L;
-}
-
-void KFileMetaPreview::showPreview(const KURL &url)
-{
- KMimeType::Ptr mt = KMimeType::findByURL( url );
- KPreviewWidgetBase *provider = previewProviderFor( mt->name() );
- if ( provider )
- {
- if ( provider != m_stack->visibleWidget() ) // stop the previous preview
- clearPreview();
-
- m_stack->setEnabled( true );
- m_stack->raiseWidget( provider );
- provider->showPreview( url );
- }
- else
- {
- clearPreview();
- m_stack->setEnabled( false );
- }
-}
-
-void KFileMetaPreview::clearPreview()
-{
- if ( m_stack->visibleWidget() )
- static_cast<KPreviewWidgetBase*>( m_stack->visibleWidget() )->clearPreview();
-}
-
-void KFileMetaPreview::addPreviewProvider( const TQString& mimeType,
- KPreviewWidgetBase *provider )
-{
- m_previewProviders.insert( mimeType, provider );
-}
-
-void KFileMetaPreview::clearPreviewProviders()
-{
- TQDictIterator<KPreviewWidgetBase> it( m_previewProviders );
- for ( ; it.current(); ++it )
- m_stack->removeWidget( it.current() );
-
- m_previewProviders.clear();
-}
-
-// static
-KPreviewWidgetBase * KFileMetaPreview::createAudioPreview( TQWidget *parent )
-{
- KLibFactory *factory = KLibLoader::self()->factory( "kfileaudiopreview" );
- if ( !factory )
- {
- s_tryAudioPreview = false;
- return 0L;
- }
-
- return dynamic_cast<KPreviewWidgetBase*>( factory->create( TQT_TQOBJECT(parent), "kfileaudiopreview" ));
-}
-
-void KFileMetaPreview::virtual_hook( int, void* ) {}
-
-#include "kfilemetapreview.moc"