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)),
}
}
+void DolphinColumnView::scrollToCurrentItem()
+{
+ const QModelIndex activeIndex = activeColumn()->currentIndex();
+ activeColumn()->scrollTo(activeIndex);
+}
+
void DolphinColumnView::setActiveColumnIndex(int index)
{
if (m_index == index) {
* Returns the selected items of the active column.
*/
KFileItemList selectedItems() const;
-
+
/**
* Returns the MIME data for the selected items
* of the active column.
void slotSortOrderChanged(Qt::SortOrder order);
void slotShowHiddenFilesChanged();
void slotShowPreviewChanged();
+ void scrollToCurrentItem();
private:
DolphinColumnWidget* activeColumn() const;
}
}
+void DolphinController::triggerScrollToCurrentItem()
+{
+ emit scrollToCurrentItem();
+}
+
void DolphinController::handleKeyPressEvent(QKeyEvent* event)
{
Q_ASSERT(m_itemView != 0);
* - setShowPreview()
* - indicateActivationChange()
* - setZoomLevel()
+ * - triggerScrollToCurrentItem()
*/
class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
{
void setZoomLevel(int level);
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.
*/
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();
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();
setItemsExpandable(expandable);
}
+void DolphinDetailsView::scrollToCurrentItem()
+{
+ scrollTo(currentIndex());
+}
+
void DolphinDetailsView::updateDecorationSize(bool showPreview)
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
*/
void setFoldersExpandable(bool expandable);
+ void scrollToCurrentItem();
+
private:
/**
* Updates the size of the decoration dependent on the
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()),
}
}
+void DolphinIconsView::scrollToCurrentItem()
+{
+ m_enableScrollTo = true;
+ scrollTo(currentIndex());
+ m_enableScrollTo = false;
+}
+
void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
{
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
void setZoomLevel(int level);
void requestActivation();
void slotGlobalSettingsChanged(int category);
+ void scrollToCurrentItem();
private:
/**
m_tabsForFiles(false),
m_isContextMenuOpen(false),
m_ignoreViewProperties(false),
+ m_assureVisibleCurrentIndex(false),
m_mode(DolphinView::IconsView),
m_topLayout(0),
m_controller(0),
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());
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('#'));
-
- // currently the items are sorted by the selection order, resort
- // them by the file name
- qSort(items.begin(), items.end(), lessThan);
-
- // 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++);
-
- QString name = newName;
- name.replace('#', number);
-
- if (oldUrl.fileName() != name) {
- KUrl newUrl = oldUrl;
- newUrl.setFileName(name);
- KonqOperations::rename(this, oldUrl, newUrl);
- }
+ return;
+ }
+
+ // 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('#'));
+
+ // currently the items are sorted by the selection order, resort
+ // them by the file name
+ qSort(items.begin(), items.end(), lessThan);
+
+ // 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++);
+
+ 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()) {
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()
}
}
+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()) {
*/
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
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;
KUrl m_rootUrl;
KUrl m_currentItemUrl;
- QAbstractItemView* m_expandedDragSource;
+ QAbstractItemView* m_expandedDragSource;
};
inline bool DolphinView::isColumnViewActive() const