From 9ca11175a4c9e93607131c45b8e5470e1e5014b7 Mon Sep 17 00:00:00 2001 From: Chirag Anand Date: Thu, 22 Sep 2011 18:08:49 +0530 Subject: Fixed bug for selecting files with --select parameter. Files selected via --select parameter did not get current item focus. And if files were deleted while being current item, updating the view would select the next item instead of the first item in the list. BUG: 257805 CCMAIL: peter.penz19@gmail.com CCMAIL: frank78ac@googlemail.com --- src/views/dolphinview.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 2fa9196bf..71c67b1cf 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -90,7 +90,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : m_container(0), m_toolTipManager(0), m_selectionChangedTimer(0), - m_currentItemIndex(-1), + m_currentItemUrl(), m_restoredContentsPosition(), m_createdItemUrl(), m_selectedItems(), @@ -925,7 +925,7 @@ bool DolphinView::itemsExpandable() const void DolphinView::restoreState(QDataStream& stream) { // Restore the current item that had the keyboard focus - stream >> m_currentItemIndex; + stream >> m_currentItemUrl; // Restore the view position stream >> m_restoredContentsPosition; @@ -939,7 +939,14 @@ void DolphinView::restoreState(QDataStream& stream) void DolphinView::saveState(QDataStream& stream) { // Save the current item that has the keyboard focus - stream << m_container->controller()->selectionManager()->currentItem(); + const int currentIndex = m_container->controller()->selectionManager()->currentItem(); + if (currentIndex != -1) { + KFileItem item = fileItemModel()->fileItem(currentIndex); + KUrl currentItemUrl = item.url(); + stream << currentItemUrl; + } else { + stream << KUrl(); + } // Save view position const qreal x = m_container->horizontalScrollBar()->value(); @@ -993,10 +1000,15 @@ void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl) void DolphinView::updateViewState() { - if (m_currentItemIndex >= 0) { + if (m_currentItemUrl != KUrl()) { KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); - selectionManager->setCurrentItem(m_currentItemIndex); - m_currentItemIndex =-1; + const int currentIndex = fileItemModel()->index(m_currentItemUrl); + if (currentIndex != -1) { + selectionManager->setCurrentItem(currentIndex); + } else { + selectionManager->setCurrentItem(0); + } + m_currentItemUrl = KUrl(); } if (!m_restoredContentsPosition.isNull()) { @@ -1301,4 +1313,9 @@ DolphinView::Sorting DolphinView::sortingForSortRole(const QByteArray& sortRole) return sortHash.value(sortRole); } +void DolphinView::markUrlAsCurrent(const KUrl& url) +{ + m_currentItemUrl = url; +} + #include "dolphinview.moc" -- cgit v1.3