style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
QTextDocument *MakeDoc(const QString &plain_text)
|
||||
QTextDocument *make_doc(const QString &plain_text)
|
||||
{
|
||||
auto *doc = new QTextDocument();
|
||||
QTextCursor c(doc);
|
||||
@@ -17,7 +17,7 @@ QTextDocument *MakeDoc(const QString &plain_text)
|
||||
}
|
||||
|
||||
// Extract the single fragment of a single-block document for format checks.
|
||||
QTextFragment OnlyFragment(QTextDocument *doc)
|
||||
QTextFragment only_fragment(QTextDocument *doc)
|
||||
{
|
||||
QTextBlock block = doc->begin();
|
||||
auto it = block.begin();
|
||||
@@ -29,9 +29,9 @@ QTextFragment OnlyFragment(QTextDocument *doc)
|
||||
|
||||
TEST(CommonHtml, DocToHtmlWrapsTextInParagraph)
|
||||
{
|
||||
std::unique_ptr<QTextDocument> doc(MakeDoc(QStringLiteral("hello")));
|
||||
std::unique_ptr<QTextDocument> doc(make_doc(QStringLiteral("hello")));
|
||||
|
||||
const QString html = olive::Html::DocToHtml(doc.get());
|
||||
const QString html = olive::Html::doc_to_html(doc.get());
|
||||
|
||||
EXPECT_TRUE(html.contains(QStringLiteral("<p")));
|
||||
EXPECT_TRUE(html.contains(QStringLiteral("hello")));
|
||||
@@ -40,9 +40,9 @@ TEST(CommonHtml, DocToHtmlWrapsTextInParagraph)
|
||||
|
||||
TEST(CommonHtml, DocToHtmlEscapesSpecialCharacters)
|
||||
{
|
||||
std::unique_ptr<QTextDocument> doc(MakeDoc(QStringLiteral("a<b>&\"c\"")));
|
||||
std::unique_ptr<QTextDocument> doc(make_doc(QStringLiteral("a<b>&\"c\"")));
|
||||
|
||||
const QString html = olive::Html::DocToHtml(doc.get());
|
||||
const QString html = olive::Html::doc_to_html(doc.get());
|
||||
|
||||
EXPECT_FALSE(html.contains(QStringLiteral("a<b>")));
|
||||
EXPECT_TRUE(html.contains(QStringLiteral("<")));
|
||||
@@ -58,7 +58,7 @@ TEST(CommonHtml, AlignmentIsWrittenAsAttribute)
|
||||
c.setBlockFormat(fmt);
|
||||
c.insertText(QStringLiteral("right"));
|
||||
|
||||
const QString html = olive::Html::DocToHtml(&doc);
|
||||
const QString html = olive::Html::doc_to_html(&doc);
|
||||
|
||||
EXPECT_TRUE(html.contains(QStringLiteral("align=\"right\"")));
|
||||
}
|
||||
@@ -72,7 +72,7 @@ TEST(CommonHtml, CenterAlignmentIsWrittenAsAttribute)
|
||||
c.setBlockFormat(fmt);
|
||||
c.insertText(QStringLiteral("center"));
|
||||
|
||||
const QString html = olive::Html::DocToHtml(&doc);
|
||||
const QString html = olive::Html::doc_to_html(&doc);
|
||||
|
||||
EXPECT_TRUE(html.contains(QStringLiteral("align=\"center\"")));
|
||||
}
|
||||
@@ -86,7 +86,7 @@ TEST(CommonHtml, LeftAlignmentWritesNoAlignAttribute)
|
||||
c.setBlockFormat(fmt);
|
||||
c.insertText(QStringLiteral("left"));
|
||||
|
||||
const QString html = olive::Html::DocToHtml(&doc);
|
||||
const QString html = olive::Html::doc_to_html(&doc);
|
||||
|
||||
EXPECT_FALSE(html.contains(QStringLiteral("align=")));
|
||||
}
|
||||
@@ -105,13 +105,13 @@ TEST(CommonHtml, CharFormatRoundTrip)
|
||||
fmt.setForeground(QColor(255, 0, 0));
|
||||
c.insertText(QStringLiteral("styled"), fmt);
|
||||
|
||||
const QString html = olive::Html::DocToHtml(&doc);
|
||||
const QString html = olive::Html::doc_to_html(&doc);
|
||||
|
||||
QTextDocument parsed;
|
||||
olive::Html::HtmlToDoc(&parsed, html);
|
||||
olive::Html::html_to_doc(&parsed, html);
|
||||
|
||||
ASSERT_EQ(parsed.begin().text(), QStringLiteral("styled"));
|
||||
const QTextFragment frag = OnlyFragment(&parsed);
|
||||
const QTextFragment frag = only_fragment(&parsed);
|
||||
const QTextCharFormat &out = frag.charFormat();
|
||||
EXPECT_EQ(out.fontWeight(), QFont::Bold);
|
||||
EXPECT_TRUE(out.fontItalic());
|
||||
@@ -131,13 +131,13 @@ TEST(CommonHtml, ColorWithAlphaRoundTripsAsRgba)
|
||||
fmt.setForeground(semi);
|
||||
c.insertText(QStringLiteral("x"), fmt);
|
||||
|
||||
const QString html = olive::Html::DocToHtml(&doc);
|
||||
const QString html = olive::Html::doc_to_html(&doc);
|
||||
EXPECT_TRUE(html.contains(QStringLiteral("rgba(")));
|
||||
|
||||
QTextDocument parsed;
|
||||
olive::Html::HtmlToDoc(&parsed, html);
|
||||
olive::Html::html_to_doc(&parsed, html);
|
||||
|
||||
const QTextFragment frag = OnlyFragment(&parsed);
|
||||
const QTextFragment frag = only_fragment(&parsed);
|
||||
const QColor out = frag.charFormat().foreground().color();
|
||||
EXPECT_EQ(out.red(), semi.red());
|
||||
EXPECT_EQ(out.green(), semi.green());
|
||||
@@ -155,7 +155,7 @@ TEST(CommonHtml, BlockAlignmentRoundTrips)
|
||||
c.insertText(QStringLiteral("centered"));
|
||||
|
||||
QTextDocument parsed;
|
||||
olive::Html::HtmlToDoc(&parsed, olive::Html::DocToHtml(&doc));
|
||||
olive::Html::html_to_doc(&parsed, olive::Html::doc_to_html(&doc));
|
||||
|
||||
EXPECT_TRUE(parsed.begin().blockFormat().alignment() & Qt::AlignHCenter);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ TEST(CommonHtml, MultipleBlocksSurviveRoundTrip)
|
||||
c.insertText(QStringLiteral("second"));
|
||||
|
||||
QTextDocument parsed;
|
||||
olive::Html::HtmlToDoc(&parsed, olive::Html::DocToHtml(&doc));
|
||||
olive::Html::html_to_doc(&parsed, olive::Html::doc_to_html(&doc));
|
||||
|
||||
EXPECT_EQ(parsed.blockCount(), 2);
|
||||
EXPECT_EQ(parsed.begin().text(), QStringLiteral("first"));
|
||||
@@ -184,7 +184,7 @@ TEST(CommonHtml, LineSeparatorBecomesBr)
|
||||
c.insertText(QString(QChar(QChar::LineSeparator)) +
|
||||
QStringLiteral("line2"));
|
||||
|
||||
const QString html = olive::Html::DocToHtml(&doc);
|
||||
const QString html = olive::Html::doc_to_html(&doc);
|
||||
|
||||
EXPECT_TRUE(html.contains(QStringLiteral("<br/>")));
|
||||
}
|
||||
@@ -195,7 +195,7 @@ TEST(CommonHtml, HtmlToDocReplacesExistingContent)
|
||||
QTextCursor c(&doc);
|
||||
c.insertText(QStringLiteral("old content that should disappear"));
|
||||
|
||||
olive::Html::HtmlToDoc(&doc, QStringLiteral("<p>new</p>"));
|
||||
olive::Html::html_to_doc(&doc, QStringLiteral("<p>new</p>"));
|
||||
|
||||
EXPECT_EQ(doc.toPlainText().trimmed(), QStringLiteral("new"));
|
||||
}
|
||||
@@ -205,7 +205,7 @@ TEST(CommonHtml, HtmlToDocHandlesInvalidMarkupWithoutCrash)
|
||||
QTextDocument doc;
|
||||
|
||||
// Malformed markup must not crash; error is only logged.
|
||||
olive::Html::HtmlToDoc(&doc, QStringLiteral("<p>unclosed"));
|
||||
olive::Html::html_to_doc(&doc, QStringLiteral("<p>unclosed"));
|
||||
|
||||
SUCCEED();
|
||||
}
|
||||
@@ -213,7 +213,7 @@ TEST(CommonHtml, HtmlToDocHandlesInvalidMarkupWithoutCrash)
|
||||
TEST(CommonHtml, EmptyHtmlProducesEmptyDocument)
|
||||
{
|
||||
QTextDocument doc;
|
||||
olive::Html::HtmlToDoc(&doc, QString());
|
||||
olive::Html::html_to_doc(&doc, QString());
|
||||
|
||||
EXPECT_LE(doc.blockCount(), 1);
|
||||
EXPECT_TRUE(doc.toPlainText().trimmed().isEmpty());
|
||||
@@ -229,9 +229,9 @@ TEST(CommonHtml, LetterSpacingAndStretchRoundTrip)
|
||||
c.insertText(QStringLiteral("spaced"), fmt);
|
||||
|
||||
QTextDocument parsed;
|
||||
olive::Html::HtmlToDoc(&parsed, olive::Html::DocToHtml(&doc));
|
||||
olive::Html::html_to_doc(&parsed, olive::Html::doc_to_html(&doc));
|
||||
|
||||
const QTextFragment frag = OnlyFragment(&parsed);
|
||||
const QTextFragment frag = only_fragment(&parsed);
|
||||
EXPECT_DOUBLE_EQ(frag.charFormat().fontLetterSpacing(), 150.0);
|
||||
EXPECT_EQ(frag.charFormat().fontStretch(), 125);
|
||||
}
|
||||
@@ -239,12 +239,12 @@ TEST(CommonHtml, LetterSpacingAndStretchRoundTrip)
|
||||
TEST(CommonHtml, NestedInlineTagsMergeFormats)
|
||||
{
|
||||
QTextDocument doc;
|
||||
olive::Html::HtmlToDoc(
|
||||
olive::Html::html_to_doc(
|
||||
&doc, QStringLiteral(
|
||||
"<p><span style=\"font-weight: 600;\"><span "
|
||||
"style=\"font-style: italic;\">both</span></span></p>"));
|
||||
|
||||
const QTextFragment frag = OnlyFragment(&doc);
|
||||
const QTextFragment frag = only_fragment(&doc);
|
||||
EXPECT_TRUE(frag.charFormat().fontItalic());
|
||||
// CSS font-weight 600 maps to 75 on the legacy 0-99 Qt weight scale
|
||||
EXPECT_EQ(frag.charFormat().fontWeight(), 75);
|
||||
|
||||
Reference in New Issue
Block a user