2010-06-24 18:26:49 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-24 18:26:49 +02:00
|
|
|
|
|
|
|
Clementine 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-07-19 15:37:56 +02:00
|
|
|
#ifndef SRC_CORE_ORGANISEFORMAT_H_
|
|
|
|
#define SRC_CORE_ORGANISEFORMAT_H_
|
2010-06-24 18:26:49 +02:00
|
|
|
|
|
|
|
#include <QSyntaxHighlighter>
|
|
|
|
#include <QValidator>
|
|
|
|
|
|
|
|
#include "core/song.h"
|
|
|
|
|
|
|
|
class OrganiseFormat {
|
2013-07-19 15:37:56 +02:00
|
|
|
public:
|
2010-06-24 18:26:49 +02:00
|
|
|
OrganiseFormat(const QString& format = QString());
|
|
|
|
|
|
|
|
static const char* kTagPattern;
|
|
|
|
static const char* kBlockPattern;
|
|
|
|
static const QStringList kKnownTags;
|
2010-09-25 17:04:58 +02:00
|
|
|
static const char* kInvalidFatCharacters;
|
|
|
|
static const int kInvalidFatCharactersCount;
|
2010-06-24 18:26:49 +02:00
|
|
|
|
|
|
|
QString format() const { return format_; }
|
|
|
|
bool replace_non_ascii() const { return replace_non_ascii_; }
|
|
|
|
bool replace_spaces() const { return replace_spaces_; }
|
|
|
|
bool replace_the() const { return replace_the_; }
|
|
|
|
|
2010-06-24 20:33:38 +02:00
|
|
|
void set_format(const QString& v);
|
2010-06-24 18:26:49 +02:00
|
|
|
void set_replace_non_ascii(bool v) { replace_non_ascii_ = v; }
|
|
|
|
void set_replace_spaces(bool v) { replace_spaces_ = v; }
|
|
|
|
void set_replace_the(bool v) { replace_the_ = v; }
|
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
QString GetFilenameForSong(const Song& song) const;
|
|
|
|
|
|
|
|
|
|
|
|
class Validator : public QValidator {
|
2013-07-19 15:37:56 +02:00
|
|
|
public:
|
|
|
|
explicit Validator(QObject* parent = 0);
|
2010-06-24 18:26:49 +02:00
|
|
|
QValidator::State validate(QString& format, int& pos) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SyntaxHighlighter : public QSyntaxHighlighter {
|
2013-07-19 15:37:56 +02:00
|
|
|
public:
|
2010-09-05 14:49:56 +02:00
|
|
|
static const QRgb kValidTagColorLight;
|
|
|
|
static const QRgb kInvalidTagColorLight;
|
|
|
|
static const QRgb kBlockColorLight;
|
|
|
|
static const QRgb kValidTagColorDark;
|
|
|
|
static const QRgb kInvalidTagColorDark;
|
|
|
|
static const QRgb kBlockColorDark;
|
|
|
|
|
2013-07-19 15:37:56 +02:00
|
|
|
explicit SyntaxHighlighter(QObject* parent = 0);
|
|
|
|
explicit SyntaxHighlighter(QTextEdit* parent);
|
|
|
|
explicit SyntaxHighlighter(QTextDocument* parent);
|
2010-06-24 18:26:49 +02:00
|
|
|
void highlightBlock(const QString& format);
|
|
|
|
};
|
|
|
|
|
2013-07-19 15:37:56 +02:00
|
|
|
private:
|
|
|
|
QString ParseBlock(
|
|
|
|
QString block, const Song& song, bool* any_empty = NULL) const;
|
2010-06-24 18:26:49 +02:00
|
|
|
QString TagValue(const QString& tag, const Song& song) const;
|
|
|
|
|
|
|
|
QString format_;
|
|
|
|
bool replace_non_ascii_;
|
|
|
|
bool replace_spaces_;
|
|
|
|
bool replace_the_;
|
|
|
|
};
|
|
|
|
|
2013-07-19 15:37:56 +02:00
|
|
|
#endif // SRC_CORE_ORGANISEFORMAT_H_
|