m_toolTipManager(0),
m_selectionChangedTimer(0),
m_currentItemUrl(),
+ m_scrollToCurrentItem(false),
m_restoredContentsPosition(),
- m_createdItemUrl(),
m_selectedUrls(),
m_versionControlObserver(0)
{
connect(m_model, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
connect(m_model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
connect(m_model, SIGNAL(directoryRedirection(KUrl,KUrl)), this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
+ connect(m_model, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
m_view->installEventFilter(this);
connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
ViewProperties props(viewPropertiesUrl());
props.setPreviewsShown(show);
+ const int oldZoomLevel = m_view->zoomLevel();
m_view->setPreviewsShown(show);
emit previewsShownChanged(show);
+
+ const int newZoomLevel = m_view->zoomLevel();
+ if (newZoomLevel != oldZoomLevel) {
+ emit zoomLevelChanged(newZoomLevel, oldZoomLevel);
+ }
}
bool DolphinView::previewsShown() const
void DolphinView::markUrlAsCurrent(const KUrl& url)
{
m_currentItemUrl = url;
+ m_scrollToCurrentItem = true;
}
void DolphinView::selectItems(const QRegExp& pattern, bool enabled)
return m_model->nameFilter();
}
+void DolphinView::setMimeTypeFilters(const QStringList& filters)
+{
+ return m_model->setMimeTypeFilters(filters);
+}
+
+QStringList DolphinView::mimeTypeFilters() const
+{
+ return m_model->mimeTypeFilters();
+}
+
QString DolphinView::statusBarText() const
{
QString summary;
if (items.count() == 1) {
const int index = m_model->index(items.first());
- m_container->controller()->view()->editRole(index, "text");
+ m_view->editRole(index, "text");
} else {
RenameDialog* dialog = new RenameDialog(this, items);
dialog->setAttribute(Qt::WA_DeleteOnClose);
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)
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);
}
void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
{
+ if (index < 0 || index >= m_model->count()) {
+ return;
+ }
+
if (role == "text") {
- const KFileItem item = m_model->fileItem(index);
+ const KFileItem oldItem = m_model->fileItem(index);
const QString newName = value.toString();
- if (!newName.isEmpty() && newName != item.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
- KonqOperations::rename(this, item.url(), newName);
+ if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
+ const KUrl oldUrl = oldItem.url();
+
+ QHash<QByteArray, QVariant> data;
+ data.insert(role, value);
+ m_model->setData(index, data);
+
+ KonqOperations::rename(this, oldUrl, newName);
}
}
}
KUrl::List urls;
const KFileItemList items = selectedItems();
- foreach (const KFileItem &item, items) {
+ foreach (const KFileItem& item, items) {
urls.append(item.url());
}
const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
KUrl::List destUrls;
foreach (const KUrl& source, sourceUrls) {
- KUrl destination(url().url() + "/" + source.fileName());
+ KUrl destination(url().url() + '/' + source.fileName());
destUrls << destination;
}
markUrlsAsSelected(destUrls);