File indexing completed on 2024-05-05 04:48:27

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Daniel Dewald <Daniel.Dewald@time-shift.de>                       *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016  
0017 #ifndef TAGGUESSER_H
0018 #define TAGGUESSER_H
0019 
0020 #include <QMap>
0021 #include <QString>
0022 
0023 class TagGuesser
0024 {
0025     public:
0026 
0027         TagGuesser();
0028 
0029         /**
0030         *   Sets the Filename to guess from
0031         *   @arg fileName Filename to guess from
0032         */
0033         void setFilename( const QString &fileName );
0034 
0035         /**
0036         *   Sets the schema to guess from
0037         *   @arg schema schema to guess from
0038         */
0039         void setSchema( const QString &schema );
0040 
0041         /**
0042         *   Sets the case type
0043         *   @arg caseOptions the case type to use
0044         **/
0045         void setCaseType( const int caseOptions );
0046 
0047         /**
0048         *   Sets whether trailing spaces are cut from tags
0049         *   @arg cutSpaces should trailing spaces be cut from tags
0050         **/
0051         void setCutTrailingSpaces( const bool cutTrailingSpaces );
0052 
0053         /**
0054         *   Sets whether underscores should be converted to spaces
0055         *   @arg convertUnderscores should underscores be converted
0056         */
0057         void setConvertUnderscores( const bool convertUnderscores );
0058 
0059         /**
0060         *   tries guessing tags from filename and options
0061         */
0062         bool guess();
0063 
0064         /**
0065         *  @returns a list of guessed Tags
0066         */
0067         QMap<qint64,QString> tags() const { return m_tags; }
0068 
0069     private:
0070 
0071         QMap<qint64,QString> m_tags;        //!< Taglist (e.g. < Meta::valArtist,"some artist" >
0072         bool m_guessed;                     //!< Is true when guessing was done
0073         QString m_fileName;                 //!< Filename to be guessed from
0074         QString m_schema;                   //!< Schema after which should be guessed
0075         int m_caseOptions;                  //!< Case options to change tags after
0076         bool m_cutTrailingSpaces;           //!< Whether trailing spaces should be cut from tags
0077         bool m_convertUnderscores;          //!< Whether underscores should be converted to spaces
0078 
0079         /**
0080         *   Converts a tag to specific case type
0081         *   @arg tag    tag to convert
0082         *   @arg type   case type to convert tag to
0083         *   @returns    the converted tag
0084         */
0085         QString convertTagCaseType( const QString &tag, int type );
0086 };
0087 
0088 #endif /* TAGGUESSER_H */
0089