In VerticalJournal::setModel and VerticalJournal::setDelegate:
if (!m_delegateModel) {
[...]
}
[...]
for (int i = 0; i < m_columnVisibleItems.count(); ++i)
{
[...]
}
coding style: Let's be consistent with the placement of {}.
Seeing that you have the same code snippet in two functions makes me think that you could at least have a cleanupExistingItems() helper function with that chunk of code:
for (int i = 0; i < m_columnVisibleItems.count(); ++i) { QList<ViewItem> &column = m_columnVisibleItems[i]; Q_FOREACH(const ViewItem &item, column) releaseItem(item); column.clear();
} m_indexColumnMap.clear();
---------------------------
"""
// Check if we add it to the bottom of existing column items
qreal columnToAddY = !m_columnVisibleItems[0].isEmpty() ? m_columnVisibleItems[0].last().y() + m_columnVisibleItems[0].last().height() : 0;
int columnToAddTo = 0;
for (int i = 1; i < m_columnVisibleItems.count(); ++i) {
const qreal iY = !m_columnVisibleItems[i].isEmpty() ? m_columnVisibleItems[i].last().y() + m_columnVisibleItems[i].last().height() : 0;
if (iY < columnToAddY) { columnToAddTo = i; columnToAddY = iY;
}
}
if (m_columnVisibleItems[columnToAddTo].isEmpty() || m_columnVisibleItems[columnToAddTo].last().m_modelIndex < modelIndex) {
"""
Long lines ahoy!
----------------------------
Any particular reason why you're calling m_columnVisibleItems.resize(nColumns) in componentComplete() right before calling polish()? Because updatePolish() already does the very same thing. Looks like this is either a redundant leftover that should be removed or a workaround for some obscure behavior which should then be explained with a comment (for the unware developer reading this code, like myself).
----------------------------
"""
* The first nColumns items are layouted at row 0 from column 0
* to column nColumns-1 in order. After that every new item
* is positioned in the column which provides the free topmost
* position as possible. If more than one column tie in providing
* the topmost free position the leftmost column will be used.
"""
In VerticalJournal ::setModel and VerticalJournal ::setDelegate:
if (!m_delegateModel) { Items.count( ); ++i)
[...]
}
[...]
for (int i = 0; i < m_columnVisible
{
[...]
}
coding style: Let's be consistent with the placement of {}.
Seeing that you have the same code snippet in two functions makes me think that you could at least have a cleanupExisting Items() helper function with that chunk of code:
for (int i = 0; i < m_columnVisible Items.count( ); ++i) {
QList< ViewItem> &column = m_columnVisible Items[i] ;
Q_ FOREACH( const ViewItem &item, column)
releaseItem( item);
column. clear() ;
m_indexColumnM ap.clear( );
}
------- ------- ------- ------
""" eItems[ 0].isEmpty( ) ? m_columnVisible Items[0] .last() .y() + m_columnVisible Items[0] .last() .height( ) : 0; Items.count( ); ++i) { eItems[ i].isEmpty( ) ? m_columnVisible Items[i] .last() .y() + m_columnVisible Items[i] .last() .height( ) : 0;
columnToAd dTo = i;
columnToAd dY = iY; eItems[ columnToAddTo] .isEmpty( ) || m_columnVisible Items[columnToA ddTo].last( ).m_modelIndex < modelIndex) {
// Check if we add it to the bottom of existing column items
qreal columnToAddY = !m_columnVisibl
int columnToAddTo = 0;
for (int i = 1; i < m_columnVisible
const qreal iY = !m_columnVisibl
if (iY < columnToAddY) {
}
}
if (m_columnVisibl
"""
Long lines ahoy!
------- ------- ------- -------
Any particular reason why you're calling m_columnVisible Items.resize( nColumns) in componentComplete() right before calling polish()? Because updatePolish() already does the very same thing. Looks like this is either a redundant leftover that should be removed or a workaround for some obscure behavior which should then be explained with a comment (for the unware developer reading this code, like myself).
------- ------- ------- -------
"""
* The first nColumns items are layouted at row 0 from column 0
* to column nColumns-1 in order. After that every new item
* is positioned in the column which provides the free topmost
* position as possible. If more than one column tie in providing
* the topmost free position the leftmost column will be used.
"""
Got some ASCII art for you!
+-----+ +-----+ +-----+
| | | 2 | | |
| | | | | |
| 1 | +-----+ | 3 |
| | +-----+ | |
| | | | +-----+
+-----+ | 4 | +-----+
+-----+ | | | 5 |
| 6 | +-----+ | |
| | +-----+
+-----+
------- ------- ------- -------
void VerticalJournal ::updatePolish( ) htDirty) {
{
[...]
if (m_implicitHeig
[...]
}
}
Could be refactored to
void VerticalJournal ::updatePolish( ) htDirty) {
calculateImpli citHeight( );
{
[...]
if (m_implicitHeig
}
}