┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dolphincolumnview.cpp8
-rw-r--r--src/dolphincolumnview.h3
-rw-r--r--src/dolphincontroller.cpp5
-rw-r--r--src/dolphincontroller.h13
-rw-r--r--src/dolphindetailsview.cpp7
-rw-r--r--src/dolphindetailsview.h2
-rw-r--r--src/dolphiniconsview.cpp9
-rw-r--r--src/dolphiniconsview.h1
-rw-r--r--src/dolphinview.cpp70
-rw-r--r--src/dolphinview.h8
10 files changed, 99 insertions, 27 deletions
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp
index 4d180442b..16d72c0f0 100644
--- a/src/dolphincolumnview.cpp
+++ b/src/dolphincolumnview.cpp
@@ -59,6 +59,8 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
this, SLOT(setZoomLevel(int)));
connect(controller, SIGNAL(activationChanged(bool)),
this, SLOT(updateColumnsBackground(bool)));
+ connect(controller, SIGNAL(scrollToCurrentItem()),
+ this, SLOT(scrollToCurrentItem()));
const DolphinView* view = controller->dolphinView();
connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
@@ -465,6 +467,12 @@ void DolphinColumnView::slotShowPreviewChanged()
}
}
+void DolphinColumnView::scrollToCurrentItem()
+{
+ const QModelIndex activeIndex = activeColumn()->currentIndex();
+ activeColumn()->scrollTo(activeIndex);
+}
+
void DolphinColumnView::setActiveColumnIndex(int index)
{
if (m_index == index) {
diff --git a/src/dolphincolumnview.h b/src/dolphincolumnview.h
index caa54eab8..756037874 100644
--- a/src/dolphincolumnview.h
+++ b/src/dolphincolumnview.h
@@ -112,7 +112,7 @@ public:
* Returns the selected items of the active column.
*/
KFileItemList selectedItems() const;
-
+
/**
* Returns the MIME data for the selected items
* of the active column.
@@ -169,6 +169,7 @@ private slots:
void slotSortOrderChanged(Qt::SortOrder order);
void slotShowHiddenFilesChanged();
void slotShowPreviewChanged();
+ void scrollToCurrentItem();
private:
DolphinColumnWidget* activeColumn() const;
diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp
index b128c9033..cfa0d62c8 100644
--- a/src/dolphincontroller.cpp
+++ b/src/dolphincontroller.cpp
@@ -124,6 +124,11 @@ void DolphinController::setZoomLevel(int level)
}
}
+void DolphinController::triggerScrollToCurrentItem()
+{
+ emit scrollToCurrentItem();
+}
+
void DolphinController::handleKeyPressEvent(QKeyEvent* event)
{
Q_ASSERT(m_itemView != 0);
diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h
index 29dd7dfb1..ba1036060 100644
--- a/src/dolphincontroller.h
+++ b/src/dolphincontroller.h
@@ -73,6 +73,7 @@ class QWidget;
* - setShowPreview()
* - indicateActivationChange()
* - setZoomLevel()
+ * - triggerScrollToCurrentItem()
*/
class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
{
@@ -190,6 +191,12 @@ public:
int zoomLevel() const;
/**
+ * Triggers the view implementation to assure having a fully visible
+ * current item. The signal scrollToCurrentItem() will be emitted.
+ */
+ void triggerScrollToCurrentItem();
+
+ /**
* Tells the view implementation to zoom out by emitting the signal zoomOut()
* and is invoked by the abstract Dolphin view.
*/
@@ -369,6 +376,12 @@ signals:
*/
void hideToolTip();
+ /**
+ * Is emitted if the view implementation should scroll to the current item, so
+ * that it is fully visible.
+ */
+ void scrollToCurrentItem();
+
private slots:
void updateMouseButtonState();
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index dd58e5842..fbd7e41d5 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -128,6 +128,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
this, SLOT(updateColumnVisibility()));
connect(controller, SIGNAL(activationChanged(bool)),
this, SLOT(slotActivationChanged(bool)));
+ connect(controller, SIGNAL(scrollToCurrentItem()),
+ this, SLOT(scrollToCurrentItem()));
if (settings->useSystemFont()) {
m_font = KGlobalSettings::generalFont();
@@ -866,6 +868,11 @@ void DolphinDetailsView::setFoldersExpandable(bool expandable)
setItemsExpandable(expandable);
}
+void DolphinDetailsView::scrollToCurrentItem()
+{
+ scrollTo(currentIndex());
+}
+
void DolphinDetailsView::updateDecorationSize(bool showPreview)
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h
index 38aea12de..e60400b44 100644
--- a/src/dolphindetailsview.h
+++ b/src/dolphindetailsview.h
@@ -159,6 +159,8 @@ private slots:
*/
void setFoldersExpandable(bool expandable);
+ void scrollToCurrentItem();
+
private:
/**
* Updates the size of the decoration dependent on the
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index f5b69bade..4b861df44 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -88,6 +88,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
controller, SLOT(emitViewportEntered()));
connect(controller, SIGNAL(zoomLevelChanged(int)),
this, SLOT(setZoomLevel(int)));
+ connect(controller, SIGNAL(scrollToCurrentItem()),
+ this, SLOT(scrollToCurrentItem()));
const DolphinView* view = controller->dolphinView();
connect(view, SIGNAL(showPreviewChanged()),
@@ -390,6 +392,13 @@ void DolphinIconsView::slotGlobalSettingsChanged(int category)
}
}
+void DolphinIconsView::scrollToCurrentItem()
+{
+ m_enableScrollTo = true;
+ scrollTo(currentIndex());
+ m_enableScrollTo = false;
+}
+
void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
{
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
diff --git a/src/dolphiniconsview.h b/src/dolphiniconsview.h
index 76a369db9..8a1f1f8dd 100644
--- a/src/dolphiniconsview.h
+++ b/src/dolphiniconsview.h
@@ -76,6 +76,7 @@ private slots:
void setZoomLevel(int level);
void requestActivation();
void slotGlobalSettingsChanged(int category);
+ void scrollToCurrentItem();
private:
/**
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index f40accdde..638e6e7cb 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -88,6 +88,7 @@ DolphinView::DolphinView(QWidget* parent,
m_tabsForFiles(false),
m_isContextMenuOpen(false),
m_ignoreViewProperties(false),
+ m_assureVisibleCurrentIndex(false),
m_mode(DolphinView::IconsView),
m_topLayout(0),
m_controller(0),
@@ -142,6 +143,8 @@ DolphinView::DolphinView(QWidget* parent,
this, SIGNAL(redirection(KUrl, KUrl)));
connect(m_dirLister, SIGNAL(completed()),
this, SLOT(restoreCurrentItem()));
+ connect(m_dirLister, SIGNAL(refreshItems(const QList<QPair<KFileItem,KFileItem>>&)),
+ this, SLOT(slotRefreshItems()));
applyViewProperties(url);
m_topLayout->addWidget(itemView());
@@ -629,30 +632,31 @@ void DolphinView::renameSelectedItems()
const QString newName = dialog.newName();
if (newName.isEmpty()) {
emit errorMessage(dialog.errorString());
- } else {
- // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
- // as one operation instead of n rename operations like it is done now...
- Q_ASSERT(newName.contains('#'));
+ return;
+ }
- // currently the items are sorted by the selection order, resort
- // them by the file name
- qSort(items.begin(), items.end(), lessThan);
+ // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
+ // as one operation instead of n rename operations like it is done now...
+ Q_ASSERT(newName.contains('#'));
- // iterate through all selected items and rename them...
- int index = 1;
- foreach (const KFileItem& item, items) {
- const KUrl& oldUrl = item.url();
- QString number;
- number.setNum(index++);
+ // currently the items are sorted by the selection order, resort
+ // them by the file name
+ qSort(items.begin(), items.end(), lessThan);
- QString name = newName;
- name.replace('#', number);
+ // iterate through all selected items and rename them...
+ int index = 1;
+ foreach (const KFileItem& item, items) {
+ const KUrl& oldUrl = item.url();
+ QString number;
+ number.setNum(index++);
- if (oldUrl.fileName() != name) {
- KUrl newUrl = oldUrl;
- newUrl.setFileName(name);
- KonqOperations::rename(this, oldUrl, newUrl);
- }
+ QString name = newName;
+ name.replace('#', number);
+
+ if (oldUrl.fileName() != name) {
+ KUrl newUrl = oldUrl;
+ newUrl.setFileName(name);
+ KonqOperations::rename(this, oldUrl, newUrl);
}
}
} else if (DolphinSettings::instance().generalSettings()->renameInline()) {
@@ -676,13 +680,18 @@ void DolphinView::renameSelectedItems()
const QString& newName = dialog.newName();
if (newName.isEmpty()) {
emit errorMessage(dialog.errorString());
- } else {
- const KUrl& oldUrl = items.first().url();
- KUrl newUrl = oldUrl;
- newUrl.setFileName(newName);
- KonqOperations::rename(this, oldUrl, newUrl);
+ return;
}
+
+ const KUrl& oldUrl = items.first().url();
+ KUrl newUrl = oldUrl;
+ newUrl.setFileName(newName);
+ KonqOperations::rename(this, oldUrl, newUrl);
}
+
+ // assure that the current index remains visible when KDirLister
+ // will notify the view about changed items
+ m_assureVisibleCurrentIndex = true;
}
void DolphinView::trashSelectedItems()
@@ -1147,6 +1156,17 @@ void DolphinView::restoreCurrentItem()
}
}
+void DolphinView::slotRefreshItems()
+{
+ if (m_assureVisibleCurrentIndex) {
+ m_assureVisibleCurrentIndex = false;
+ // Invoking itemView()->scrollTo(itemView()->currentIndex()) is
+ // not sufficient, as QListView and QTreeView have an inconsistent
+ // default behavior.
+ m_controller->triggerScrollToCurrentItem();
+ }
+}
+
void DolphinView::loadDirectory(const KUrl& url, bool reload)
{
if (!url.isValid()) {
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 5cedeecfa..1498de08a 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -631,6 +631,11 @@ private slots:
void restoreCurrentItem();
/**
+ * Is invoked when the KDirLister indicates refreshed items.
+ */
+ void slotRefreshItems();
+
+ /**
* If \a view can be positively identified as not being the source for the
* current drag operation, deleteLater() it immediately. Else stores
* it for later deletion.
@@ -716,6 +721,7 @@ private:
bool m_tabsForFiles : 1;
bool m_isContextMenuOpen : 1; // TODO: workaround for Qt-issue 207192
bool m_ignoreViewProperties : 1;
+ bool m_assureVisibleCurrentIndex : 1;
Mode m_mode;
@@ -739,7 +745,7 @@ private:
KUrl m_rootUrl;
KUrl m_currentItemUrl;
- QAbstractItemView* m_expandedDragSource;
+ QAbstractItemView* m_expandedDragSource;
};
inline bool DolphinView::isColumnViewActive() const