┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/dolphinview.cpp
diff options
context:
space:
mode:
authorWeng Xuetian <[email protected]>2012-08-27 13:55:17 -0400
committerWeng Xuetian <[email protected]>2012-08-27 14:01:10 -0400
commit09ba6bcb62297c45c0a5ea664aca1ecb52ba0149 (patch)
tree5eaba1ac542b727ac72c162461cfa30e2b7c8414 /src/views/dolphinview.cpp
parentd898f40f29f6328fd80165022790609972dcce7c (diff)
Make --select can automatically scroll to the selected file.
REVIEW: 106209
Diffstat (limited to 'src/views/dolphinview.cpp')
-rw-r--r--src/views/dolphinview.cpp30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 7cfb3fc41..f2b0a5c8c 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -98,8 +98,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
m_toolTipManager(0),
m_selectionChangedTimer(0),
m_currentItemUrl(),
+ m_scrollToCurrentItem(false),
m_restoredContentsPosition(),
- m_createdItemUrl(),
m_selectedUrls(),
m_versionControlObserver(0)
{
@@ -363,6 +363,7 @@ void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
void DolphinView::markUrlAsCurrent(const KUrl& url)
{
m_currentItemUrl = url;
+ m_scrollToCurrentItem = true;
}
void DolphinView::selectItems(const QRegExp& pattern, bool enabled)
@@ -1142,25 +1143,8 @@ QString DolphinView::viewPropertiesContext() const
void DolphinView::observeCreatedItem(const KUrl& url)
{
- m_createdItemUrl = url;
- connect(m_model, SIGNAL(directoryLoadingCompleted()),
- this, SLOT(selectAndScrollToCreatedItem()));
-}
-
-void DolphinView::selectAndScrollToCreatedItem()
-{
- KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
- const int index = m_model->index(m_createdItemUrl);
- if (index != -1) {
- selectionManager->setCurrentItem(index);
- selectionManager->clearSelection();
- selectionManager->setSelected(index);
- m_view->scrollToItem(index);
- }
-
- disconnect(m_model, SIGNAL(directoryLoadingCompleted()),
- this, SLOT(selectAndScrollToCreatedItem()));
- m_createdItemUrl = KUrl();
+ markUrlAsCurrent(url);
+ markUrlsAsSelected(QList<KUrl>() << url);
}
void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
@@ -1178,6 +1162,12 @@ void DolphinView::updateViewState()
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);
}