each item. Additional columns can be added by clicking a column header with the
&RMB;.
</para>
-<para>In the context menu of the header line, you can add or remove the padding from the
-leading column by checking or unchecking the respective menu item and choose between a custom
+<para>In the context menu of the header line, you can add or remove side padding
+by checking or unchecking the respective menu item and choose between a custom
or automatic column width. Automatic width adjusts the width of all columns once to display the
longest item in the column completely, except for the <guilabel>Name</guilabel> column where
the extension is replaced by <quote>...</quote>
settings/dolphin_versioncontrolsettings.kcfg
DESTINATION ${KDE_INSTALL_KCFGDIR} )
+install( FILES settings/dolphin_detailsmodesettings.upd
+ DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR} )
+
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
return m_headerWidget->preferredColumnWidth(role);
}
-void KItemListHeader::setLeadingPadding(qreal width){
- if (m_headerWidget->leadingPadding() != width) {
- m_headerWidget->setLeadingPadding(width);
+void KItemListHeader::setSidePadding(qreal width){
+ if (m_headerWidget->sidePadding() != width) {
+ m_headerWidget->setSidePadding(width);
if (m_headerWidget->automaticColumnResizing()) {
m_view->applyAutomaticColumnWidths();
}
}
}
-qreal KItemListHeader::leadingPadding() const{
- return m_headerWidget->leadingPadding();
+qreal KItemListHeader::sidePadding() const{
+ return m_headerWidget->sidePadding();
}
KItemListHeader::KItemListHeader(KItemListView* listView) :
this, &KItemListHeader::columnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChangeFinished,
this, &KItemListHeader::columnWidthChangeFinished);
- connect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
- this, &KItemListHeader::leadingPaddingChanged);
+ connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
+ this, &KItemListHeader::sidePaddingChanged);
}
* Sets the width of the column *before* the first column.
* This is intended to facilitate an empty region for deselection in the main viewport.
*/
- void setLeadingPadding(qreal width);
- qreal leadingPadding() const;
+ void setSidePadding(qreal width);
+ qreal sidePadding() const;
Q_SIGNALS:
- void leadingPaddingChanged(qreal width);
+ void sidePaddingChanged(qreal width);
/**
* Is emitted if the width of a column has been adjusted by the user with the mouse
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
- connect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
- this, &KItemListView::slotLeadingPaddingChanged);
+ connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
+ this, &KItemListView::slotSidePaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
} else if (!visible && m_headerWidget->isVisible()) {
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
- disconnect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
- this, &KItemListView::slotLeadingPaddingChanged);
+ disconnect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
+ this, &KItemListView::slotSidePaddingChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
doLayout(NoAnimation);
}
-void KItemListView::slotLeadingPaddingChanged(qreal width)
+void KItemListView::slotSidePaddingChanged(qreal width)
{
Q_UNUSED(width)
if (m_headerWidget->automaticColumnResizing()) {
void KItemListView::applyColumnWidthsFromHeader()
{
// Apply the new size to the layouter
- const qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding();
+ const qreal requiredWidth = columnWidthsSum() + m_headerWidget->sidePadding();
const QSizeF dynamicItemSize(qMax(size().width(), requiredWidth),
m_itemSize.height());
m_layouter->setItemSize(dynamicItemSize);
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
widget->setColumnWidth(role, m_headerWidget->columnWidth(role));
}
- widget->setLeadingPadding(m_headerWidget->leadingPadding());
+ widget->setSidePadding(m_headerWidget->sidePadding());
}
void KItemListView::updatePreferredColumnWidths(const KItemRangeList& itemRanges)
qreal firstColumnWidth = m_headerWidget->columnWidth(firstRole);
QSizeF dynamicItemSize = m_itemSize;
- qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding()
- + m_headerWidget->leadingPadding(); // Adding the padding a second time so we have the same padding symmetrically on both sides of the view.
+ qreal requiredWidth = columnWidthsSum() + m_headerWidget->sidePadding()
+ + m_headerWidget->sidePadding(); // Adding the padding a second time so we have the same padding symmetrically on both sides of the view.
// This improves UX, looks better and increases the chances of users figuring out that the padding area can be used for deselecting and dropping files.
const qreal availableWidth = size().width();
if (requiredWidth < availableWidth) {
qreal currentWidth,
qreal previousWidth);
- void slotLeadingPaddingChanged(qreal width);
+ void slotSidePaddingChanged(qreal width);
/**
* Is invoked if a column has been moved by the user. Applies
return m_columnWidths.value(role);
}
-qreal KItemListWidget::leadingPadding() const {
- return m_leadingPadding;
+qreal KItemListWidget::sidePadding() const {
+ return m_sidePadding;
}
-void KItemListWidget::setLeadingPadding(qreal width) {
- if (m_leadingPadding != width){
- m_leadingPadding = width;
- leadingPaddingChanged(width);
+void KItemListWidget::setSidePadding(qreal width) {
+ if (m_sidePadding != width){
+ m_sidePadding = width;
+ sidePaddingChanged(width);
update();
}
}
Q_UNUSED(previous)
}
-void KItemListWidget::leadingPaddingChanged(qreal width)
+void KItemListWidget::sidePaddingChanged(qreal width)
{
Q_UNUSED(width)
}
void setColumnWidth(const QByteArray& role, qreal width);
qreal columnWidth(const QByteArray& role) const;
- void setLeadingPadding(qreal width);
- qreal leadingPadding() const;
+ void setSidePadding(qreal width);
+ qreal sidePadding() const;
void setStyleOption(const KItemListStyleOption& option);
const KItemListStyleOption& styleOption() const;
virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
- virtual void leadingPaddingChanged(qreal width);
+ virtual void sidePaddingChanged(qreal width);
virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
virtual void currentChanged(bool current);
virtual void selectedChanged(bool selected);
QHash<QByteArray, QVariant> m_data;
QList<QByteArray> m_visibleRoles;
QHash<QByteArray, qreal> m_columnWidths;
- qreal m_leadingPadding;
+ qreal m_sidePadding;
KItemListStyleOption m_styleOption;
QBitArray m_siblingsInfo;
QRectF adjustedIconRect = iconRect().adjusted(-padding, -padding, padding, padding);
QRectF result = adjustedIconRect | m_textRect;
if (m_highlightEntireRow) {
- result.setRight(m_columnWidthSum + leadingPadding());
+ result.setRight(m_columnWidthSum + sidePadding());
}
return result;
}
m_dirtyLayout = true;
}
-void KStandardItemListWidget::leadingPaddingChanged(qreal padding) {
+void KStandardItemListWidget::sidePaddingChanged(qreal padding) {
Q_UNUSED(padding)
m_dirtyLayout = true;
}
const qreal inc = (widgetHeight - widgetIconSize) / 2;
const qreal x = expandedParentsCount * widgetHeight + inc;
const qreal y = inc;
- const qreal xPadding = m_highlightEntireRow ? leadingPadding() : 0;
+ const qreal xPadding = m_highlightEntireRow ? sidePadding() : 0;
m_expansionArea = QRectF(xPadding + x, y, widgetIconSize, widgetIconSize);
return;
}
if (m_supportsItemExpanding) {
firstColumnInc += (m_expansionArea.left() + m_expansionArea.right() + widgetHeight) / 2;
} else {
- firstColumnInc += option.padding + leadingPadding();
+ firstColumnInc += option.padding + sidePadding();
}
qreal x = firstColumnInc;
const bool isTextRole = (role == "text");
if (isTextRole) {
- availableTextWidth -= firstColumnInc - leadingPadding();
+ availableTextWidth -= firstColumnInc - sidePadding();
}
if (requiredWidth > availableTextWidth) {
// The column after the name should always be aligned on the same x-position independent
// from the expansion-level shown in the name column
- x -= firstColumnInc - leadingPadding();
+ x -= firstColumnInc - sidePadding();
} else if (isRoleRightAligned(role)) {
textInfo->pos.rx() += roleWidth - requiredWidth - columnWidthInc;
}
void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>()) override;
void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) override;
void columnWidthChanged(const QByteArray& role, qreal current, qreal previous) override;
- void leadingPaddingChanged(qreal width) override;
+ void sidePaddingChanged(qreal width) override;
void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) override;
void hoveredChanged(bool hovered) override;
void selectedChanged(bool selected) override;
m_automaticColumnResizing(true),
m_model(nullptr),
m_offset(0),
- m_leadingPadding(0),
+ m_sidePadding(0),
m_columns(),
m_columnWidths(),
m_preferredColumnWidths(),
return m_offset;
}
-void KItemListHeaderWidget::setLeadingPadding(qreal width)
+void KItemListHeaderWidget::setSidePadding(qreal width)
{
- if (m_leadingPadding != width) {
- m_leadingPadding = width;
- leadingPaddingChanged(width);
+ if (m_sidePadding != width) {
+ m_sidePadding = width;
+ sidePaddingChanged(width);
update();
}
}
-qreal KItemListHeaderWidget::leadingPadding() const
+qreal KItemListHeaderWidget::sidePadding() const
{
- return m_leadingPadding;
+ return m_sidePadding;
}
qreal KItemListHeaderWidget::minimumColumnWidth() const
painter->setFont(font());
painter->setPen(palette().text().color());
- qreal x = -m_offset + m_leadingPadding;
+ qreal x = -m_offset + m_sidePadding;
int orderIndex = 0;
for (const QByteArray& role : qAsConst(m_columns)) {
const qreal roleWidth = m_columnWidths.value(role);
if (event->button() & Qt::LeftButton) {
m_pressedMousePos = event->pos();
if (isAbovePaddingGrip(m_pressedMousePos, PaddingGrip::Leading)) {
- m_roleOperation = ResizeLeadingColumnOperation;
+ m_roleOperation = ResizePaddingColumnOperation;
} else {
updatePressedRoleIndex(event->pos());
m_roleOperation = isAboveRoleGrip(m_pressedMousePos, m_pressedRoleIndex) ?
} else {
m_movingRole.pixmap = createRolePixmap(roleIndex);
- qreal roleX = -m_offset + m_leadingPadding;
+ qreal roleX = -m_offset + m_sidePadding;
for (int i = 0; i < roleIndex; ++i) {
const QByteArray role = m_columns[i];
roleX += m_columnWidths.value(role);
break;
}
- case ResizeLeadingColumnOperation: {
- qreal currentWidth = m_leadingPadding;
+ case ResizePaddingColumnOperation: {
+ qreal currentWidth = m_sidePadding;
currentWidth += event->pos().x() - event->lastPos().x();
currentWidth = qMax(0.0, currentWidth);
- m_leadingPadding = currentWidth;
+ m_sidePadding = currentWidth;
update();
- Q_EMIT leadingPaddingChanged(currentWidth);
+ Q_EMIT sidePaddingChanged(currentWidth);
break;
}
{
int index = -1;
- qreal x = -m_offset + m_leadingPadding;
+ qreal x = -m_offset + m_sidePadding;
for (const QByteArray& role : qAsConst(m_columns)) {
++index;
x += m_columnWidths.value(role);
bool KItemListHeaderWidget::isAboveRoleGrip(const QPointF& pos, int roleIndex) const
{
- qreal x = -m_offset + m_leadingPadding;
+ qreal x = -m_offset + m_sidePadding;
for (int i = 0; i <= roleIndex; ++i) {
const QByteArray role = m_columns[i];
x += m_columnWidths.value(role);
bool KItemListHeaderWidget::isAbovePaddingGrip(const QPointF& pos, PaddingGrip paddingGrip) const
{
- const qreal lx = -m_offset + m_leadingPadding;
+ const qreal lx = -m_offset + m_sidePadding;
const int grip = style()->pixelMetric(QStyle::PM_HeaderGripMargin);
switch (paddingGrip) {
const int movingRight = movingLeft + movingWidth - 1;
int targetIndex = 0;
- qreal targetLeft = -m_offset + m_leadingPadding;
+ qreal targetLeft = -m_offset + m_sidePadding;
while (targetIndex < m_columns.count()) {
const QByteArray role = m_columns[targetIndex];
const qreal targetWidth = m_columnWidths.value(role);
qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
{
- qreal x = -m_offset + m_leadingPadding;
+ qreal x = -m_offset + m_sidePadding;
for (const QByteArray& visibleRole : qAsConst(m_columns)) {
if (visibleRole == role) {
return x;
void setOffset(qreal offset);
qreal offset() const;
- void setLeadingPadding(qreal width);
- qreal leadingPadding() const;
+ void setSidePadding(qreal width);
+ qreal sidePadding() const;
qreal minimumColumnWidth() const;
qreal currentWidth,
qreal previousWidth);
- void leadingPaddingChanged(qreal width);
+ void sidePaddingChanged(qreal width);
/**
* Is emitted if the user has released the mouse button after adjusting the
{
NoRoleOperation,
ResizeRoleOperation,
- ResizeLeadingColumnOperation,
+ ResizePaddingColumnOperation,
MoveRoleOperation
};
bool m_automaticColumnResizing;
KItemModelBase* m_model;
qreal m_offset;
- qreal m_leadingPadding;
+ qreal m_sidePadding;
QList<QByteArray> m_columns;
QHash<QByteArray, qreal> m_columnWidths;
QHash<QByteArray, qreal> m_preferredColumnWidths;
<label>Position of columns</label>
<default>0,1,2,3,4,5,6,7,8</default>
</entry>
- <entry name="LeadingPadding" type="UInt">
- <label>Leading Column Padding</label>
+ <entry name="SidePadding" type="UInt">
+ <label>Side Padding</label>
<default>20</default>
</entry>
<entry name="ExpandableFolders" type="Bool">
--- /dev/null
+#Configuration update for Dolphin
+Version=5
+
+#Rename LeadingPadding to SidePadding
+Id=rename-leading-padding
+File=dolphinrc
+Group=DetailsMode
+Key=LeadingPadding,SidePadding
\ No newline at end of file
beginTransaction();
setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
- setHighlightEntireRow(DetailsModeSettings::leadingPadding());
+ setHighlightEntireRow(DetailsModeSettings::sidePadding());
setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout()));
updateFont();
this, &DolphinView::slotRoleEditingCanceled);
connect(m_view->header(), &KItemListHeader::columnWidthChangeFinished,
this, &DolphinView::slotHeaderColumnWidthChangeFinished);
- connect(m_view->header(), &KItemListHeader::leadingPaddingChanged,
- this, &DolphinView::slotLeadingPaddingWidthChanged);
+ connect(m_view->header(), &KItemListHeader::sidePaddingChanged,
+ this, &DolphinView::slotSidePaddingWidthChanged);
KItemListSelectionManager* selectionManager = controller->selectionManager();
connect(selectionManager, &KItemListSelectionManager::selectionChanged,
QActionGroup* widthsGroup = new QActionGroup(menu);
const bool autoColumnWidths = props.headerColumnWidths().isEmpty();
- QAction* toggleLeadingPaddingAction = menu->addAction(i18nc("@action:inmenu", "Leading Column Padding"));
- toggleLeadingPaddingAction->setCheckable(true);
- toggleLeadingPaddingAction->setChecked(view->header()->leadingPadding() > 0);
+ QAction* toggleSidePaddingAction = menu->addAction(i18nc("@action:inmenu", "Side Padding"));
+ toggleSidePaddingAction->setCheckable(true);
+ toggleSidePaddingAction->setChecked(view->header()->sidePadding() > 0);
QAction* autoAdjustWidthsAction = menu->addAction(i18nc("@action:inmenu", "Automatic Column Widths"));
autoAdjustWidthsAction->setCheckable(true);
}
props.setHeaderColumnWidths(columnWidths);
header->setAutomaticColumnResizing(false);
- } else if (action == toggleLeadingPaddingAction) {
- header->setLeadingPadding(toggleLeadingPaddingAction->isChecked() ? 20 : 0);
+ } else if (action == toggleSidePaddingAction) {
+ header->setSidePadding(toggleSidePaddingAction->isChecked() ? 20 : 0);
} else {
// Show or hide the selected role
const QByteArray selectedRole = action->data().toByteArray();
props.setHeaderColumnWidths(columnWidths);
}
-void DolphinView::slotLeadingPaddingWidthChanged(qreal width)
+void DolphinView::slotSidePaddingWidthChanged(qreal width)
{
ViewProperties props(viewPropertiesUrl());
- DetailsModeSettings::setLeadingPadding(int(width));
+ DetailsModeSettings::setSidePadding(int(width));
m_view->writeSettings();
}
} else {
header->setAutomaticColumnResizing(true);
}
- header->setLeadingPadding(DetailsModeSettings::leadingPadding());
+ header->setSidePadding(DetailsModeSettings::sidePadding());
}
m_view->endTransaction();
void slotViewContextMenuRequested(const QPointF& pos);
void slotHeaderContextMenuRequested(const QPointF& pos);
void slotHeaderColumnWidthChangeFinished(const QByteArray& role, qreal current);
- void slotLeadingPaddingWidthChanged(qreal width);
+ void slotSidePaddingWidthChanged(qreal width);
void slotItemHovered(int index);
void slotItemUnhovered(int index);
void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);