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

kdecore

  • kdecore
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 <kglobal.h>
23 #include <kinstance.h>
24 #include <kiconloader.h>
25 
26 #include "kmimesourcefactory.h"
27 
28 class KMimeSourceFactoryPrivate
29 {
30 public:
31  inline KMimeSourceFactoryPrivate (KIconLoader* loader) : m_iconLoader(loader), m_instance(0L) {}
32  inline KIconLoader *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  KIconLoader *m_iconLoader;
44  KInstance *m_instance;
45 };
46 
47 KMimeSourceFactory::KMimeSourceFactory (KIconLoader* loader)
48  : TQMimeSourceFactory (),
49  d (new KMimeSourceFactoryPrivate (loader))
50 {
51 }
52 
53 KMimeSourceFactory::~KMimeSourceFactory()
54 {
55  delete d;
56 }
57 
58 TQString 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, KIcon::Desktop);
75  }
76  else if (myContext == "toolbar")
77  {
78  result = d->iconLoader()->iconPath (myName, KIcon::Toolbar);
79  }
80  else if (myContext == "maintoolbar")
81  {
82  result = d->iconLoader()->iconPath (myName, KIcon::MainToolbar);
83  }
84  else if (myContext == "small")
85  {
86  result = d->iconLoader()->iconPath (myName, KIcon::Small);
87  }
88  else if (myContext == "user")
89  {
90  result = d->iconLoader()->iconPath (myName, KIcon::User);
91  }
92 
93  if (result.isEmpty())
94  result = TQMimeSourceFactory::makeAbsolute (absOrRelName, context);
95 
96  return result;
97 }
98 
99 void KMimeSourceFactory::setInstance(KInstance *instance)
100 {
101  d->m_instance = instance;
102 }
103 
104 void KMimeSourceFactory::virtual_hook( int, void* )
105 { /*BASE::virtual_hook( id, data );*/ }
106 
KIcon::Toolbar
Toolbar icons.
Definition: kicontheme.h:96
KMimeSourceFactory::~KMimeSourceFactory
virtual ~KMimeSourceFactory()
Destructor.
Definition: kmimesourcefactory.cpp:53
KIcon::Small
Small icons.
Definition: kicontheme.h:100
KIcon::User
User icons.
Definition: kicontheme.h:106
KIcon::Desktop
Desktop icons.
Definition: kicontheme.h:92
KInstance
Access to KDE global objects for use in shared libraries.
Definition: kinstance.h:43
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
KMimeSourceFactory(KIconLoader *loader=KGlobal::iconLoader())
Constructor.
Definition: kmimesourcefactory.cpp:47
KIconLoader
Iconloader for KDE.
Definition: kiconloader.h:77
KIcon::MainToolbar
Main toolbar icons.
Definition: kicontheme.h:98

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |