File indexing completed on 2024-05-19 04:56:00

0001 /**
0002  * \file coretaggedfileiconprovider.h
0003  * Provides icons for tagged files.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 29-Mar-2011
0008  *
0009  * Copyright (C) 2011-2018  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 "kid3api.h"
0030 
0031 class QVariant;
0032 class QSize;
0033 class TaggedFile;
0034 
0035 /**
0036  * Contextual colors.
0037  */
0038 enum class ColorContext {
0039   None,
0040   Marked,
0041   Error
0042 };
0043 
0044 /**
0045  * Provides icons for tagged files.
0046  */
0047 class KID3_CORE_EXPORT CoreTaggedFileIconProvider {
0048 public:
0049   /**
0050    * Constructor.
0051    */
0052   CoreTaggedFileIconProvider();
0053 
0054   /**
0055    * Destructor.
0056    */
0057   virtual ~CoreTaggedFileIconProvider() = default;
0058 
0059   /**
0060    * Set icon to be used for modified files.
0061    * @param icon modified icon
0062    */
0063   virtual void setModifiedIcon(const QVariant& icon);
0064 
0065   /**
0066    * Set the requested size for icons.
0067    *
0068    * The size set with this method will be used to create icons.
0069    *
0070    * @param size icon size, the default is 16x16.
0071    */
0072   virtual void setRequestedSize(const QSize& size);
0073 
0074   /**
0075    * Get an icon for a tagged file.
0076    *
0077    * @param taggedFile tagged file
0078    *
0079    * @return icon for tagged file
0080    */
0081   virtual QVariant iconForTaggedFile(const TaggedFile* taggedFile);
0082 
0083   /**
0084    * Get an icon ID for a tagged file.
0085    *
0086    * @param taggedFile tagged file
0087    *
0088    * @return icon ID for tagged file
0089    */
0090   virtual QByteArray iconIdForTaggedFile(const TaggedFile* taggedFile) const;
0091 
0092   /**
0093    * Get pixmap for an icon ID.
0094    * @param id icon ID as returned by iconIdForTaggedFile(), or data for image
0095    * set with setImageData()
0096    * @return pixmap for @a id.
0097    */
0098   virtual QVariant pixmapForIconId(const QByteArray& id);
0099 
0100   /**
0101    * Get background color for a tagged file.
0102    *
0103    * @param taggedFile tagged file
0104    *
0105    * @return background color for tagged file
0106    */
0107   virtual QVariant backgroundForTaggedFile(const TaggedFile* taggedFile);
0108 
0109   /**
0110    * Get brush with color for a context.
0111    * @param context color context
0112    * @return brush.
0113    */
0114   virtual QVariant colorForContext(ColorContext context) const;
0115 
0116   /**
0117    * Get context for a brush.
0118    * @param color brush
0119    * @return color context.
0120    */
0121   virtual ColorContext contextForColor(const QVariant& color) const;
0122 };