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

KDED

  • sources
  • kde-4.12
  • kdelibs
  • kded
kmimeassociations.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  * Copyright 2008 David Faure <faure@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 2 of the License or ( at
7  * your option ) version 3 or, at the discretion of KDE e.V. ( which shall
8  * act as a proxy as in section 14 of the GPLv3 ), 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 Lesser 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 #ifndef KDED_KMIMEASSOCIATIONS_H
22 #define KDED_KMIMEASSOCIATIONS_H
23 
24 #include <QSet>
25 #include <QStringList>
26 #include <QHash>
27 #include <kserviceoffer.h>
28 class KMimeTypeFactory;
29 class KConfigGroup;
30 
31 struct ServiceTypeOffersData {
32  QList<KServiceOffer> offers; // service + initial preference + allow as default
33  QSet<KService::Ptr> offerSet; // for quick contains() check
34  QSet<KService::Ptr> removedOffers; // remember removed offers explicitly
35 };
36 
37 class KOfferHash
38 {
39 public:
40  KOfferHash() {}
41  QList<KServiceOffer> offersFor(const QString& serviceType) const {
42  QHash<QString, ServiceTypeOffersData>::const_iterator it = m_serviceTypeData.find(serviceType);
43  if (it != m_serviceTypeData.end())
44  return (*it).offers;
45  return QList<KServiceOffer>();
46  }
47  void addServiceOffer(const QString& serviceType, const KServiceOffer& offer);
48  void removeServiceOffer(const QString& serviceType, KService::Ptr service);
49  bool hasRemovedOffer(const QString& serviceType, KService::Ptr service) const;
50 
51 private:
52  KOfferHash(const KOfferHash&); // forbidden
53  QHash<QString, ServiceTypeOffersData> m_serviceTypeData;
54 };
55 
56 
62 class KMimeAssociations
63 {
64 public:
65  explicit KMimeAssociations(KOfferHash& offerHash);
66 
67  // Read mimeapps.list files
68  bool parseAllMimeAppsList();
69 
70  void parseMimeAppsList(const QString& file, int basePreference);
71 
72 private:
73  void parseAddedAssociations(const KConfigGroup& group, const QString& file, int basePreference);
74  void parseRemovedAssociations(const KConfigGroup& group, const QString& file);
75 
76  KOfferHash& m_offerHash;
77 };
78 
79 #endif /* KMIMEASSOCIATIONS_H */
KOfferHash::offersFor
QList< KServiceOffer > offersFor(const QString &serviceType) const
Definition: kmimeassociations.h:41
KSharedPtr
KMimeAssociations
Parse mimeapps.list files and:
Definition: kmimeassociations.h:62
ServiceTypeOffersData::offers
QList< KServiceOffer > offers
Definition: kmimeassociations.h:32
KMimeAssociations::parseAllMimeAppsList
bool parseAllMimeAppsList()
Definition: kmimeassociations.cpp:53
group
KOfferHash::addServiceOffer
void addServiceOffer(const QString &serviceType, const KServiceOffer &offer)
Definition: kmimeassociations.cpp:118
KMimeTypeFactory
QString
QHash
kserviceoffer.h
ServiceTypeOffersData::offerSet
QSet< KService::Ptr > offerSet
Definition: kmimeassociations.h:33
KMimeAssociations::KMimeAssociations
KMimeAssociations(KOfferHash &offerHash)
Definition: kmimeassociations.cpp:31
KOfferHash
Definition: kmimeassociations.h:37
KOfferHash::removeServiceOffer
void removeServiceOffer(const QString &serviceType, KService::Ptr service)
Definition: kmimeassociations.cpp:140
KMimeAssociations::parseMimeAppsList
void parseMimeAppsList(const QString &file, int basePreference)
Definition: kmimeassociations.cpp:72
QSet< KService::Ptr >
KServiceOffer
KConfigGroup
KOfferHash::hasRemovedOffer
bool hasRemovedOffer(const QString &serviceType, KService::Ptr service) const
Definition: kmimeassociations.cpp:152
ServiceTypeOffersData::removedOffers
QSet< KService::Ptr > removedOffers
Definition: kmimeassociations.h:34
KOfferHash::KOfferHash
KOfferHash()
Definition: kmimeassociations.h:40
ServiceTypeOffersData
Definition: kmimeassociations.h:31
QList< KServiceOffer >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDED

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

kdelibs API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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