X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/616294bc805242f29a5b9c8d44ddd1e7466505ec..a4ef4bbfdebad708e4b3c772c1ce3e236a4da145:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 6fadaa85c..c1d245301 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -177,8 +177,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray))); connect(m_view, SIGNAL(visibleRolesChanged(QList,QList)), this, SLOT(slotVisibleRolesChangedByHeader(QList,QList))); - 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))); @@ -248,9 +248,12 @@ void DolphinView::setMode(Mode mode) 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); } } @@ -553,8 +556,8 @@ QString DolphinView::statusBarText() const } if (folderCount + fileCount == 1) { - // If only one item is selected, show the filename - filesText = i18nc("@info:status", "%1 selected", list.first().text()); + // If only one item is selected, show info about it + return list.first().getStatusBarInfo(); } else { // At least 2 items are selected foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount); @@ -612,6 +615,9 @@ void DolphinView::setUrl(const KUrl& url) 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 @@ -651,6 +657,9 @@ void DolphinView::renameSelectedItems() 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); @@ -841,6 +850,12 @@ void DolphinView::slotItemMiddleClicked(int index) void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos) { + // Force emit of a selection changed signal before we request the + // context menu, to update the edit-actions first. (See Bug 294013) + if (m_selectionChangedTimer->isActive()) { + emitSelectionChangedSignal(); + } + const KFileItem item = m_model->fileItem(index); emit requestContextMenu(pos.toPoint(), item, url(), QList()); } @@ -1039,8 +1054,10 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even if (op && destUrl == url()) { // Mark the dropped urls as selected. m_clearSelectionBeforeSelectingNewItems = true; - connect(op, SIGNAL(urlPasted(KUrl)), this, SLOT(slotUrlPasted(KUrl))); + connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List))); } + + setActive(true); } void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous) @@ -1082,7 +1099,7 @@ void DolphinView::slotAboutToCreate(const KUrl::List& urls) markUrlAsCurrent(urls.first()); m_markFirstNewlySelectedItemAsCurrent = false; } - m_selectedUrls << urls; + m_selectedUrls << KDirModel::simplifiedUrlList(urls); } } @@ -1237,10 +1254,13 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh } if (mimetype == QLatin1String("application/x-desktop")) { - // Redirect to the URL in Type=Link desktop files + // Redirect to the URL in Type=Link desktop files, unless it is a http(s) URL. KDesktopFile desktopFile(url.toLocalFile()); if (desktopFile.hasLinkType()) { - return desktopFile.readUrl(); + const QString linkUrl = desktopFile.readUrl(); + if (!linkUrl.startsWith(QLatin1String("http"))) { + return linkUrl; + } } } } @@ -1361,6 +1381,16 @@ void DolphinView::slotDeleteFileFinished(KJob* job) } } +void DolphinView::slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl) +{ + const int index = m_model->index(newUrl); + if (index >= 0) { + QHash 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 @@ -1427,8 +1457,17 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList& curre 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; } @@ -1452,7 +1491,10 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con 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))); + } } } } @@ -1478,9 +1520,13 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload) 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) { @@ -1620,7 +1666,7 @@ QMimeData* DolphinView::selectionMimeData() const void DolphinView::updateWritableState() { const bool wasFolderWritable = m_isFolderWritable; - m_isFolderWritable = true; + m_isFolderWritable = false; const KFileItem item = m_model->rootItem(); if (!item.isNull()) {