tagguesser.h 2.26 KB
Newer Older
1 2
/**
 * Copyright (C) 2003 Frerich Raabe <raabe@kde.org>
3
 *
4 5 6 7 8 9 10 11 12 13 14
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
15
 */
16

17 18
#ifndef TAGGUESSER_H
#define TAGGUESSER_H
19

20
#include <QString>
21
#include <QRegExp>
22
#include <QList>
23 24 25 26

class FileNameScheme
{
    public:
27
        typedef QList<FileNameScheme> List;
28 29

        FileNameScheme() { }
Yuri Chornoivan's avatar
Yuri Chornoivan committed
30
        explicit FileNameScheme(const QString &s);
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

        bool matches(const QString &s) const;

        QString title() const;
        QString artist() const;
        QString album() const;
        QString track() const;
        QString comment() const;

    private:
        QString composeRegExp(const QString &s) const;

        mutable QRegExp m_regExp;
        int m_titleField;
        int m_artistField;
        int m_albumField;
        int m_trackField;
        int m_commentField;
};

class TagGuesser
{
    public:
54

55
        enum Type { FileName = 0, MusicBrainz = 1 };
56

57 58 59
        static QStringList schemeStrings();
        static void setSchemeStrings(const QStringList &schemes);

60
        TagGuesser();
Yuri Chornoivan's avatar
Yuri Chornoivan committed
61
        explicit TagGuesser(const QString &absFileName);
62 63 64 65 66 67 68 69 70 71 72

        void guess(const QString &absFileName);

        QString title() const { return m_title; }
        QString artist() const { return m_artist; }
        QString album() const { return m_album; }
        QString track() const { return m_track; }
        QString comment() const { return m_comment; }

    private:
        void loadSchemes();
73
        QString capitalizeWords(const QString &s);
74 75 76 77 78 79 80 81 82

        FileNameScheme::List m_schemes;
        QString m_title;
        QString m_artist;
        QString m_album;
        QString m_track;
        QString m_comment;
};

83
#endif // TAGGUESSER_H
84 85

// vim: set et sw=4 tw=0 sta: