void KItemListHeaderWidget::setColumns(const QList<QByteArray>& roles)
{
- foreach (const QByteArray& role, roles) {
+ for (const QByteArray& role : roles) {
if (!m_columnWidths.contains(role)) {
m_preferredColumnWidths.remove(role);
}
qreal x = -m_offset;
int orderIndex = 0;
- foreach (const QByteArray& role, m_columns) {
+ for (const QByteArray& role : qAsConst(m_columns)) {
const qreal roleWidth = m_columnWidths.value(role);
const QRectF rect(x, 0, roleWidth, size().height());
paintRole(painter, role, rect, orderIndex, widget);
const Qt::SortOrder current = (m_model->sortOrder() == Qt::AscendingOrder) ?
Qt::DescendingOrder : Qt::AscendingOrder;
m_model->setSortOrder(current);
- emit sortOrderChanged(current, previous);
+ Q_EMIT sortOrderChanged(current, previous);
} else {
// Change the sort role and reset to the ascending order
const QByteArray previous = m_model->sortRole();
const QByteArray current = m_columns[m_pressedRoleIndex];
const bool resetSortOrder = m_model->sortOrder() == Qt::DescendingOrder;
m_model->setSortRole(current, !resetSortOrder);
- emit sortRoleChanged(current, previous);
+ Q_EMIT sortRoleChanged(current, previous);
if (resetSortOrder) {
m_model->setSortOrder(Qt::AscendingOrder);
- emit sortOrderChanged(Qt::AscendingOrder, Qt::DescendingOrder);
+ Q_EMIT sortOrderChanged(Qt::AscendingOrder, Qt::DescendingOrder);
}
}
break;
case ResizeRoleOperation: {
const QByteArray pressedRole = m_columns[m_pressedRoleIndex];
const qreal currentWidth = m_columnWidths.value(pressedRole);
- emit columnWidthChangeFinished(pressedRole, currentWidth);
+ Q_EMIT columnWidthChangeFinished(pressedRole, currentWidth);
break;
}
m_columnWidths.insert(pressedRole, currentWidth);
update();
- emit columnWidthChanged(pressedRole, currentWidth, previousWidth);
+ Q_EMIT columnWidthChanged(pressedRole, currentWidth, previousWidth);
break;
}
const QByteArray role = m_columns[m_movingRole.index];
const int previousIndex = m_movingRole.index;
m_movingRole.index = targetIndex;
- emit columnMoved(role, targetIndex, previousIndex);
+ Q_EMIT columnMoved(role, targetIndex, previousIndex);
m_movingRole.xDec = event->pos().x() - roleXPosition(role);
}
setColumnWidth(role, preferredColumnWidth(role));
qreal currentWidth = columnWidth(role);
- emit columnWidthChanged(role, currentWidth, previousWidth);
- emit columnWidthChangeFinished(role, currentWidth);
+ Q_EMIT columnWidthChanged(role, currentWidth, previousWidth);
+ Q_EMIT columnWidthChangeFinished(role, currentWidth);
}
}
int index = -1;
qreal x = -m_offset;
- foreach (const QByteArray& role, m_columns) {
+ for (const QByteArray& role : qAsConst(m_columns)) {
++index;
x += m_columnWidths.value(role);
if (pos.x() <= x) {
qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
{
qreal x = -m_offset;
- foreach (const QByteArray& visibleRole, m_columns) {
+ for (const QByteArray& visibleRole : qAsConst(m_columns)) {
if (visibleRole == role) {
return x;
}