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

0001 /**
0002  * \file genremodel.h
0003  * Model with genres.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 22 Jun 2014
0008  *
0009  * Copyright (C) 2014-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 <QStringListModel>
0030 #include "kid3api.h"
0031 
0032 /**
0033  * Genre model.
0034  */
0035 class KID3_CORE_EXPORT GenreModel : public QStringListModel {
0036   Q_OBJECT
0037 public:
0038   /**
0039    * Constructor.
0040    * @param id3v1 true to create genres for ID3v1
0041    * @param parent parent widget
0042    */
0043   explicit GenreModel(bool id3v1, QObject* parent = nullptr);
0044 
0045   /**
0046    * Destructor.
0047    */
0048   ~GenreModel() override = default;
0049 
0050   /**
0051    * Initialize module with genres.
0052    * This method is called by the constructor. It shall be called after
0053    * construction if genre settings are changed.
0054    */
0055   void init();
0056 
0057   /**
0058    * Get the row for a genre.
0059    * If the genre is not found, it is added at the returned row.
0060    * @param genreStr genre string
0061    * @return row number.
0062    */
0063   Q_INVOKABLE int getRowForGenre(const QString& genreStr);
0064 
0065 private:
0066   bool m_id3v1;
0067 };