diff options
| author | Chirag Anand <[email protected]> | 2011-09-22 18:08:49 +0530 |
|---|---|---|
| committer | Chirag Anand <[email protected]> | 2011-09-22 18:08:49 +0530 |
| commit | 9ca11175a4c9e93607131c45b8e5470e1e5014b7 (patch) | |
| tree | 61f1635596c0e5e76881344693af4238f05215ed /src/views/dolphinview.cpp | |
| parent | bc96a102340252363158ded39a3cb0adaee59824 (diff) | |
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: [email protected]
CCMAIL: [email protected]
Diffstat (limited to 'src/views/dolphinview.cpp')
| -rw-r--r-- | src/views/dolphinview.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
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" |
