kmimesourcefactory.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #include <kdebug.h>
00022 #include <kglobal.h>
00023 #include <kiconloader.h>
00024 
00025 #include "kmimesourcefactory.h"
00026 
00027 class KMimeSourceFactoryPrivate
00028 {
00029 public:
00030   inline KMimeSourceFactoryPrivate (KIconLoader* loader)
00031     : kil (loader)
00032   {}
00033   
00034   KIconLoader* kil;
00035 };
00036 
00037 KMimeSourceFactory::KMimeSourceFactory (KIconLoader* loader)
00038   : QMimeSourceFactory (),
00039     d (new KMimeSourceFactoryPrivate (loader))
00040 {
00041 }
00042 
00043 KMimeSourceFactory::~KMimeSourceFactory()
00044 {
00045   delete d;
00046 }
00047 
00048 QString KMimeSourceFactory::makeAbsolute (const QString& absOrRelName, const QString& context) const
00049 {
00050   QString myName;
00051   QString myContext;
00052 
00053   const int pos = absOrRelName.find ('|');
00054   if (pos > -1)
00055     {
00056       myContext = absOrRelName.left (pos);
00057       myName = absOrRelName.right (absOrRelName.length() - myContext.length() - 1);
00058     }
00059 
00060   QString result;
00061 
00062   if (myContext == "desktop")
00063     {
00064       result = d->kil->iconPath (myName, KIcon::Desktop);
00065     }
00066   else if (myContext == "toolbar")
00067     {    
00068       result = d->kil->iconPath (myName, KIcon::Toolbar);
00069     }
00070   else if (myContext == "maintoolbar")
00071     {
00072       result = d->kil->iconPath (myName, KIcon::MainToolbar);
00073     }
00074   else if (myContext == "small")
00075     {
00076       result = d->kil->iconPath (myName, KIcon::Small);
00077     }
00078   else if (myContext == "user")
00079     {     
00080       result = d->kil->iconPath (myName, KIcon::User);
00081     }
00082 
00083   if (result.isEmpty())
00084     result = QMimeSourceFactory::makeAbsolute (absOrRelName, context);
00085   
00086   return result;
00087 }
00088 
00089 void KMimeSourceFactory::virtual_hook( int, void* )
00090 {  }
00091 
 
This file is part of the documentation for kdecore Library Version 3.2.0.