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

KDE3Support

k3mimesourcefactory.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE libraries
00003     Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "k3mimesourcefactory.h"
00022 
00023 #include <kdebug.h>
00024 #include <kiconloader.h>
00025 
00026 class K3MimeSourceFactoryPrivate
00027 {
00028 public:
00029   inline K3MimeSourceFactoryPrivate (KIconLoader* loader)
00030     : kil (loader)
00031   {}
00032 
00033   KIconLoader* kil;
00034 };
00035 
00036 void K3MimeSourceFactory::install()
00037 {
00038     // Set default mime-source factory
00039     // XXX: This is a hack. Make our factory the default factory, but add the
00040     // previous default factory to the list of factories. Why? When the default
00041     // factory can't resolve something, it iterates in the list of factories.
00042     // But it QWhatsThis only uses the default factory. So if there was already
00043     // a default factory (which happens when using an image library using uic),
00044     // we prefer KDE's factory and so we put that old default factory in the
00045     // list and use KDE as the default. This may speed up things as well.
00046     Q3MimeSourceFactory* oldDefaultFactory = Q3MimeSourceFactory::takeDefaultFactory();
00047     K3MimeSourceFactory* mimeSourceFactory = new K3MimeSourceFactory(KIconLoader::global());
00048     Q3MimeSourceFactory::setDefaultFactory( mimeSourceFactory );
00049     if ( oldDefaultFactory ) {
00050         Q3MimeSourceFactory::addFactory( oldDefaultFactory );
00051     }
00052 }
00053 
00054 K3MimeSourceFactory::K3MimeSourceFactory (KIconLoader* loader)
00055   : Q3MimeSourceFactory (),
00056     d (new K3MimeSourceFactoryPrivate (loader ? loader : KIconLoader::global()))
00057 {
00058 }
00059 
00060 K3MimeSourceFactory::~K3MimeSourceFactory()
00061 {
00062   delete d;
00063 }
00064 
00065 QString K3MimeSourceFactory::makeAbsolute (const QString& absOrRelName, const QString& context) const
00066 {
00067   QString myName;
00068   QString myContext;
00069 
00070   const int pos = absOrRelName.indexOf ('|');
00071   if (pos > -1)
00072     {
00073       myContext = absOrRelName.left (pos);
00074       myName = absOrRelName.right (absOrRelName.length() - myContext.length() - 1);
00075     }
00076 
00077   QString result;
00078 
00079   if (myContext == "desktop")
00080     {
00081       result = d->kil->iconPath (myName, KIconLoader::Desktop);
00082     }
00083   else if (myContext == "toolbar")
00084     {
00085       result = d->kil->iconPath (myName, KIconLoader::Toolbar);
00086     }
00087   else if (myContext == "maintoolbar")
00088     {
00089       result = d->kil->iconPath (myName, KIconLoader::MainToolbar);
00090     }
00091   else if (myContext == "small")
00092     {
00093       result = d->kil->iconPath (myName, KIconLoader::Small);
00094     }
00095   else if (myContext == "user")
00096     {
00097       result = d->kil->iconPath (myName, KIconLoader::User);
00098     }
00099 
00100   if (result.isEmpty())
00101     result = Q3MimeSourceFactory::makeAbsolute (absOrRelName, context);
00102 
00103   return result;
00104 }
00105 
00106 void K3MimeSourceFactory::virtual_hook( int, void* )
00107 { /*BASE::virtual_hook( id, data );*/ }
00108 

KDE3Support

Skip menu "KDE3Support"
  • 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