- Remember selection + current item when switching view-modes
- Fix the current item indicator alignment for selections
- Set the item as current item when the selection toggle has
been clicked
QColor KFileItemListWidget::textColor() const
{
QColor KFileItemListWidget::textColor() const
{
- if (m_customTextColor.isValid()) {
+ if (m_customTextColor.isValid() && !isSelected()) {
return m_customTextColor;
}
return m_customTextColor;
}
switch (key) {
case Qt::Key_Home:
index = 0;
switch (key) {
case Qt::Key_Home:
index = 0;
m_selectionTogglePressed = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos);
if (m_selectionTogglePressed) {
m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Toggle);
m_selectionTogglePressed = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos);
if (m_selectionTogglePressed) {
m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Toggle);
+ m_selectionManager->setCurrentItem(m_pressedIndex);
if (isCurrent()) {
QStyleOptionViewItemV4 viewItemOption;
viewItemOption.initFrom(widget);
if (isCurrent()) {
QStyleOptionViewItemV4 viewItemOption;
viewItemOption.initFrom(widget);
- viewItemOption.rect = textRect().toRect();
+
+ const QRect iconBounds = iconRect().toRect();
+ const QRect textBounds = textRect().toRect();
+ if (iconBounds.bottom() >= textBounds.top()) {
+ viewItemOption.rect = textBounds;
+ } else {
+ // See KItemListWidget::drawItemStyleOption(): The selection rectangle
+ // gets decreased.
+ viewItemOption.rect = textBounds.adjusted(1, 1, -1, -1);
+ }
+
viewItemOption.state = QStyle::State_Enabled | QStyle::State_Item;
if (m_selected) {
viewItemOption.state |= QStyle::State_Selected;
}
viewItemOption.state = QStyle::State_Enabled | QStyle::State_Item;
if (m_selected) {
viewItemOption.state |= QStyle::State_Selected;
}
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &viewItemOption, painter, widget);
}
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &viewItemOption, painter, widget);
}
viewItemOption.state = styleState;
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
viewItemOption.state = styleState;
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
- const bool drawMerged = (iconBounds.top() == textBounds.top() &&
- iconBounds.bottom() == textBounds.bottom());
-
- if (drawMerged) {
+ if (iconBounds.bottom() >= textBounds.top()) {
viewItemOption.rect = iconBounds | textBounds;
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
} else {
viewItemOption.rect = iconBounds;
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
viewItemOption.rect = iconBounds | textBounds;
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
} else {
viewItemOption.rect = iconBounds;
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
- viewItemOption.rect = textBounds.adjusted(2, 2, -2, -2);
+ viewItemOption.rect = textBounds.adjusted(1, 1, -1, -1);
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
}
}
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
}
}
// has been modified.
const bool restoreModel = (model->count() > 0);
if (restoreModel) {
// has been modified.
const bool restoreModel = (model->count() > 0);
if (restoreModel) {
+ const int currentItemIndex = m_container->controller()->selectionManager()->currentItem();
+ if (currentItemIndex >= 0) {
+ m_currentItemUrl = model->fileItem(currentItemIndex).url();
+ }
+ m_selectedUrls = selectedItems().urlList();
QTimer* m_selectionChangedTimer;
QTimer* m_selectionChangedTimer;
+ KUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
QPoint m_restoredContentsPosition;
KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
QPoint m_restoredContentsPosition;
KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
- QList<KUrl> m_selectedUrls; // this is used for making the View to remember selections after F5
+
+ QList<KUrl> m_selectedUrls; // Used for making the view to remember selections after F5
VersionControlObserver* m_versionControlObserver;
VersionControlObserver* m_versionControlObserver;