X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/bd925ea49a7e4e7c6e652f4529dcd0c4e25fd19a..44d938cf4b421e6c8d39a069809ffbf807f1e02e:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index f5a972d37..20d3db4ae 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -214,69 +214,16 @@ DolphinView::Mode DolphinView::mode() const return m_mode; } -void DolphinView::setShowPreview(bool show) -{ - if (m_showPreview == show) { - return; - } - - const KUrl viewPropsUrl = viewPropertiesUrl(); - ViewProperties props(viewPropsUrl); - props.setShowPreview(show); - - m_showPreview = show; - m_iconManager->setShowPreview(show); - emit showPreviewChanged(); - - loadDirectory(viewPropsUrl); -} - bool DolphinView::showPreview() const { return m_showPreview; } -void DolphinView::setShowHiddenFiles(bool show) -{ - if (m_dirLister->showingDotFiles() == show) { - return; - } - - const KUrl viewPropsUrl = viewPropertiesUrl(); - ViewProperties props(viewPropsUrl); - props.setShowHiddenFiles(show); - - m_dirLister->setShowingDotFiles(show); - emit showHiddenFilesChanged(); - - loadDirectory(viewPropsUrl); -} - bool DolphinView::showHiddenFiles() const { return m_dirLister->showingDotFiles(); } -void DolphinView::setCategorizedSorting(bool categorized) -{ - if (categorized == categorizedSorting()) { - return; - } - - // setCategorizedSorting(true) may only get invoked - // if the view supports categorized sorting - Q_ASSERT(!categorized || supportsCategorizedSorting()); - - ViewProperties props(viewPropertiesUrl()); - props.setCategorizedSorting(categorized); - props.save(); - - m_storedCategorizedSorting = categorized; - m_proxyModel->setCategorizedModel(categorized); - - emit categorizedSortingChanged(); -} - bool DolphinView::categorizedSorting() const { // If all view modes would support categorized sorting, returning @@ -866,18 +813,12 @@ void DolphinView::emitContentsMoved() void DolphinView::showHoverInformation(const KFileItem& item) { - if (hasSelection() || !m_active) { - return; - } - emit requestItemInfo(item); } void DolphinView::clearHoverInformation() { - if (m_active) { - emit requestItemInfo(KFileItem()); - } + emit requestItemInfo(KFileItem()); } void DolphinView::createView() @@ -1023,14 +964,19 @@ void DolphinView::renameSelectedItems() } } } + } else if (DolphinSettings::instance().generalSettings()->renameInline()) { + Q_ASSERT(items.count() == 1); + + if (isColumnViewActive()) { + m_columnView->editItem(items.first()); + } else { + const QModelIndex dirIndex = m_dolphinModel->indexForItem(items.first()); + const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); + itemView()->edit(proxyIndex); + } } else { - // Only one item has been selected for renaming. Use the custom - // renaming mechanism from the views. Q_ASSERT(items.count() == 1); - // TODO: Think about using KFileItemDelegate as soon as it supports editing. - // Currently the RenameDialog is used, but I'm not sure whether inline renaming - // is a benefit for the user at all -> let's wait for some input first... RenameDialog dialog(this, items); if (dialog.exec() == QDialog::Rejected) { return; @@ -1103,45 +1049,69 @@ void DolphinView::paste() const QMimeData* mimeData = clipboard->mimeData(); const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData); - - // per default the pasting is done into the current URL of the view - KUrl destUrl = url(); - - // check whether the pasting should be done into a selected directory - const KUrl::List selectedUrls = this->selectedUrls(); - if (selectedUrls.count() == 1) { - const KFileItem fileItem(S_IFDIR, - KFileItem::Unknown, - selectedUrls.first(), - true); - if (fileItem.isDir()) { - // only one item is selected which is a directory, hence paste - // into this directory - destUrl = selectedUrls.first(); - if (sourceUrls.contains(destUrl)) { - const QString text = i18nc("@info", "The folder %1 is pasted into itself. Is this intended?", fileItem.name()); - int result = KMessageBox::questionYesNo(window(), - text, - i18nc("@title:window", "Paste into Folder"), - KGuiItem(i18nc("@label", "Paste"), "dialog-ok"), - KGuiItem(i18nc("@label", "Cancel"), "dialog-cancel")); - if (result == KMessageBox::No) { - return; - } - } - } - } - if (KonqMimeData::decodeIsCutSelection(mimeData)) { - KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, destUrl); + KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url()); emit doingOperation(KonqFileUndoManager::MOVE); clipboard->clear(); } else { - KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, destUrl); + KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url()); emit doingOperation(KonqFileUndoManager::COPY); } } +void DolphinView::setShowPreview(bool show) +{ + if (m_showPreview == show) { + return; + } + + const KUrl viewPropsUrl = viewPropertiesUrl(); + ViewProperties props(viewPropsUrl); + props.setShowPreview(show); + + m_showPreview = show; + m_iconManager->setShowPreview(show); + emit showPreviewChanged(); + + loadDirectory(viewPropsUrl); +} + +void DolphinView::setShowHiddenFiles(bool show) +{ + if (m_dirLister->showingDotFiles() == show) { + return; + } + + const KUrl viewPropsUrl = viewPropertiesUrl(); + ViewProperties props(viewPropsUrl); + props.setShowHiddenFiles(show); + + m_dirLister->setShowingDotFiles(show); + emit showHiddenFilesChanged(); + + loadDirectory(viewPropsUrl); +} + +void DolphinView::setCategorizedSorting(bool categorized) +{ + if (categorized == categorizedSorting()) { + return; + } + + // setCategorizedSorting(true) may only get invoked + // if the view supports categorized sorting + Q_ASSERT(!categorized || supportsCategorizedSorting()); + + ViewProperties props(viewPropertiesUrl()); + props.setCategorizedSorting(categorized); + props.save(); + + m_storedCategorizedSorting = categorized; + m_proxyModel->setCategorizedModel(categorized); + + emit categorizedSortingChanged(); +} + QPair DolphinView::pasteInfo() const { QPair ret; @@ -1164,19 +1134,6 @@ QPair DolphinView::pasteInfo() const ret.second = i18nc("@action:inmenu", "Paste"); } - if (ret.first) { - const KFileItemList items = selectedItems(); - const uint count = items.count(); - if (count > 1) { - // pasting should not be allowed when more than one file - // is selected - ret.first = false; - } else if (count == 1) { - // Only one file is selected. Pasting is only allowed if this - // file is a directory. - ret.first = items.first().isDir(); - } - } return ret; }