summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-14 02:02:23 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-14 02:02:23 (GMT)
commit1fc80ab58fa069122f379f3cfddab32772ff0c8b (patch)
treebbccb5e244f349ed16dd956ae1e885cdf8915751
parentdd8fa351ce87be2b46243e5de641b9c104a024cc (diff)
Revert "Improve page breaks and batch up cursor edits in epub generator"
This broke the layouting. This reverts commit c110c65401a97877eb8b1cd3c6be04e2bdcbc5ec.
-rw-r--r--generators/epub/converter.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp
index 5ec1d32..9b28323 100644
--- a/generators/epub/converter.cpp
+++ b/generators/epub/converter.cpp
@@ -175,7 +175,6 @@ QTextDocument* Converter::convert( const QString &fileName )
mTextDocument = newDocument;
QTextCursor *_cursor = new QTextCursor( mTextDocument );
- _cursor->beginEditBlock();
mLocalLinks.clear();
mSectionMap.clear();
@@ -347,21 +346,19 @@ QTextDocument* Converter::convert( const QString &fileName )
_handle_anchors(before, link);
- // Force a page break.
- // The new format will also clear the previous one,
+ const int page = mTextDocument->pageCount();
+
+ // it will clear the previous format
// useful when the last line had a bullet
- QTextBlockFormat pageBreak;
- pageBreak.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysAfter);
- _cursor->insertBlock(pageBreak);
+ _cursor->insertBlock(QTextBlockFormat());
+
+ while(mTextDocument->pageCount() == page)
+ _cursor->insertText(QStringLiteral("\n"));
}
} while (epub_it_get_next(it));
epub_free_iterator(it);
- // Clear the previous format
- // In particular, clear the last page break.
- _cursor->insertBlock(QTextBlockFormat());
-
// handle toc
struct titerator *tit;
@@ -400,8 +397,10 @@ QTextDocument* Converter::convert( const QString &fileName )
_handle_anchors(block, link);
}
- // start a new page.
- _cursor->block().blockFormat().setPageBreakPolicy(QTextFormat::PageBreak_AlwaysAfter);
+ // Start new file in a new page
+ int page = mTextDocument->pageCount();
+ while(mTextDocument->pageCount() == page)
+ _cursor->insertText(QStringLiteral("\n"));
}
free(data);
@@ -448,8 +447,6 @@ QTextDocument* Converter::convert( const QString &fileName )
}
}
- _cursor->endEditBlock();
-
delete _cursor;
return mTextDocument;