bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString* errorString)
{
    TrackExceptionState es;
    bool result = replaceWholeText(textNode, text, es);
    populateErrorString(es, errorString);
    return result;
}
예제 #2
0
bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString* errorString)
{
    ExceptionCode ec = 0;
    bool result = replaceWholeText(textNode, text, ec);
    populateErrorString(ec, errorString);
    return result;
}
예제 #3
0
파일: lrceditor.cpp 프로젝트: timxx/lyricsx
void LrcEditor::expandMarks()
{
	QByteArray strText = toPlainText().toLocal8Bit();
	if (strText.isEmpty())
		return ;

	LrcReader parser(strText, strText.length());
	parser.parse();

	QStringList newText;

	const LRC &lrc = parser.getLrc();
	generateTags(newText, lrc);

	const auto &lines = lrc.getLines();
	for (const auto &line : lines)
	{
		QString strLine = _makeTimeTag(line.time);
		strLine += QString::fromStdString(line.lyrics);

		newText << strLine;
	}

	replaceWholeText(newText.join(m_charNewLine));
}
예제 #4
0
파일: lrceditor.cpp 프로젝트: timxx/lyricsx
void LrcEditor::removeAllMarks()
{
	QString strText = toPlainText();

	strText.remove(QRegExp( "\\[\\d+:\\d+\\.\\d+\\]" ));

	replaceWholeText(strText);
}
예제 #5
0
파일: lrceditor.cpp 프로젝트: timxx/lyricsx
void LrcEditor::mergeLyrics()
{
	QByteArray strText = toPlainText().toLocal8Bit();
	if (strText.isEmpty())
		return ;

	LrcReader parser(strText, strText.length());
	parser.parse();

	QStringList newText;

	const LRC &lrc = parser.getLrc();
	generateTags(newText, lrc);

	struct Line
	{
		std::string lyrics;
		std::vector<int> times;

		Line(const LRC::Line &line)
		{
			lyrics = line.lyrics;
			times.push_back(line.time);
		}
	};

	std::vector<Line> sortedLines;

	const auto &lines = lrc.getLines();
	// merge the same lyrics
	for (const auto &line : lines)
	{
		auto it = sortedLines.begin();
		for ( ; it != sortedLines.end(); ++it)
		{
			if (it->lyrics == line.lyrics)
				break;
		}

		if (it != sortedLines.end())
			it->times.push_back(line.time);
		else
			sortedLines.push_back(Line(line));
	}

	// sort by time
	std::sort(sortedLines.begin(), sortedLines.end(), [](Line &rhl, Line &rhs)
	{
		Q_ASSERT(rhl.times.size() > 0 && rhs.times.size() > 0);

		std::sort(rhl.times.begin(), rhl.times.end(), std::greater<int>());
		std::sort(rhs.times.begin(), rhs.times.end(), std::greater<int>());

		return rhl.times.back() < rhs.times.back();
	});

	for (const auto &line : sortedLines)
	{
		QString strLine;
		for (auto time : line.times)
		{
			strLine += _makeTimeTag(time);
		}
		strLine += QString::fromStdString(line.lyrics);

		newText << strLine;
	}

	replaceWholeText(newText.join(m_charNewLine));
}