• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • kde3support
  • kdecore
k3mimesourcefactory.cpp
Go to the documentation of this file.
1/*
2 This file is part of the KDE libraries
3 Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "k3mimesourcefactory.h"
22
23#include <kdebug.h>
24#include <kiconloader.h>
25
26class K3MimeSourceFactoryPrivate
27{
28public:
29 inline K3MimeSourceFactoryPrivate (KIconLoader* loader)
30 : kil (loader)
31 {}
32
33 KIconLoader* kil;
34};
35
36void K3MimeSourceFactory::install()
37{
38 // Set default mime-source factory
39 // XXX: This is a hack. Make our factory the default factory, but add the
40 // previous default factory to the list of factories. Why? When the default
41 // factory can't resolve something, it iterates in the list of factories.
42 // But it QWhatsThis only uses the default factory. So if there was already
43 // a default factory (which happens when using an image library using uic),
44 // we prefer KDE's factory and so we put that old default factory in the
45 // list and use KDE as the default. This may speed up things as well.
46 Q3MimeSourceFactory* oldDefaultFactory = Q3MimeSourceFactory::takeDefaultFactory();
47 K3MimeSourceFactory* mimeSourceFactory = new K3MimeSourceFactory(KIconLoader::global());
48 Q3MimeSourceFactory::setDefaultFactory( mimeSourceFactory );
49 if ( oldDefaultFactory ) {
50 Q3MimeSourceFactory::addFactory( oldDefaultFactory );
51 }
52}
53
54K3MimeSourceFactory::K3MimeSourceFactory (KIconLoader* loader)
55 : Q3MimeSourceFactory (),
56 d (new K3MimeSourceFactoryPrivate (loader ? loader : KIconLoader::global()))
57{
58}
59
60K3MimeSourceFactory::~K3MimeSourceFactory()
61{
62 delete d;
63}
64
65QString K3MimeSourceFactory::makeAbsolute (const QString& absOrRelName, const QString& context) const
66{
67 QString myName;
68 QString myContext;
69
70 const int pos = absOrRelName.indexOf ('|');
71 if (pos > -1)
72 {
73 myContext = absOrRelName.left (pos);
74 myName = absOrRelName.right (absOrRelName.length() - myContext.length() - 1);
75 }
76
77 QString result;
78
79 if (myContext == "desktop")
80 {
81 result = d->kil->iconPath (myName, KIconLoader::Desktop);
82 }
83 else if (myContext == "toolbar")
84 {
85 result = d->kil->iconPath (myName, KIconLoader::Toolbar);
86 }
87 else if (myContext == "maintoolbar")
88 {
89 result = d->kil->iconPath (myName, KIconLoader::MainToolbar);
90 }
91 else if (myContext == "small")
92 {
93 result = d->kil->iconPath (myName, KIconLoader::Small);
94 }
95 else if (myContext == "user")
96 {
97 result = d->kil->iconPath (myName, KIconLoader::User);
98 }
99
100 if (result.isEmpty())
101 result = Q3MimeSourceFactory::makeAbsolute (absOrRelName, context);
102
103 return result;
104}
105
106void K3MimeSourceFactory::virtual_hook( int, void* )
107{ /*BASE::virtual_hook( id, data );*/ }
108
K3MimeSourceFactory
An extension to QMimeSourceFactory that uses KIconLoader to find images.
Definition: k3mimesourcefactory.h:43
K3MimeSourceFactory::~K3MimeSourceFactory
virtual ~K3MimeSourceFactory()
Destructor.
Definition: k3mimesourcefactory.cpp:60
K3MimeSourceFactory::virtual_hook
virtual void virtual_hook(int id, void *data)
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility.
Definition: k3mimesourcefactory.cpp:106
K3MimeSourceFactory::makeAbsolute
virtual QString makeAbsolute(const QString &abs_or_rel_name, const QString &context) const
This function is maps an absolute or relative name for a resource to the absolute one.
Definition: k3mimesourcefactory.cpp:65
K3MimeSourceFactory::install
static void install()
Set up a K3MimeSourceFactory instance as the default mimesource factory.
Definition: k3mimesourcefactory.cpp:36
K3MimeSourceFactory::K3MimeSourceFactory
K3MimeSourceFactory(KIconLoader *loader=0)
Constructor.
Definition: k3mimesourcefactory.cpp:54
KIconLoader
KIconLoader::Small
Small
KIconLoader::User
User
KIconLoader::Desktop
Desktop
KIconLoader::MainToolbar
MainToolbar
KIconLoader::Toolbar
Toolbar
KIconLoader::global
static KIconLoader * global()
Q3MimeSourceFactory
k3mimesourcefactory.h
kdebug.h
kiconloader.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal