┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/dolphinview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/dolphinview.cpp')
-rw-r--r--src/views/dolphinview.cpp79
1 files changed, 43 insertions, 36 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index cd802eec1..e40e49d6e 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -87,19 +87,19 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
m_viewPropertiesContext(),
m_mode(DolphinView::IconsView),
m_visibleRoles(),
- m_topLayout(0),
- m_model(0),
- m_view(0),
- m_container(0),
- m_toolTipManager(0),
- m_selectionChangedTimer(0),
+ m_topLayout(nullptr),
+ m_model(nullptr),
+ m_view(nullptr),
+ m_container(nullptr),
+ m_toolTipManager(nullptr),
+ m_selectionChangedTimer(nullptr),
m_currentItemUrl(),
m_scrollToCurrentItem(false),
m_restoredContentsPosition(),
m_selectedUrls(),
m_clearSelectionBeforeSelectingNewItems(false),
m_markFirstNewlySelectedItemAsCurrent(false),
- m_versionControlObserver(0),
+ m_versionControlObserver(nullptr),
m_twoClicksRenamingTimer(nullptr)
{
m_topLayout = new QVBoxLayout(this);
@@ -912,7 +912,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
#endif
QString groupName;
- QMenu* groupMenu = 0;
+ QMenu* groupMenu = nullptr;
// Add all roles to the menu that can be shown or hidden by the user
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
@@ -923,7 +923,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
}
const QString text = m_model->roleDescription(info.role);
- QAction* action = 0;
+ QAction* action = nullptr;
if (info.group.isEmpty()) {
action = menu->addAction(text);
} else {
@@ -1094,11 +1094,11 @@ void DolphinView::dropUrls(const QUrl &destUrl, QDropEvent *dropEvent, QWidget *
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
{
- if (previous != 0) {
+ if (previous != nullptr) {
Q_ASSERT(qobject_cast<KFileItemModel*>(previous));
KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(previous);
disconnect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
- m_versionControlObserver->setModel(0);
+ m_versionControlObserver->setModel(nullptr);
}
if (current) {
@@ -1356,17 +1356,21 @@ void DolphinView::updateViewState()
{
if (m_currentItemUrl != QUrl()) {
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
- const int currentIndex = m_model->index(m_currentItemUrl);
- if (currentIndex != -1) {
- selectionManager->setCurrentItem(currentIndex);
- // scroll to current item and reset the state
- if (m_scrollToCurrentItem) {
- m_view->scrollToItem(currentIndex);
- m_scrollToCurrentItem = false;
+ // if there is a selection already, leave it that way
+ if (!selectionManager->hasSelection()) {
+ const int currentIndex = m_model->index(m_currentItemUrl);
+ if (currentIndex != -1) {
+ selectionManager->setCurrentItem(currentIndex);
+
+ // scroll to current item and reset the state
+ if (m_scrollToCurrentItem) {
+ m_view->scrollToItem(currentIndex);
+ m_scrollToCurrentItem = false;
+ }
+ } else {
+ selectionManager->setCurrentItem(0);
}
- } else {
- selectionManager->setCurrentItem(0);
}
m_currentItemUrl = QUrl();
@@ -1384,26 +1388,29 @@ void DolphinView::updateViewState()
if (!m_selectedUrls.isEmpty()) {
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
- if (m_clearSelectionBeforeSelectingNewItems) {
- selectionManager->clearSelection();
- m_clearSelectionBeforeSelectingNewItems = false;
- }
+ // if there is a selection already, leave it that way
+ if (!selectionManager->hasSelection()) {
+ if (m_clearSelectionBeforeSelectingNewItems) {
+ selectionManager->clearSelection();
+ m_clearSelectionBeforeSelectingNewItems = false;
+ }
- KItemSet selectedItems = selectionManager->selectedItems();
+ KItemSet selectedItems = selectionManager->selectedItems();
- QList<QUrl>::iterator it = m_selectedUrls.begin();
- while (it != m_selectedUrls.end()) {
- const int index = m_model->index(*it);
- if (index >= 0) {
- selectedItems.insert(index);
- it = m_selectedUrls.erase(it);
- } else {
- ++it;
+ QList<QUrl>::iterator it = m_selectedUrls.begin();
+ while (it != m_selectedUrls.end()) {
+ const int index = m_model->index(*it);
+ if (index >= 0) {
+ selectedItems.insert(index);
+ it = m_selectedUrls.erase(it);
+ } else {
+ ++it;
+ }
}
- }
- selectionManager->beginAnchoredSelection(selectionManager->currentItem());
- selectionManager->setSelectedItems(selectedItems);
+ selectionManager->beginAnchoredSelection(selectionManager->currentItem());
+ selectionManager->setSelectedItems(selectedItems);
+ }
}
}