• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
kmimesourcefactory.cpp
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 <kdebug.h>
22#include <tdeglobal.h>
23#include <kinstance.h>
24#include <kiconloader.h>
25
26#include "kmimesourcefactory.h"
27
28class KMimeSourceFactoryPrivate
29{
30public:
31 inline KMimeSourceFactoryPrivate (TDEIconLoader* loader) : m_iconLoader(loader), m_instance(0L) {}
32 inline TDEIconLoader *iconLoader()
33 {
34 // If we don't have either of these, things are looking grim.
35 Q_ASSERT(m_instance || m_iconLoader);
36
37 if (m_iconLoader)
38 return m_iconLoader;
39
40 return m_instance->iconLoader();
41 }
42
43 TDEIconLoader *m_iconLoader;
44 TDEInstance *m_instance;
45};
46
47KMimeSourceFactory::KMimeSourceFactory (TDEIconLoader* loader)
48 : TQMimeSourceFactory (),
49 d (new KMimeSourceFactoryPrivate (loader))
50{
51}
52
53KMimeSourceFactory::~KMimeSourceFactory()
54{
55 delete d;
56}
57
58TQString KMimeSourceFactory::makeAbsolute (const TQString& absOrRelName, const TQString& context) const
59{
60 TQString myName;
61 TQString myContext;
62
63 const int pos = absOrRelName.find ('|');
64 if (pos > -1)
65 {
66 myContext = absOrRelName.left (pos);
67 myName = absOrRelName.right (absOrRelName.length() - myContext.length() - 1);
68 }
69
70 TQString result;
71
72 if (myContext == "desktop")
73 {
74 result = d->iconLoader()->iconPath (myName, TDEIcon::Desktop);
75 }
76 else if (myContext == "toolbar")
77 {
78 result = d->iconLoader()->iconPath (myName, TDEIcon::Toolbar);
79 }
80 else if (myContext == "maintoolbar")
81 {
82 result = d->iconLoader()->iconPath (myName, TDEIcon::MainToolbar);
83 }
84 else if (myContext == "small")
85 {
86 result = d->iconLoader()->iconPath (myName, TDEIcon::Small);
87 }
88 else if (myContext == "user")
89 {
90 result = d->iconLoader()->iconPath (myName, TDEIcon::User);
91 }
92
93 if (result.isEmpty())
94 result = TQMimeSourceFactory::makeAbsolute (absOrRelName, context);
95
96 return result;
97}
98
99void KMimeSourceFactory::setInstance(TDEInstance *instance)
100{
101 d->m_instance = instance;
102}
103
104void KMimeSourceFactory::virtual_hook( int, void* )
105{ /*BASE::virtual_hook( id, data );*/ }
106
KMimeSourceFactory::KMimeSourceFactory
KMimeSourceFactory(TDEIconLoader *loader=TDEGlobal::iconLoader())
Constructor.
Definition: kmimesourcefactory.cpp:47
KMimeSourceFactory::makeAbsolute
virtual TQString makeAbsolute(const TQString &abs_or_rel_name, const TQString &context) const
This function is maps an absolute or relative name for a resource to the absolute one.
Definition: kmimesourcefactory.cpp:58
KMimeSourceFactory::~KMimeSourceFactory
virtual ~KMimeSourceFactory()
Destructor.
Definition: kmimesourcefactory.cpp:53
TDEIconLoader
Iconloader for KDE.
Definition: kiconloader.h:78
TDEIcon::Toolbar
@ Toolbar
Toolbar icons.
Definition: kicontheme.h:96
TDEIcon::MainToolbar
@ MainToolbar
Main toolbar icons.
Definition: kicontheme.h:98
TDEIcon::Small
@ Small
Small icons.
Definition: kicontheme.h:100
TDEIcon::User
@ User
User icons.
Definition: kicontheme.h:106
TDEIcon::Desktop
@ Desktop
Desktop icons.
Definition: kicontheme.h:92
TDEInstance
Access to KDE global objects for use in shared libraries.
Definition: kinstance.h:48

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.