Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konqueror / settings / filetypes / mimetypedata.h
blobace0ef1b3711abe034b9fa585ededcf061d0294d
1 /* This file is part of the KDE project
2 Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
3 Copyright (C) 2003, 2007 David Faure <faure@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License version 2 or at your option version 3 as published by
8 the Free Software Foundation.
10 This program 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef MIMETYPEDATA_H
22 #define MIMETYPEDATA_H
24 #include <kmimetype.h>
26 /**
27 * This is a non-gui (data) class, that represents a mimetype.
28 * It is a KMimeType::Ptr plus the changes we made to it.
30 class MimeTypeData
32 public:
33 // Constructor used for groups
34 MimeTypeData(const QString& major);
35 // Real constructor, used for a mimetype.
36 MimeTypeData(const KMimeType::Ptr mime, bool newItem = false);
38 QString name() const { return m_isGroup ? m_major : m_major + '/' + m_minor; }
39 QString majorType() const { return m_major; }
40 QString minorType() const { return m_minor; }
41 void setMinor(const QString& m) { m_minor = m; }
42 QString comment() const { return m_comment; }
43 void setComment(const QString& c) { m_comment = c; }
45 /**
46 * Returns true if "this" is a group
48 bool isMeta() const { return m_isGroup; }
50 /**
51 * Returns true if the type is essential, i.e. can't be deleted
52 * (see KMimeType::checkEssentialMimeTypes)
54 bool isEssential() const;
55 QString icon() const { return m_icon; }
56 //void setIcon(const QString& icon);
57 QStringList patterns() const { return m_patterns; }
58 void setPatterns(const QStringList &p);
59 QStringList appServices() const;
60 void setAppServices(const QStringList &dsl) { m_appServices = dsl; }
61 QStringList embedServices() const;
62 void setEmbedServices(const QStringList &dsl) { m_embedServices = dsl; }
64 enum AutoEmbed { Yes = 0, No = 1, UseGroupSetting = 2 };
65 AutoEmbed autoEmbed() const { return m_autoEmbed; }
66 void setAutoEmbed( AutoEmbed a ) { m_autoEmbed = a; }
68 const KMimeType::Ptr& mimeType() const { return m_mimetype; }
69 bool canUseGroupSetting() const;
71 void getAskSave(bool &);
72 void setAskSave(bool);
74 /**
75 * Returns true if the mimetype data has any unsaved changes.
77 bool isDirty() const;
78 /**
79 * Save changes to disk.
80 * Does not check isDirty(), so the common idiom is if (data.isDirty()) { needUpdate = data.sync(); }
81 * Returns true if update-mime-database needs to be run afterwards
83 bool sync();
84 /**
85 * Update m_mimetype from ksycoca when Apply is pressed
87 void refresh();
89 private:
90 AutoEmbed readAutoEmbed() const;
91 void writeAutoEmbed();
92 bool isMimeTypeDirty() const; // whether the mimetype definition file needs saving
93 bool areServicesDirty() const; // whether the services using that mimetype need saving
94 void getServiceOffers(QStringList& appServices, QStringList& embedServices) const;
95 void getMyServiceOffers() const;
96 void syncServices();
97 void saveServices(KConfigGroup & config, const QStringList& services);
98 void saveRemovedServices(KConfigGroup & config, const QStringList& services, const QString& genericServiceType);
100 KMimeType::Ptr m_mimetype; // 0 if this is data for a mimetype group (m_isGroup==true)
101 enum AskSave { AskSaveYes = 0, AskSaveNo = 1, AskSaveDefault = 2 };
102 AskSave m_askSave:3;
103 AutoEmbed m_autoEmbed:3;
104 bool m_bNewItem:1;
105 mutable bool m_bFullInit:1; // lazy init of m_appServices and m_embedServices
106 bool m_isGroup:1;
107 QString m_major, m_minor, m_comment, m_icon;
108 QStringList m_patterns;
109 mutable QStringList m_appServices;
110 mutable QStringList m_embedServices;
113 #endif /* MIMETYPEDATA_H */