Messagelib

mimetype.cpp
1 /*
2  SPDX-FileCopyrightText: 2005 Till Adam <[email protected]>
3  SPDX-FileCopyrightText: 2016 Sandro KnauƟ <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #include "utils/mimetype.h"
9 #include "utils/iconnamecache.h"
10 
11 #include <MimeTreeParser/NodeHelper>
12 #include <MimeTreeParser/Util>
13 
14 #include <KIconLoader>
15 #include <KMime/Content>
16 
17 QString MessageViewer::Util::iconPathForMimetype(const QString &mimeType, int iconSize, const QString &fallbackFileName1, const QString &fallbackFileName2)
18 {
19  return IconNameCache::instance()->iconPath(MimeTreeParser::Util::iconNameForMimetype(mimeType, fallbackFileName1, fallbackFileName2), iconSize);
20 }
21 
22 QString MessageViewer::Util::iconPathForContent(KMime::Content *node, int size)
23 {
24  return IconNameCache::instance()->iconPath(MimeTreeParser::Util::iconNameForContent(node), size);
25 }
26 
27 MessageViewer::Util::AttachmentDisplayInfo MessageViewer::Util::attachmentDisplayInfo(KMime::Content *node)
28 {
29  AttachmentDisplayInfo info;
30  info.icon = iconPathForContent(node, KIconLoader::Small);
31  info.label = MimeTreeParser::Util::labelForContent(node);
32 
33  const bool typeBlacklisted = MimeTreeParser::Util::isTypeBlacklisted(node);
34  info.displayInHeader = !info.label.isEmpty() && !info.icon.isEmpty() && !typeBlacklisted;
35  return info;
36 }
QString MESSAGEVIEWER_EXPORT iconPathForMimetype(const QString &mimeType, int iconSize, const QString &fallbackFileName1=QString(), const QString &fallbackFileName2=QString())
Finds the filename of an icon based on the given mimetype or filenames.
Definition: mimetype.cpp:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:57:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.