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

KDED

  • 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>
28class KMimeTypeFactory;
29class KConfigGroup;
30
31struct 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
37class KOfferHash
38{
39public:
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
51private:
52 KOfferHash(const KOfferHash&); // forbidden
53 QHash<QString, ServiceTypeOffersData> m_serviceTypeData;
54};
55
56
62class KMimeAssociations
63{
64public:
65 explicit KMimeAssociations(KOfferHash& offerHash);
66
67 // Read mimeapps.list files
68 bool parseAllMimeAppsList();
69
70 void parseMimeAppsList(const QString& file, int basePreference);
71
72private:
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 */
KConfigGroup
KMimeAssociations
Parse mimeapps.list files and:
Definition: kmimeassociations.h:63
KMimeAssociations::parseAllMimeAppsList
bool parseAllMimeAppsList()
Definition: kmimeassociations.cpp:53
KMimeAssociations::parseMimeAppsList
void parseMimeAppsList(const QString &file, int basePreference)
Definition: kmimeassociations.cpp:72
KMimeTypeFactory
KOfferHash
Definition: kmimeassociations.h:38
KOfferHash::KOfferHash
KOfferHash()
Definition: kmimeassociations.h:40
KOfferHash::removeServiceOffer
void removeServiceOffer(const QString &serviceType, KService::Ptr service)
Definition: kmimeassociations.cpp:140
KOfferHash::addServiceOffer
void addServiceOffer(const QString &serviceType, const KServiceOffer &offer)
Definition: kmimeassociations.cpp:118
KOfferHash::offersFor
QList< KServiceOffer > offersFor(const QString &serviceType) const
Definition: kmimeassociations.h:41
KOfferHash::hasRemovedOffer
bool hasRemovedOffer(const QString &serviceType, KService::Ptr service) const
Definition: kmimeassociations.cpp:152
KServiceOffer
KSharedPtr< KService >
QHash
QList
QSet
kserviceoffer.h
group
group
ServiceTypeOffersData
Definition: kmimeassociations.h:31
ServiceTypeOffersData::offers
QList< KServiceOffer > offers
Definition: kmimeassociations.h:32
ServiceTypeOffersData::removedOffers
QSet< KService::Ptr > removedOffers
Definition: kmimeassociations.h:34
ServiceTypeOffersData::offerSet
QSet< KService::Ptr > offerSet
Definition: kmimeassociations.h:33
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.

KDED

Skip menu "KDED"
  • Main Page
  • 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