Skip to content

Commit

Permalink
fix simple text detection
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Oct 24, 2012
1 parent 763af76 commit d470cbd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion libmscore/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,23 @@ void Text::writeProperties(Xml& xml, bool writeText) const
}
}

//---------------------------------------------------------
// isSimpleText
// check if _doc can be converted to simple text
//---------------------------------------------------------

bool Text::isSimpleText() const
{
if (_doc->blockCount() > 1)
return false;
int n = 0;
QTextBlock b(_doc->firstBlock());
QTextBlock::iterator i(_doc->firstBlock().begin());
for (; !i.atEnd(); ++i)
++n;
return n <= 1;
}

//---------------------------------------------------------
// readProperties
//---------------------------------------------------------
Expand Down Expand Up @@ -477,7 +494,7 @@ bool Text::readProperties(const QDomElement& e)
if (_doc == 0)
createDoc();
_doc->setHtml(s);
if (_doc->blockCount() == 1) { // simple text?
if (isSimpleText()) {
QString s = _doc->toPlainText();
delete _doc;
_doc = 0;
Expand Down
1 change: 1 addition & 0 deletions libmscore/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Text : public SimpleText {
void createDoc();
void setUnstyledText(const QString& s);
void layoutEdit();
bool isSimpleText() const;

protected:
bool _editMode;
Expand Down

0 comments on commit d470cbd

Please sign in to comment.