40 QVector<int> columnsForPage;
42 return columnsForPage;
43 const int numColumnsForPage = m_widths.count();
45 for (
int i = 0; i < numColumnsForPage; ++i) {
46 totalWidth += m_widths[i];
48 const qreal idealPageWidth = totalWidth / m_pages;
50 qreal currentWidth = 0;
51 columnsForPage.resize(m_pages);
52 int columnsInThisPage = 0;
54 for (
int i = 0; i < numColumnsForPage; ++i) {
55 const qreal columnWidth = m_widths[i];
56 const bool lastPage = pageNumber == m_pages - 1;
57 if (currentWidth + columnWidth > idealPageWidth && !lastPage) {
64 if (currentWidth + columnWidth < idealPageWidth * 4 / 3 || currentWidth == 0) {
65 columnsInThisPage += 1;
70 columnsForPage[pageNumber++] = columnsInThisPage;
73 columnsInThisPage = 0;
75 currentWidth += columnWidth;
76 columnsInThisPage += 1;
79 if (pageNumber < m_pages && columnsInThisPage > 0) {
80 columnsForPage[pageNumber++] = columnsInThisPage;
82 columnsForPage.resize(pageNumber);
83 #ifdef DEBUG_TABLEBREAKINGLOGIC
84 qDebug() <<
"Result of optimized table breaking:" << columnsForPage;
86 return columnsForPage;
91 Q_ASSERT(colPerPage.size() <= m_pages);
94 widths.resize(colPerPage.size());
95 for (
int page = 0; page < colPerPage.size(); ++page) {
96 const int numColumnsForPage = colPerPage[page];
97 qreal pageTotalWidth = 0;
98 for (
int i = startColumn; i < startColumn + numColumnsForPage; ++i) {
99 pageTotalWidth += m_widths[i];
101 startColumn += numColumnsForPage;
102 widths[page] = pageTotalWidth;