kmimesourcefactory.cpp
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 <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 { /*BASE::virtual_hook( id, data );*/ } 00091