34 QVector<int> columnsForPage;
36 return columnsForPage;
37 const int numColumnsForPage = m_widths.count();
39 for (
int i = 0; i < numColumnsForPage; ++i) {
40 totalWidth += m_widths[i];
42 const qreal idealPageWidth = totalWidth / m_pages;
44 qreal currentWidth = 0;
45 columnsForPage.resize(m_pages);
46 int columnsInThisPage = 0;
48 for (
int i = 0; i < numColumnsForPage; ++i) {
49 const qreal columnWidth = m_widths[i];
50 const bool lastPage = pageNumber == m_pages - 1;
51 if (currentWidth + columnWidth > idealPageWidth && !lastPage) {
58 if (currentWidth + columnWidth < idealPageWidth * 4 / 3 || currentWidth == 0) {
59 columnsInThisPage += 1;
64 columnsForPage[pageNumber++] = columnsInThisPage;
67 columnsInThisPage = 0;
69 currentWidth += columnWidth;
70 columnsInThisPage += 1;
73 if (pageNumber < m_pages && columnsInThisPage > 0) {
74 columnsForPage[pageNumber++] = columnsInThisPage;
76 columnsForPage.resize(pageNumber);
77 #ifdef DEBUG_TABLEBREAKINGLOGIC
78 qDebug() <<
"Result of optimized table breaking:" << columnsForPage;
80 return columnsForPage;
85 Q_ASSERT(colPerPage.size() <= m_pages);
88 widths.resize(colPerPage.size());
89 for (
int page = 0; page < colPerPage.size(); ++page) {
90 const int numColumnsForPage = colPerPage[page];
91 qreal pageTotalWidth = 0;
92 for (
int i = startColumn; i < startColumn + numColumnsForPage; ++i) {
93 pageTotalWidth += m_widths[i];
95 startColumn += numColumnsForPage;
96 widths[page] = pageTotalWidth;
QVector< int > columnsPerPage() const
void setColumnWidths(const WidthVector &widths)
WidthVector widthPerPage(const QVector< int > &colPerPage) const
QVector< qreal > WidthVector
void setPageCount(int pages)