• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

kpreviewprops.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2005 Stephan Binner <binner@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License version 2 as published by the Free Software Foundation.
00007 
00008     This library is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011     Library General Public License for more details.
00012 
00013     You should have received a copy of the GNU Library General Public License
00014     along with this library; see the file COPYING.LIB.  If not, write to
00015     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, USA.
00017 
00018  */
00019 
00020 #include "kpreviewprops.h"
00021 #include <kio/previewjob.h>
00022 
00023 #include <QtGui/QLayout>
00024 
00025 #include <kfilemetapreview.h>
00026 #include <kglobalsettings.h>
00027 #include <klocale.h>
00028 
00029 class KPreviewPropsPlugin::KPreviewPropsPluginPrivate
00030 {
00031 public:
00032     KPreviewPropsPluginPrivate()  {}
00033     ~KPreviewPropsPluginPrivate() {}
00034 };
00035 
00036 KPreviewPropsPlugin::KPreviewPropsPlugin(KPropertiesDialog* props)
00037   : KPropertiesDialogPlugin(props),d(new KPreviewPropsPluginPrivate)
00038 {
00039 
00040     if (properties->items().count()>1)
00041         return;
00042 
00043     createLayout();
00044 }
00045 
00046 void KPreviewPropsPlugin::createLayout()
00047 {
00048     // let the dialog create the page frame
00049     QFrame* topframe = new QFrame();
00050     properties->addPage(topframe, i18n("P&review"));
00051     topframe->setFrameStyle(QFrame::NoFrame);
00052 
00053     QVBoxLayout* tmp = new QVBoxLayout(topframe);
00054     tmp->setMargin(0);
00055     tmp->setSpacing(0);
00056 
00057     preview = new KFileMetaPreview(topframe);
00058 
00059     tmp->addWidget(preview) ;
00060     connect( properties, SIGNAL( currentPageChanged( KPageWidgetItem *, KPageWidgetItem * ) ), SLOT( currentPageChanged( KPageWidgetItem *, KPageWidgetItem * ) ) );
00061 }
00062 
00063 KPreviewPropsPlugin::~KPreviewPropsPlugin()
00064 {
00065     delete d;
00066 }
00067 
00068 bool KPreviewPropsPlugin::supports( const KFileItemList &_items )
00069 {
00070     if ( _items.count() != 1 )
00071         return false;
00072     bool metaDataEnabled = KGlobalSettings::showFilePreview(_items.first().url());
00073     if (!metaDataEnabled)
00074         return false;
00075     const KMimeType::Ptr mime = _items.first().mimeTypePtr();
00076     const QStringList supportedMimeTypes = KIO::PreviewJob::supportedMimeTypes();
00077     foreach(const QString& supportedMime, supportedMimeTypes) {
00078         if (mime->is(supportedMime))
00079     return true;
00080     }
00081     return false;
00082 }
00083 
00084 void KPreviewPropsPlugin::currentPageChanged( KPageWidgetItem *current, KPageWidgetItem * )
00085 {
00086     if ( current->widget() != preview->parent() )
00087         return;
00088 
00089     disconnect( properties, SIGNAL( currentPageChanged( KPageWidgetItem *, KPageWidgetItem * ) ), this, SLOT( currentPageChanged( KPageWidgetItem *, KPageWidgetItem * ) ) );
00090     preview->showPreview(properties->item().url());
00091 }
00092 
00093 #include "kpreviewprops.moc"

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal