Commit 916e422d authored by Laurent Montel's avatar Laurent Montel 😁

We need margin for make sure that we use blockquote

parent 96f10f43
......@@ -33,6 +33,69 @@ MarkupDirector::~MarkupDirector()
}
QTextFrame::iterator
MarkupDirector::processBlockContents(QTextFrame::iterator frameIt,
const QTextBlock &block)
{
//Same code as grantlee but interprete margin
auto blockFormat = block.blockFormat();
auto blockAlignment = blockFormat.alignment();
// TODO: decide when to use <h1> etc.
if (blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) {
m_builder->insertHorizontalRule();
if (!frameIt.atEnd())
return ++frameIt;
return frameIt;
}
auto it = block.begin();
// The beginning is the end. This is an empty block. Insert a newline and
// move
// on.
if (it.atEnd()) {
m_builder->addNewline();
if (!frameIt.atEnd())
return ++frameIt;
return frameIt;
}
// Don't have p tags inside li tags.
if (!block.textList()) {
//Laurent : we need this margin as it's necessary to show blockquote
// Don't instruct builders to use margins. The rich text widget doesn't
// have
// an action for them yet,
// So users can't edit them. See bug
// http://bugs.kde.org/show_bug.cgi?id=160600
m_builder->beginParagraph(
blockAlignment,
blockFormat.topMargin(),
blockFormat.bottomMargin(),
blockFormat.leftMargin(),
blockFormat.rightMargin()
);
}
while (!it.atEnd()) {
it = processFragment(it, it.fragment(), block.document());
}
// Don't have p tags inside li tags.
if (!block.textList()) {
m_builder->endParagraph();
}
if (!frameIt.atEnd())
return ++frameIt;
return frameIt;
}
QTextBlock::iterator
MarkupDirector::processFragment(QTextBlock::iterator it,
const QTextFragment &fragment,
......
......@@ -30,6 +30,8 @@ class MarkupDirector : public Grantlee::MarkupDirector
public:
explicit MarkupDirector(Grantlee::AbstractMarkupBuilder *builder);
~MarkupDirector() override;
QTextFrame::iterator processBlockContents(QTextFrame::iterator frameIt, const QTextBlock &block) override;
protected:
QTextBlock::iterator processFragment(QTextBlock::iterator it, const QTextFragment &fragment, const QTextDocument *doc) override;
};
......
......@@ -37,3 +37,18 @@ void PlainTextMarkupBuilder::beginParagraph(Qt::Alignment a, qreal top, qreal bo
//TODO
//qDebug() << " left " << left << right << bottom << top << a;
}
bool PlainTextMarkupBuilder::isQuoteBlock(qreal top, qreal bottom, qreal left, qreal right) const
{
/*
case Html_blockquote:
margin[QTextHtmlParser::MarginTop] = 12;
margin[QTextHtmlParser::MarginBottom] = 12;
margin[QTextHtmlParser::MarginLeft] = 40;
margin[QTextHtmlParser::MarginRight] = 40;
break;
*/
//TODO
return false;
}
......@@ -32,6 +32,8 @@ public:
PlainTextMarkupBuilder();
void beginParagraph(Qt::Alignment a, qreal top, qreal bottom, qreal left, qreal right) override;
private:
bool isQuoteBlock(qreal top, qreal bottom, qreal left, qreal right) const;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment