File indexing completed on 2025-02-23 04:34:22
0001 /** 0002 * \file taggedfileiconprovider.h 0003 * Provides icons for tagged files. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 13 Jul 2019 0008 * 0009 * Copyright (C) 2019-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QMap> 0030 #include <QVariant> 0031 #include <QSize> 0032 #include "coretaggedfileiconprovider.h" 0033 0034 /** 0035 * Provides icons for tagged files. 0036 */ 0037 class KID3_GUI_EXPORT TaggedFileIconProvider : 0038 public CoreTaggedFileIconProvider { 0039 public: 0040 /** 0041 * Constructor. 0042 */ 0043 TaggedFileIconProvider(); 0044 0045 /** 0046 * Destructor. 0047 */ 0048 ~TaggedFileIconProvider() override = default; 0049 0050 /** 0051 * Set icon to be used for modified files. 0052 * @param icon modified icon 0053 */ 0054 void setModifiedIcon(const QVariant& icon) override; 0055 0056 /** 0057 * Set the requested size for icons. 0058 * 0059 * The size set with this method will be used to create icons. 0060 * 0061 * @param size icon size, the default is 16x16. 0062 */ 0063 void setRequestedSize(const QSize& size) override; 0064 0065 /** 0066 * Get an icon for a tagged file. 0067 * 0068 * @param taggedFile tagged file 0069 * 0070 * @return icon for tagged file 0071 */ 0072 QVariant iconForTaggedFile(const TaggedFile* taggedFile) override; 0073 0074 /** 0075 * Get pixmap for an icon ID. 0076 * @param id icon ID as returned by iconIdForTaggedFile(), or data for image 0077 * set with setImageData() 0078 * @return pixmap for @a id. 0079 */ 0080 QVariant pixmapForIconId(const QByteArray& id) override; 0081 0082 /** 0083 * Get background color for a tagged file. 0084 * 0085 * @param taggedFile tagged file 0086 * 0087 * @return background color for tagged file 0088 */ 0089 QVariant backgroundForTaggedFile(const TaggedFile* taggedFile) override; 0090 0091 /** 0092 * Get brush with color for a context. 0093 * @param context color context 0094 * @return brush. 0095 */ 0096 QVariant colorForContext(ColorContext context) const override; 0097 0098 /** 0099 * Get context for a brush. 0100 * @param color brush 0101 * @return color context. 0102 */ 0103 ColorContext contextForColor(const QVariant& color) const override; 0104 0105 private: 0106 void createIcons(); 0107 0108 QMap<QByteArray, QVariant> m_iconMap; 0109 QMap<QByteArray, QVariant> m_pixmapMap; 0110 QSize m_requestedSize; 0111 QVariant m_modifiedIcon; 0112 QVariant m_markedColor; 0113 };