X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ee4e21530b21efe7a3b6fa108ec186f553ed4b65..7e61bb47d742c116fcd63223778cf9dda8b6aaac:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 9b2286c87..4d830e2c7 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -22,6 +22,7 @@ #include +#include #include #include #include @@ -319,12 +320,12 @@ DolphinStatusBar* DolphinView::statusBar() const int DolphinView::contentsX() const { - return 0; //scrollView()->contentsX(); + return itemView()->horizontalScrollBar()->value(); } int DolphinView::contentsY() const { - return 0; //scrollView()->contentsY(); + return itemView()->verticalScrollBar()->value(); } void DolphinView::refreshSettings() @@ -610,15 +611,22 @@ void DolphinView::loadDirectory(const KUrl& url) void DolphinView::triggerItem(const QModelIndex& index) { + const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); + if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) { + // items are selected by the user, hence don't trigger the + // item specified by 'index' + return; + } + KFileItem* item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index)); if (item == 0) { return; } if (item->isDir()) { - // Prefer the local path over the Url. This assures that the - // volume space information is correct. Assuming that the Url is media:/sda1, - // and the local path is /windows/C: For the Url the space info is related + // Prefer the local path over the URL. This assures that the + // volume space information is correct. Assuming that the URL is media:/sda1, + // and the local path is /windows/C: For the URL the space info is related // to the root partition (and hence wrong) and for the local path the space // info is related to the windows partition (-> correct). const QString localPath(item->localPath()); @@ -668,6 +676,23 @@ void DolphinView::updateItemCount() } updateStatusBar(); + + QTimer::singleShot(0, this, SLOT(restoreContentsPos())); +} + +void DolphinView::restoreContentsPos() +{ + int index = 0; + const QLinkedList history = urlHistory(index); + if (!history.isEmpty()) { + QAbstractItemView* view = itemView(); + // TODO: view->setCurrentItem(history[index].currentFileName()); + + QLinkedList::const_iterator it = history.begin(); + it += index; + view->horizontalScrollBar()->setValue((*it).contentsX()); + view->verticalScrollBar()->setValue((*it).contentsY()); + } } void DolphinView::showInfoMessage(const QString& msg) @@ -764,8 +789,8 @@ QString DolphinView::selectionStatusBarText() const QString text; const KFileItemList list = selectedItems(); if (list.isEmpty()) { - // TODO: assert(!list.isEmpty()) should be used, as this method is only invoked if - // DolphinView::hasSelection() is true. Inconsistent behavior? + // when an item is triggered, it is temporary selected but selectedItems() + // will return an empty list return QString(); } @@ -790,7 +815,7 @@ QString DolphinView::selectionStatusBarText() const text = i18n("1 Folder selected"); } else if (folderCount > 1) { - text = i18n("%1 Folders selected",folderCount); + text = i18n("%1 Folders selected", folderCount); } if ((fileCount > 0) && (folderCount > 0)) { @@ -799,10 +824,10 @@ QString DolphinView::selectionStatusBarText() const const QString sizeText(KIO::convertSize(byteSize)); if (fileCount == 1) { - text += i18n("1 File selected (%1)",sizeText); + text += i18n("1 File selected (%1)", sizeText); } else if (fileCount > 1) { - text += i18n("%1 Files selected (%1)",fileCount,sizeText); + text += i18n("%1 Files selected (%2)", fileCount, sizeText); } return text;