X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d9ac44e08f8d2abe7104c20e308d05038e1896da..1582bd856557c1f290f95478afda285ea75de75e:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 3602d1563..34bd6f688 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -59,6 +59,7 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow, bool showHiddenFiles) : QWidget(parent), m_showProgress(false), + m_blockContentsMovedSignal(false), m_mode(mode), m_iconSize(0), m_folderCount(0), @@ -265,45 +266,31 @@ void DolphinView::renameSelectedItems() } else { // TODO: check how this can be integrated into KonqUndoManager/KonqOperations - - //UndoManager& undoMan = UndoManager::instance(); - //undoMan.beginMacro(); - + // as one operation instead of n rename operations like it is done now... Q_ASSERT(newName.contains('#')); - const int urlsCount = urls.count(); - // iterate through all selected items and rename them... const int replaceIndex = newName.indexOf('#'); Q_ASSERT(replaceIndex >= 0); - for (int i = 0; i < urlsCount; ++i) { - const KUrl& source = urls[i]; + int index = 1; + + KUrl::List::const_iterator it = urls.begin(); + KUrl::List::const_iterator end = urls.end(); + while (it != end) { + const KUrl& oldUrl = *it; QString number; - number.setNum(i + 1); + number.setNum(index++); QString name(newName); name.replace(replaceIndex, 1, number); - if (source.fileName() != name) { - KUrl dest(source.upUrl()); - dest.addPath(name); - - const bool destExists = KIO::NetAccess::exists(dest, false, view); - if (destExists) { - view->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name), - DolphinStatusBar::Error); - break; - } - else if (KIO::NetAccess::file_move(source, dest)) { - // TODO: From the users point of view he executed one 'rename n files' operation, - // but internally we store it as n 'rename 1 file' operations for the undo mechanism. - //DolphinCommand command(DolphinCommand::Rename, source, dest); - //undoMan.addCommand(command); - } + if (oldUrl.fileName() != name) { + KUrl newUrl(oldUrl.upUrl()); + newUrl.addPath(name); + m_mainWindow->rename(oldUrl, newUrl); } + ++it; } - - //undoMan.endMacro(); } } else { @@ -311,8 +298,9 @@ void DolphinView::renameSelectedItems() // renaming mechanism from the views. Q_ASSERT(urls.count() == 1); - // TODO: until KFileItemDelegate supports editing, use the the Dolphin - // rename dialog as temporary workaround: + // 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(urls); if (dialog.exec() == QDialog::Rejected) { return; @@ -473,6 +461,11 @@ bool DolphinView::hasSelection() const return itemView()->selectionModel()->hasSelection(); } +void DolphinView::clearSelection() +{ + itemView()->selectionModel()->clear(); +} + KFileItemList DolphinView::selectedItems() const { const QAbstractItemView* view = itemView(); @@ -739,6 +732,7 @@ void DolphinView::updateItemCount() updateStatusBar(); + m_blockContentsMovedSignal = false; QTimer::singleShot(0, this, SLOT(restoreContentsPos())); } @@ -749,11 +743,6 @@ void DolphinView::generatePreviews(const KFileItemList& items) connect(job, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)), this, SLOT(showPreview(const KFileItem*, const QPixmap&))); } - - const QMimeData* mimeData = QApplication::clipboard()->mimeData(); - if (KonqMimeData::decodeIsCutSelection(mimeData)) { - QTimer::singleShot(0, this, SLOT(applyCutEffect())); - } } void DolphinView::showPreview(const KFileItem* item, const QPixmap& pixmap) @@ -834,6 +823,7 @@ void DolphinView::startDirLister(const KUrl& url, bool reload) m_statusBar->setProgress(0); } + m_blockContentsMovedSignal = true; m_dirLister->stop(); m_dirLister->openUrl(url, false, reload); } @@ -986,7 +976,7 @@ void DolphinView::openContextMenu(const QPoint& pos) item = fileItem(index); } - DolphinContextMenu contextMenu(this, item); + DolphinContextMenu contextMenu(m_mainWindow, item, url()); contextMenu.open(); } @@ -1013,8 +1003,6 @@ void DolphinView::dropUrls(const KUrl::List& urls, const KUrl& destination = (directory == 0) ? url() : directory->url(); - kDebug() << "DolphinView::dropUrls() - destination: " << destination.prettyUrl() << endl; - dropUrls(urls, destination); } @@ -1047,7 +1035,9 @@ void DolphinView::updateSortOrder(Qt::SortOrder order) void DolphinView::emitContentsMoved() { - emit contentsMoved(contentsX(), contentsY()); + if (!m_blockContentsMovedSignal) { + emit contentsMoved(contentsX(), contentsY()); + } } void DolphinView::updateActivationState()