summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-10-02 12:19:11 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-10-10 21:08:08 +0200
commitf1dd6addda908185f497d299d706b88977dea858 (patch)
tree1dff6f7093bb22c4c6c62ae5a374934ef634aa9a
parenta6ece9e88a3b227b7359d85d2641e9aab9be1c7b (diff)
Make QTextBlockFormat::MarkerType an enum class
This came up during API review. Change-Id: I9198e1eb96db0c21e46a226a032919bb62d3ca66 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp12
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp2
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp4
-rw-r--r--src/gui/text/qtextformat.h2
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp6
-rw-r--r--src/gui/text/qtextmarkdownimporter_p.h2
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp4
-rw-r--r--src/widgets/widgets/qtextedit.cpp2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp8
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp2
10 files changed, 22 insertions, 22 deletions
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index 996bb8e0a4..85fb83ab89 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -640,7 +640,7 @@ void TextEdit::textStyle(int styleIndex)
{
QTextCursor cursor = textEdit->textCursor();
QTextListFormat::Style style = QTextListFormat::ListStyleUndefined;
- QTextBlockFormat::MarkerType marker = QTextBlockFormat::NoMarker;
+ QTextBlockFormat::MarkerType marker = QTextBlockFormat::MarkerType::NoMarker;
switch (styleIndex) {
case 1:
@@ -657,14 +657,14 @@ void TextEdit::textStyle(int styleIndex)
style = cursor.currentList()->format().style();
else
style = QTextListFormat::ListDisc;
- marker = QTextBlockFormat::Unchecked;
+ marker = QTextBlockFormat::MarkerType::Unchecked;
break;
case 5:
if (cursor.currentList())
style = cursor.currentList()->format().style();
else
style = QTextListFormat::ListDisc;
- marker = QTextBlockFormat::Checked;
+ marker = QTextBlockFormat::MarkerType::Checked;
break;
case 6:
style = QTextListFormat::ListDecimal;
@@ -823,14 +823,14 @@ void TextEdit::cursorPositionChanged()
break;
}
switch (textEdit->textCursor().block().blockFormat().marker()) {
- case QTextBlockFormat::NoMarker:
+ case QTextBlockFormat::MarkerType::NoMarker:
actionToggleCheckState->setChecked(false);
break;
- case QTextBlockFormat::Unchecked:
+ case QTextBlockFormat::MarkerType::Unchecked:
comboStyle->setCurrentIndex(4);
actionToggleCheckState->setChecked(false);
break;
- case QTextBlockFormat::Checked:
+ case QTextBlockFormat::MarkerType::Checked:
comboStyle->setCurrentIndex(5);
actionToggleCheckState->setChecked(true);
break;
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 5263ece87c..8b8f3e28ac 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -660,7 +660,7 @@ QTextBlock QAbstractTextDocumentLayout::blockWithMarkerAt(const QPointF &pos) co
{
QTextBlock block = document()->firstBlock();
while (block.isValid()) {
- if (block.blockFormat().marker() != QTextBlockFormat::NoMarker) {
+ if (block.blockFormat().marker() != QTextBlockFormat::MarkerType::NoMarker) {
QRectF blockBr = blockBoundingRect(block);
QTextBlockFormat blockFmt = block.blockFormat();
QFontMetrics fm(block.charFormat().font());
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 1d5afee16b..7be114adf9 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -2194,11 +2194,11 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
QBrush brush = context.palette.brush(QPalette::Text);
- bool marker = bl.blockFormat().marker() != QTextBlockFormat::NoMarker;
+ bool marker = bl.blockFormat().marker() != QTextBlockFormat::MarkerType::NoMarker;
if (marker) {
int adj = fontMetrics.lineSpacing() / 6;
r.adjust(-adj, 0, -adj, 0);
- if (bl.blockFormat().marker() == QTextBlockFormat::Checked) {
+ if (bl.blockFormat().marker() == QTextBlockFormat::MarkerType::Checked) {
// ### Qt6: render with QStyle / PE_IndicatorCheckBox. We don't currently
// have access to that here, because it would be a widget dependency.
painter->setPen(QPen(painter->pen().color(), 2));
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index 12f14a1555..28da0fe344 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -627,7 +627,7 @@ public:
LineDistanceHeight = 4
};
- enum MarkerType {
+ enum class MarkerType {
NoMarker = 0,
Unchecked = 1,
Checked = 2
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index b96263f5fc..fe7e422923 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -190,8 +190,8 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
m_listItem = true;
MD_BLOCK_LI_DETAIL *detail = static_cast<MD_BLOCK_LI_DETAIL *>(det);
m_markerType = detail->is_task ?
- (detail->task_mark == ' ' ? QTextBlockFormat::Unchecked : QTextBlockFormat::Checked) :
- QTextBlockFormat::NoMarker;
+ (detail->task_mark == ' ' ? QTextBlockFormat::MarkerType::Unchecked : QTextBlockFormat::MarkerType::Checked) :
+ QTextBlockFormat::MarkerType::NoMarker;
qCDebug(lcMD) << "LI";
} break;
case MD_BLOCK_UL: {
@@ -549,7 +549,7 @@ void QTextMarkdownImporter::insertBlock()
blockFormat.setTopMargin(m_paragraphMargin);
blockFormat.setBottomMargin(m_paragraphMargin);
}
- if (m_markerType == QTextBlockFormat::NoMarker)
+ if (m_markerType == QTextBlockFormat::MarkerType::NoMarker)
blockFormat.clearProperty(QTextFormat::BlockMarker);
else
blockFormat.setMarker(m_markerType);
diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h
index 1b8c2ca354..35655aff8a 100644
--- a/src/gui/text/qtextmarkdownimporter_p.h
+++ b/src/gui/text/qtextmarkdownimporter_p.h
@@ -128,7 +128,7 @@ private:
Features m_features;
QTextImageFormat m_imageFormat;
QTextListFormat m_listFormat;
- QTextBlockFormat::MarkerType m_markerType = QTextBlockFormat::NoMarker;
+ QTextBlockFormat::MarkerType m_markerType = QTextBlockFormat::MarkerType::NoMarker;
bool m_needsInsertBlock = false;
bool m_needsInsertList = false;
bool m_listItem = false; // true from the beginning of LI to the end of the first P
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index cbfb092485..764c64aead 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -327,10 +327,10 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
break;
}
switch (blockFmt.marker()) {
- case QTextBlockFormat::Checked:
+ case QTextBlockFormat::MarkerType::Checked:
bullet += " [x]";
break;
- case QTextBlockFormat::Unchecked:
+ case QTextBlockFormat::MarkerType::Unchecked:
bullet += " [ ]";
break;
default:
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 0702603648..dd2ea3f18f 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -237,7 +237,7 @@ void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block)
Qt::CursorShape cursor = cursorToRestoreAfterHover;
if (block.isValid() && !q->isReadOnly()) {
QTextBlockFormat::MarkerType marker = block.blockFormat().marker();
- if (marker != QTextBlockFormat::NoMarker) {
+ if (marker != QTextBlockFormat::MarkerType::NoMarker) {
if (viewport->cursor().shape() != Qt::PointingHandCursor)
cursorToRestoreAfterHover = viewport->cursor().shape();
cursor = Qt::PointingHandCursor;
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index fdbaf29dd8..094c59a0c9 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1810,11 +1810,11 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but
if (markerBlock == blockWithMarkerUnderMouse) {
auto fmt = blockWithMarkerUnderMouse.blockFormat();
switch (fmt.marker()) {
- case QTextBlockFormat::Unchecked :
- fmt.setMarker(QTextBlockFormat::Checked);
+ case QTextBlockFormat::MarkerType::Unchecked :
+ fmt.setMarker(QTextBlockFormat::MarkerType::Checked);
break;
- case QTextBlockFormat::Checked:
- fmt.setMarker(QTextBlockFormat::Unchecked);
+ case QTextBlockFormat::MarkerType::Checked:
+ fmt.setMarker(QTextBlockFormat::MarkerType::Unchecked);
break;
default:
break;
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
index 8d38cbb18a..1e6c354f17 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
@@ -159,7 +159,7 @@ void tst_QTextMarkdownWriter::testWriteNestedBulletLists()
QTextCursor cursor(document);
QTextBlockFormat blockFmt = cursor.blockFormat();
if (checkbox) {
- blockFmt.setMarker(checked ? QTextBlockFormat::Checked : QTextBlockFormat::Unchecked);
+ blockFmt.setMarker(checked ? QTextBlockFormat::MarkerType::Checked : QTextBlockFormat::MarkerType::Unchecked);
cursor.setBlockFormat(blockFmt);
}