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

KDECore

kmimesourcefactory.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 <kdebug.h>
00022 #include <kglobal.h>
00023 #include <kinstance.h>
00024 #include <kiconloader.h>
00025 
00026 #include "kmimesourcefactory.h"
00027 
00028 class KMimeSourceFactoryPrivate
00029 {
00030 public:
00031   inline KMimeSourceFactoryPrivate (KIconLoader* loader) : m_iconLoader(loader), m_instance(0L) {}
00032   inline KIconLoader *iconLoader()
00033   {
00034     // If we don't have either of these, things are looking grim.
00035     Q_ASSERT(m_instance || m_iconLoader);
00036 
00037     if (m_iconLoader)
00038       return m_iconLoader;
00039 
00040     return m_instance->iconLoader();
00041   }
00042 
00043   KIconLoader *m_iconLoader;
00044   KInstance *m_instance;
00045 };
00046 
00047 KMimeSourceFactory::KMimeSourceFactory (KIconLoader* loader)
00048   : QMimeSourceFactory (),
00049     d (new KMimeSourceFactoryPrivate (loader))
00050 {
00051 }
00052 
00053 KMimeSourceFactory::~KMimeSourceFactory()
00054 {
00055   delete d;
00056 }
00057 
00058 QString KMimeSourceFactory::makeAbsolute (const QString& absOrRelName, const QString& context) const
00059 {
00060   QString myName;
00061   QString myContext;
00062 
00063   const int pos = absOrRelName.find ('|');
00064   if (pos > -1)
00065     {
00066       myContext = absOrRelName.left (pos);
00067       myName = absOrRelName.right (absOrRelName.length() - myContext.length() - 1);
00068     }
00069 
00070   QString result;
00071 
00072   if (myContext == "desktop")
00073     {
00074       result = d->iconLoader()->iconPath (myName, KIcon::Desktop);
00075     }
00076   else if (myContext == "toolbar")
00077     {    
00078       result = d->iconLoader()->iconPath (myName, KIcon::Toolbar);
00079     }
00080   else if (myContext == "maintoolbar")
00081     {
00082       result = d->iconLoader()->iconPath (myName, KIcon::MainToolbar);
00083     }
00084   else if (myContext == "small")
00085     {
00086       result = d->iconLoader()->iconPath (myName, KIcon::Small);
00087     }
00088   else if (myContext == "user")
00089     {     
00090       result = d->iconLoader()->iconPath (myName, KIcon::User);
00091     }
00092 
00093   if (result.isEmpty())
00094     result = QMimeSourceFactory::makeAbsolute (absOrRelName, context);
00095   
00096   return result;
00097 }
00098 
00099 void KMimeSourceFactory::setInstance(KInstance *instance)
00100 {
00101   d->m_instance = instance;
00102 }
00103 
00104 void KMimeSourceFactory::virtual_hook( int, void* )
00105 { /*BASE::virtual_hook( id, data );*/ }
00106 

KDECore

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
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