2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
*
|
|
|
|
* Strawberry 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.
|
|
|
|
*
|
|
|
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QObject>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QApplication>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QList>
|
|
|
|
#include <QChar>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringBuilder>
|
|
|
|
#include <QStringList>
|
2020-07-18 04:05:07 +02:00
|
|
|
#include <QRegularExpression>
|
2020-07-20 00:57:42 +02:00
|
|
|
#include <QRegularExpressionMatch>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QUrl>
|
2020-04-09 18:14:02 +02:00
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QDir>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QColor>
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QValidator>
|
|
|
|
#include <QTextEdit>
|
2020-05-16 19:17:06 +02:00
|
|
|
#include <QTextDocument>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QTextFormat>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "core/arraysize.h"
|
2018-12-29 15:37:16 +01:00
|
|
|
#include "core/timeconstants.h"
|
|
|
|
#include "core/utilities.h"
|
|
|
|
#include "core/song.h"
|
2018-05-01 00:41:33 +02:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
#include "organizeformat.h"
|
2018-05-01 00:41:33 +02:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
const char *OrganizeFormat::kTagPattern = "\\%([a-zA-Z]*)";
|
|
|
|
const char *OrganizeFormat::kBlockPattern = "\\{([^{}]+)\\}";
|
|
|
|
const QStringList OrganizeFormat::kKnownTags = QStringList() << "title"
|
2018-02-27 18:06:05 +01:00
|
|
|
<< "album"
|
|
|
|
<< "artist"
|
|
|
|
<< "artistinitial"
|
|
|
|
<< "albumartist"
|
|
|
|
<< "composer"
|
|
|
|
<< "track"
|
|
|
|
<< "disc"
|
|
|
|
<< "year"
|
2018-12-29 15:37:16 +01:00
|
|
|
<< "originalyear"
|
2018-02-27 18:06:05 +01:00
|
|
|
<< "genre"
|
|
|
|
<< "comment"
|
|
|
|
<< "length"
|
|
|
|
<< "bitrate"
|
|
|
|
<< "samplerate"
|
|
|
|
<< "bitdepth"
|
|
|
|
<< "extension"
|
|
|
|
<< "performer"
|
|
|
|
<< "grouping"
|
2018-12-29 15:37:16 +01:00
|
|
|
<< "lyrics";
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
const QRegularExpression OrganizeFormat::kInvalidDirCharacters("[/\\\\]");
|
|
|
|
const QRegularExpression OrganizeFormat::kProblematicCharacters("[:?*\"<>|]");
|
2018-02-27 18:06:05 +01:00
|
|
|
// From http://en.wikipedia.org/wiki/8.3_filename#Directory_table
|
2020-08-04 21:18:14 +02:00
|
|
|
const QRegularExpression OrganizeFormat::kInvalidFatCharacters("[^a-zA-Z0-9!#\\$%&'()\\-@\\^_`{}~/. ]");
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
const char OrganizeFormat::kInvalidPrefixCharacters[] = ".";
|
|
|
|
const int OrganizeFormat::kInvalidPrefixCharactersCount = arraysize(OrganizeFormat::kInvalidPrefixCharacters) - 1;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
const QRgb OrganizeFormat::SyntaxHighlighter::kValidTagColorLight = qRgb(64, 64, 255);
|
|
|
|
const QRgb OrganizeFormat::SyntaxHighlighter::kInvalidTagColorLight = qRgb(255, 64, 64);
|
|
|
|
const QRgb OrganizeFormat::SyntaxHighlighter::kBlockColorLight = qRgb(230, 230, 230);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
const QRgb OrganizeFormat::SyntaxHighlighter::kValidTagColorDark = qRgb(128, 128, 255);
|
|
|
|
const QRgb OrganizeFormat::SyntaxHighlighter::kInvalidTagColorDark = qRgb(255, 128, 128);
|
|
|
|
const QRgb OrganizeFormat::SyntaxHighlighter::kBlockColorDark = qRgb(64, 64, 64);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
OrganizeFormat::OrganizeFormat(const QString &format)
|
2018-02-27 18:06:05 +01:00
|
|
|
: format_(format),
|
2020-04-09 19:59:31 +02:00
|
|
|
remove_problematic_(false),
|
2018-12-29 15:37:16 +01:00
|
|
|
remove_non_fat_(false),
|
|
|
|
remove_non_ascii_(false),
|
2019-03-22 23:18:14 +01:00
|
|
|
allow_ascii_ext_(false),
|
2018-12-29 15:37:16 +01:00
|
|
|
replace_spaces_(true) {}
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
void OrganizeFormat::set_format(const QString &v) {
|
2018-02-27 18:06:05 +01:00
|
|
|
format_ = v;
|
|
|
|
format_.replace('\\', '/');
|
|
|
|
}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
bool OrganizeFormat::IsValid() const {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
int pos = 0;
|
|
|
|
QString format_copy(format_);
|
|
|
|
|
|
|
|
Validator v;
|
|
|
|
return v.validate(format_copy, pos) == QValidator::Acceptable;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-18 13:24:33 +02:00
|
|
|
QString OrganizeFormat::GetFilenameForSong(const Song &song, QString extension) const {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
QString filename = ParseBlock(format_, song);
|
|
|
|
|
|
|
|
if (QFileInfo(filename).completeBaseName().isEmpty()) {
|
2018-05-01 00:41:33 +02:00
|
|
|
// Avoid having empty filenames, or filenames with extension only: in this case, keep the original filename.
|
|
|
|
// We remove the extension from "filename" if it exists, as song.basefilename() also contains the extension.
|
2020-10-21 21:32:12 +02:00
|
|
|
QString path = QFileInfo(filename).path();
|
|
|
|
filename.clear();
|
|
|
|
if (!path.isEmpty()) {
|
|
|
|
filename.append(path);
|
|
|
|
if (path.right(1) != '/' && path.right(1) != '\\') {
|
|
|
|
filename.append('/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
filename.append(song.basefilename());
|
2018-12-29 15:37:16 +01:00
|
|
|
}
|
|
|
|
|
2020-04-09 19:59:31 +02:00
|
|
|
if (remove_problematic_) filename = filename.remove(kProblematicCharacters);
|
2019-07-14 03:16:53 +02:00
|
|
|
if (remove_non_fat_ || (remove_non_ascii_ && !allow_ascii_ext_)) filename = Utilities::UnicodeToAscii(filename);
|
2020-04-09 19:59:31 +02:00
|
|
|
if (remove_non_fat_) filename = filename.remove(kInvalidFatCharacters);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-12-29 15:37:16 +01:00
|
|
|
if (remove_non_ascii_) {
|
2019-03-22 23:18:14 +01:00
|
|
|
int ascii = 128;
|
|
|
|
if (allow_ascii_ext_) ascii = 255;
|
2018-02-27 18:06:05 +01:00
|
|
|
QString stripped;
|
2020-04-09 18:14:02 +02:00
|
|
|
for (int i = 0 ; i < filename.length() ; ++i) {
|
2020-07-18 04:05:07 +02:00
|
|
|
const QChar c = filename[i];
|
2020-11-17 01:22:00 +01:00
|
|
|
if (c.unicode() < ascii) {
|
2018-02-27 18:06:05 +01:00
|
|
|
stripped.append(c);
|
2018-05-01 00:41:33 +02:00
|
|
|
}
|
|
|
|
else {
|
2018-02-27 18:06:05 +01:00
|
|
|
const QString decomposition = c.decomposition();
|
2020-11-17 01:22:00 +01:00
|
|
|
if (!decomposition.isEmpty() && decomposition[0].unicode() < ascii)
|
2018-02-27 18:06:05 +01:00
|
|
|
stripped.append(decomposition[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
filename = stripped;
|
|
|
|
}
|
|
|
|
|
2020-04-09 18:14:02 +02:00
|
|
|
// Remove repeated whitespaces in the filename.
|
|
|
|
filename = filename.simplified();
|
|
|
|
|
|
|
|
QFileInfo info(filename);
|
2020-10-18 13:24:33 +02:00
|
|
|
if (extension.isEmpty()) extension = info.suffix();
|
2020-05-16 19:17:06 +02:00
|
|
|
QString filepath;
|
|
|
|
if (!info.path().isEmpty() && info.path() != ".") {
|
|
|
|
filepath.append(info.path());
|
|
|
|
filepath.append("/");
|
|
|
|
}
|
|
|
|
filepath.append(info.completeBaseName());
|
2020-04-09 18:14:02 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
// Fix any parts of the path that start with dots.
|
2020-04-09 18:14:02 +02:00
|
|
|
QStringList parts_old = filepath.split("/");
|
|
|
|
QStringList parts_new;
|
|
|
|
for (int i = 0 ; i < parts_old.count() ; ++i) {
|
|
|
|
QString part = parts_old[i];
|
|
|
|
for (int j = 0 ; j < kInvalidPrefixCharactersCount ; ++j) {
|
|
|
|
if (part.startsWith(kInvalidPrefixCharacters[j])) {
|
2020-04-09 19:59:31 +02:00
|
|
|
part = part.remove(0, 1);
|
2018-02-27 18:06:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-04-09 18:14:02 +02:00
|
|
|
part = part.trimmed();
|
|
|
|
parts_new.append(part);
|
|
|
|
}
|
|
|
|
filename = parts_new.join("/");
|
|
|
|
|
2020-07-18 04:05:07 +02:00
|
|
|
if (replace_spaces_) filename.replace(QRegularExpression("\\s"), "_");
|
2020-04-09 18:14:02 +02:00
|
|
|
|
|
|
|
if (!extension.isEmpty()) {
|
|
|
|
filename.append(QString(".%1").arg(extension));
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
2020-04-09 18:14:02 +02:00
|
|
|
return filename;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *any_empty) const {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-07-20 00:57:42 +02:00
|
|
|
QRegularExpression tag_regexp(kTagPattern);
|
|
|
|
QRegularExpression block_regexp(kBlockPattern);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// Find any blocks first
|
|
|
|
int pos = 0;
|
2020-07-20 00:57:42 +02:00
|
|
|
QRegularExpressionMatch re_match;
|
|
|
|
for (re_match = block_regexp.match(block, pos) ; re_match.hasMatch() ; re_match = block_regexp.match(block, pos)) {
|
|
|
|
pos = re_match.capturedStart();
|
2018-02-27 18:06:05 +01:00
|
|
|
// Recursively parse the block
|
|
|
|
bool empty = false;
|
2020-07-20 00:57:42 +02:00
|
|
|
QString value = ParseBlock(re_match.captured(1), song, &empty);
|
2018-02-27 18:06:05 +01:00
|
|
|
if (empty) value = "";
|
|
|
|
|
|
|
|
// Replace the block's value
|
2020-07-20 00:57:42 +02:00
|
|
|
block.replace(pos, re_match.capturedLength(), value);
|
2018-02-27 18:06:05 +01:00
|
|
|
pos += value.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now look for tags
|
|
|
|
bool empty = false;
|
|
|
|
pos = 0;
|
2020-07-20 00:57:42 +02:00
|
|
|
for (re_match = tag_regexp.match(block, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(block, pos)) {
|
|
|
|
pos = re_match.capturedStart();
|
|
|
|
QString value = TagValue(re_match.captured(1), song);
|
2018-02-27 18:06:05 +01:00
|
|
|
if (value.isEmpty()) empty = true;
|
|
|
|
|
2020-07-20 00:57:42 +02:00
|
|
|
block.replace(pos, re_match.capturedLength(), value);
|
2018-02-27 18:06:05 +01:00
|
|
|
pos += value.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (any_empty) *any_empty = empty;
|
|
|
|
return block;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
QString value;
|
|
|
|
|
|
|
|
if (tag == "title")
|
|
|
|
value = song.title();
|
|
|
|
else if (tag == "album")
|
|
|
|
value = song.album();
|
|
|
|
else if (tag == "artist")
|
|
|
|
value = song.artist();
|
|
|
|
else if (tag == "composer")
|
|
|
|
value = song.composer();
|
|
|
|
else if (tag == "performer")
|
|
|
|
value = song.performer();
|
|
|
|
else if (tag == "grouping")
|
|
|
|
value = song.grouping();
|
2018-09-06 20:04:29 +02:00
|
|
|
else if (tag == "lyrics")
|
|
|
|
value = song.lyrics();
|
2018-02-27 18:06:05 +01:00
|
|
|
else if (tag == "genre")
|
|
|
|
value = song.genre();
|
|
|
|
else if (tag == "comment")
|
|
|
|
value = song.comment();
|
|
|
|
else if (tag == "year")
|
|
|
|
value = QString::number(song.year());
|
|
|
|
else if (tag == "originalyear")
|
|
|
|
value = QString::number(song.effective_originalyear());
|
|
|
|
else if (tag == "track")
|
|
|
|
value = QString::number(song.track());
|
|
|
|
else if (tag == "disc")
|
|
|
|
value = QString::number(song.disc());
|
|
|
|
else if (tag == "length")
|
|
|
|
value = QString::number(song.length_nanosec() / kNsecPerSec);
|
|
|
|
else if (tag == "bitrate")
|
|
|
|
value = QString::number(song.bitrate());
|
2020-04-09 18:14:02 +02:00
|
|
|
else if (tag == "samplerate")
|
|
|
|
value = QString::number(song.samplerate());
|
|
|
|
else if (tag == "bitdepth")
|
|
|
|
value = QString::number(song.bitdepth());
|
2018-02-27 18:06:05 +01:00
|
|
|
else if (tag == "extension")
|
|
|
|
value = QFileInfo(song.url().toLocalFile()).suffix();
|
|
|
|
else if (tag == "artistinitial") {
|
|
|
|
value = song.effective_albumartist().trimmed();
|
2018-12-29 15:37:16 +01:00
|
|
|
if (!value.isEmpty()) {
|
2020-07-18 04:05:07 +02:00
|
|
|
value.replace(QRegularExpression("^the\\s+", QRegularExpression::CaseInsensitiveOption), "");
|
2018-12-29 15:37:16 +01:00
|
|
|
value = value[0].toUpper();
|
|
|
|
}
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
else if (tag == "albumartist") {
|
|
|
|
value = song.is_compilation() ? "Various Artists" : song.effective_albumartist();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value == "0" || value == "-1") value = "";
|
|
|
|
|
|
|
|
// Prepend a 0 to single-digit track numbers
|
|
|
|
if (tag == "track" && value.length() == 1) value.prepend('0');
|
|
|
|
|
|
|
|
// Replace characters that really shouldn't be in paths
|
2020-04-09 18:14:02 +02:00
|
|
|
value = value.remove(kInvalidDirCharacters);
|
2020-04-09 19:59:31 +02:00
|
|
|
if (remove_problematic_) value = value.remove('.');
|
2020-04-09 18:14:02 +02:00
|
|
|
value = value.trimmed();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
return value;
|
2018-12-29 15:37:16 +01:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
OrganizeFormat::Validator::Validator(QObject *parent) : QValidator(parent) {}
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) const {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-07-20 00:57:42 +02:00
|
|
|
QRegularExpression tag_regexp(kTagPattern);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// Make sure all the blocks match up
|
|
|
|
int block_level = 0;
|
|
|
|
for (int i = 0; i < input.length(); ++i) {
|
|
|
|
if (input[i] == '{')
|
|
|
|
block_level++;
|
|
|
|
else if (input[i] == '}')
|
|
|
|
block_level--;
|
|
|
|
|
|
|
|
if (block_level < 0 || block_level > 1) return QValidator::Invalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (block_level != 0) return QValidator::Invalid;
|
|
|
|
|
|
|
|
// Make sure the tags are valid
|
2020-07-20 00:57:42 +02:00
|
|
|
QRegularExpressionMatch re_match;
|
2018-02-27 18:06:05 +01:00
|
|
|
int pos = 0;
|
2020-07-20 00:57:42 +02:00
|
|
|
for (re_match = tag_regexp.match(input, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(input, pos)) {
|
|
|
|
pos = re_match.capturedStart();
|
2020-08-04 21:18:14 +02:00
|
|
|
if (!OrganizeFormat::kKnownTags.contains(re_match.captured(1)))
|
2018-02-27 18:06:05 +01:00
|
|
|
return QValidator::Invalid;
|
|
|
|
|
2020-07-20 00:57:42 +02:00
|
|
|
pos += re_match.capturedLength();
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return QValidator::Acceptable;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QObject *parent)
|
2018-02-27 18:06:05 +01:00
|
|
|
: QSyntaxHighlighter(parent) {}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextEdit *parent)
|
2018-02-27 18:06:05 +01:00
|
|
|
: QSyntaxHighlighter(parent) {}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
OrganizeFormat::SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent)
|
2018-02-27 18:06:05 +01:00
|
|
|
: QSyntaxHighlighter(parent) {}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
const bool light = QApplication::palette().color(QPalette::Base).value() > 128;
|
|
|
|
const QRgb block_color = light ? kBlockColorLight : kBlockColorDark;
|
|
|
|
const QRgb valid_tag_color = light ? kValidTagColorLight : kValidTagColorDark;
|
|
|
|
const QRgb invalid_tag_color = light ? kInvalidTagColorLight : kInvalidTagColorDark;
|
|
|
|
|
2020-07-20 00:57:42 +02:00
|
|
|
QRegularExpression tag_regexp(kTagPattern);
|
|
|
|
QRegularExpression block_regexp(kBlockPattern);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
QTextCharFormat block_format;
|
|
|
|
block_format.setBackground(QColor(block_color));
|
|
|
|
|
|
|
|
// Reset formatting
|
|
|
|
setFormat(0, text.length(), QTextCharFormat());
|
|
|
|
|
|
|
|
// Blocks
|
2020-07-20 00:57:42 +02:00
|
|
|
QRegularExpressionMatch re_match;
|
2018-02-27 18:06:05 +01:00
|
|
|
int pos = 0;
|
2020-07-20 00:57:42 +02:00
|
|
|
for (re_match = block_regexp.match(text, pos) ; re_match.hasMatch() ; re_match = block_regexp.match(text, pos)) {
|
|
|
|
pos = re_match.capturedStart();
|
|
|
|
setFormat(pos, re_match.capturedLength(), block_format);
|
|
|
|
pos += re_match.capturedLength();
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tags
|
|
|
|
pos = 0;
|
2020-07-20 00:57:42 +02:00
|
|
|
for (re_match = tag_regexp.match(text, pos) ; re_match.hasMatch() ; re_match = tag_regexp.match(text, pos)) {
|
|
|
|
pos = re_match.capturedStart();
|
2018-02-27 18:06:05 +01:00
|
|
|
QTextCharFormat f = format(pos);
|
2020-08-04 21:18:14 +02:00
|
|
|
f.setForeground(QColor(OrganizeFormat::kKnownTags.contains(re_match.captured(1)) ? valid_tag_color : invalid_tag_color));
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-07-20 00:57:42 +02:00
|
|
|
setFormat(pos, re_match.capturedLength(), f);
|
|
|
|
pos += re_match.capturedLength();
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|