const int tabCount = m_viewTab.count();
for (int i = 0; i < tabCount; ++i) {
m_viewTab[i].primaryView->view()->markUrlsAsSelected(files);
+ m_viewTab[i].primaryView->view()->markUrlAsCurrent(files.at(0));
if (m_viewTab[i].secondaryView) {
m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files);
+ m_viewTab[i].secondaryView->view()->markUrlAsCurrent(files.at(0));
}
}
}
return m_items.value(item.url(), -1);
}
+int KFileItemModel::index(const KUrl& url) const
+{
+ KUrl urlToFind = url;
+ urlToFind.adjustPath(KUrl::RemoveTrailingSlash);
+ return m_items.value(urlToFind, -1);
+}
+
KFileItem KFileItemModel::rootItem() const
{
const KDirLister* dirLister = m_dirLister.data();
m_container(0),
m_toolTipManager(0),
m_selectionChangedTimer(0),
- m_currentItemIndex(-1),
+ m_currentItemUrl(),
m_restoredContentsPosition(),
m_createdItemUrl(),
m_selectedItems(),
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;
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();
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()) {
return sortHash.value(sortRole);
}
+void DolphinView::markUrlAsCurrent(const KUrl& url)
+{
+ m_currentItemUrl = url;
+}
+
#include "dolphinview.moc"
*/
void markUrlsAsSelected(const QList<KUrl>& urls);
+ /**
+ * Marks the item indicated by \p url as the current item after the
+ * directory DolphinView::url() has been loaded.
+ */
+ void markUrlAsCurrent(const KUrl& url);
+
/**
* All items that match to the pattern \a pattern will get selected
* if \a enabled is true and deselected if \a enabled is false.
QTimer* m_selectionChangedTimer;
- int m_currentItemIndex;
+ KUrl m_currentItemUrl;
QPoint m_restoredContentsPosition;
KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
KFileItemList m_selectedItems; // this is used for making the View to remember selections after F5