19 data.append(QString(
"[by: %1]\n[offset:0]\n").arg(
TTK_APP_NAME));
28 if(!file.open(QIODevice::WriteOnly))
33 QTextStream outstream(&file);
34 outstream.setCodec(
"UTF-8");
121 for(
const QString &oneLine :
qAsConst(data))
161 const QRegExp regx01(
"\\[\\d{2}:\\d{2}\\.\\d{3}\\]");
162 const QRegExp regx02(
"\\[\\d{2}:\\d{2}\\.\\d{2}\\]");
163 const QRegExp regx03(
"\\[\\d{2}:\\d{2}\\.\\d{1}\\]");
164 const QRegExp regx04(
"\\[\\d{2}:\\d{2}:\\d{3}\\]");
165 const QRegExp regx05(
"\\[\\d{2}:\\d{2}:\\d{2}\\]");
166 const QRegExp regx06(
"\\[\\d{2}:\\d{2}:\\d{1}\\]");
167 const QRegExp regx07(
"\\[\\d{2}:\\d{2}\\]");
168 const QRegExp regx08(
"\\[\\d{2}\\.\\d{2}\\.\\d{3}\\]");
169 const QRegExp regx09(
"\\[\\d{2}\\.\\d{2}\\.\\d{2}\\]");
170 const QRegExp regx10(
"\\[\\d{2}\\.\\d{2}\\.\\d{1}\\]");
171 const QRegExp regx11(
"\\[\\d{2}\\.\\d{2}:\\d{3}\\]");
172 const QRegExp regx12(
"\\[\\d{2}\\.\\d{2}:\\d{2}\\]");
173 const QRegExp regx13(
"\\[\\d{2}\\.\\d{2}:\\d{1}\\]");
174 const QRegExp regx14(
"\\[\\d{2}\\.\\d{2}\\]");
178 if(oneLine.contains(regx01))
183 else if(oneLine.contains(regx02))
188 else if(oneLine.contains(regx03))
193 else if(oneLine.contains(regx04))
198 else if(oneLine.contains(regx05))
203 else if(oneLine.contains(regx06))
208 else if(oneLine.contains(regx07))
213 else if(oneLine.contains(regx08))
218 else if(oneLine.contains(regx09))
223 else if(oneLine.contains(regx10))
228 else if(oneLine.contains(regx11))
233 else if(oneLine.contains(regx12))
238 else if(oneLine.contains(regx13))
249 QString temp = oneLine;
250 temp.replace(regx, {});
251 int pos = regx.indexIn(oneLine);
254 const QString &cap = regx.cap(0);
276 pos += regx.matchedLength();
277 pos = regx.indexIn(oneLine, pos);
284 regx.setPattern(first);
287 const int minutes = regx.cap(0).toInt();
288 regx.setPattern(second);
291 const int seconds = regx.cap(0).toInt();
292 regx.setPattern(third);
295 const int milliseconds = regx.cap(0).toInt();
296 const int length = QString::number(milliseconds).length();
297 const qint64 totalTime = minutes *
TTK_DN_M2MS + seconds *
TTK_DN_S2MS + milliseconds * pow(10, 3 - length);
304 regx.setPattern(first);
307 const int minutes = regx.cap(0).toInt();
308 regx.setPattern(second);
311 const int seconds = regx.cap(0).toInt();
320 const QStringList list(cap.split(splite));
321 if(list.count() != 3)
326 const int minutes = list[0].toInt();
327 const int seconds = list[1].toInt();
328 const int milliseconds = list[2].toInt();
329 const int length = QString::number(milliseconds).length();
330 const qint64 totalTime = minutes *
TTK_DN_M2MS + seconds *
TTK_DN_S2MS + milliseconds * pow(10, 3 - length);
337 qint64 beforeTime = 0;
343 beforeTime = keys[0];
346 for(
int i = 1; i < keys.count(); ++i)
349 const qint64 afterTime = keys[i];
350 if(beforeTime <= time && time <= afterTime)
355 beforeTime = afterTime;
370 copy.insert(it.key() + pos, it.value());
418 pre = last = QString();
446 interval = later - previous;
455 for(
int i = 0; i < index + 1; ++i)
void revertTime(qint64 pos)
virtual bool decode(const QString &input) overridefinal
const QByteArray & data() const noexcept
virtual bool decode(const QString &input) overridefinal
QStringList dataList() const
bool isValid() const noexcept
bool findText(qint64 current, qint64 total, QString &pre, QString &last, qint64 &interval) const
#define TTK_INFO_STREAM(msg)
QMap< qint64, QString > TTKIntStringMap
QString text(int index) const
The class of the krc to lrc.
virtual bool decode(const QString &input) overridefinal
qint64 setSongTimeSpeed(qint64 time)
State setData(const TTKIntStringMap &data)
qint64 findTime(int index) const
int lineMiddle() const noexcept
TTK_MODULE_EXPORT QStringList split(const QString &value, const QString &key=TTK_DEFAULT_STR)
#define QtNamespace(p)
Qt use namespace.
virtual bool decode(const QString &input) overridefinal
virtual bool decode(const QString &input) overridefinal
The class of the plain lrc.
TTKIntStringMap m_lrcContainer
MusicLrcAnalysis(QObject *parent=nullptr)
QString dataString() const
void matchLrcLine(const QString &oneLine)
State loadFromFile(const QString &path)
#define TTK_FILE_SUFFIX(fin)
The class of the trc to lrc.
bool isEmpty() const noexcept
The class of the qrc to lrc.
static QString toString(qint64 time, const QString &format) noexcept
The class of the yrc to lrc.
QStringList m_currentShowLrcContainer
QString m_currentFilePath
int count() const noexcept