this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
- connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
+ this, SLOT(slotRoleEditingCanceled()));
connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
if (mode != m_mode) {
ViewProperties props(viewPropertiesUrl());
props.setViewMode(mode);
- props.save();
- applyViewProperties();
+ // We pass the new ViewProperties to applyViewProperties, rather than
+ // storing them on disk and letting applyViewProperties() read them
+ // from there, to prevent that changing the view mode fails if the
+ // .directory file is not writable (see bug 318534).
+ applyViewProperties(props);
}
}
hideToolTip();
+ disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
+ this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+
// It is important to clear the items from the model before
// applying the view properties, otherwise expensive operations
// might be done on the existing items although they get cleared
if (items.count() == 1 && GeneralSettings::renameInline()) {
const int index = m_model->index(items.first());
m_view->editRole(index, "text");
+
+ connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
+ this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
} else {
RenameDialog* dialog = new RenameDialog(this, items);
dialog->setAttribute(Qt::WA_DeleteOnClose);
m_clearSelectionBeforeSelectingNewItems = true;
connect(op, SIGNAL(urlPasted(KUrl)), this, SLOT(slotUrlPasted(KUrl)));
}
+
+ setActive(true);
}
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
}
}
+void DolphinView::slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl)
+{
+ const int index = m_model->index(newUrl);
+ if (index >= 0) {
+ QHash<QByteArray, QVariant> data;
+ data.insert("text", oldUrl.fileName());
+ m_model->setData(index, data);
+ }
+}
+
void DolphinView::slotDirectoryLoadingStarted()
{
// Disable the writestate temporary until it can be determined in a fast way
emit visibleRolesChanged(m_visibleRoles, previousVisibleRoles);
}
+void DolphinView::slotRoleEditingCanceled()
+{
+ disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
+ this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+}
+
void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
{
+ disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
+ this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+
if (index < 0 || index >= m_model->count()) {
return;
}
m_model->setData(index, data);
}
- KonqOperations::rename(this, oldUrl, newName);
+ KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName);
+ if (op) {
+ connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl)));
+ }
}
}
}
void DolphinView::applyViewProperties()
{
- m_view->beginTransaction();
-
const ViewProperties props(viewPropertiesUrl());
+ applyViewProperties(props);
+}
+
+void DolphinView::applyViewProperties(const ViewProperties& props)
+{
+ m_view->beginTransaction();
const Mode mode = props.viewMode();
if (m_mode != mode) {