m_isContextMenuOpen(false),
m_ignoreViewProperties(false),
m_assureVisibleCurrentIndex(false),
- m_selectClipboardItems(false),
m_mode(DolphinView::IconsView),
m_topLayout(0),
m_controller(0),
m_previewGenerator(0),
m_toolTipManager(0),
m_rootUrl(),
- m_currentItemUrl(),
+ m_activeItemUrl(),
m_createdItemUrl(),
m_selectedItems(),
+ m_newFileNames(),
m_expandedDragSource(0)
{
m_topLayout = new QVBoxLayout(this);
connect(&DolphinNewMenuObserver::instance(), SIGNAL(itemCreated(const KUrl&)),
this, SLOT(observeCreatedItem(const KUrl&)));
- // when a copy/move-operation has been finished, the pasted items should get selected
- connect(KIO::FileUndoManager::self(), SIGNAL(jobRecordingFinished(CommandType)),
- this, SLOT(slotJobRecordingFinished(CommandType)));
-
applyViewProperties(url);
m_topLayout->addWidget(itemView());
}
const QModelIndex currentIndex = selModel->currentIndex();
selModel->setCurrentIndex(currentIndex, QItemSelectionModel::Current |
QItemSelectionModel::Clear);
+ m_selectedItems.clear();
}
KFileItemList DolphinView::selectedItems() const
return m_columnView->selectedItems().count();
}
- return itemView()->selectionModel()->selection().count();
+ return itemView()->selectionModel()->selectedIndexes().count();
}
void DolphinView::setContentsPosition(int x, int y)
void DolphinView::setUrl(const KUrl& url)
{
- // remember current item candidate (see slotDirListerCompleted())
- m_selectClipboardItems = false;
- m_currentItemUrl = url;
+ m_newFileNames.clear();
updateView(url, KUrl());
}
if (itemCount > 1) {
// More than one item has been selected for renaming. Open
// a rename dialog and rename all items afterwards.
- RenameDialog dialog(this, items);
- if (dialog.exec() == QDialog::Rejected) {
+ QPointer<RenameDialog> dialog = new RenameDialog(this, items);
+ if (dialog->exec() == QDialog::Rejected) {
+ delete dialog;
return;
}
- const QString newName = dialog.newName();
+ const QString newName = dialog->newName();
if (newName.isEmpty()) {
- emit errorMessage(dialog.errorString());
+ emit errorMessage(dialog->errorString());
+ delete dialog;
return;
}
+ delete dialog;
+
+ // the selection would be invalid after renaming the items, so just clear
+ // it before
+ clearSelection();
// TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations
// as one operation instead of n rename operations like it is done now...
} else {
Q_ASSERT(itemCount == 1);
- RenameDialog dialog(this, items);
- if (dialog.exec() == QDialog::Rejected) {
+ QPointer<RenameDialog> dialog = new RenameDialog(this, items);
+ if (dialog->exec() == QDialog::Rejected) {
+ delete dialog;
return;
}
- const QString& newName = dialog.newName();
+ const QString newName = dialog->newName();
if (newName.isEmpty()) {
- emit errorMessage(dialog.errorString());
+ emit errorMessage(dialog->errorString());
+ delete dialog;
return;
}
+ delete dialog;
const KUrl& oldUrl = items.first().url();
KUrl newUrl = oldUrl;
const KUrl& destPath,
QDropEvent* event)
{
+ addNewFileNames(event->mimeData());
DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
}
return m_tabsForFiles;
}
+void DolphinView::activateItem(const KUrl& url)
+{
+ m_activeItemUrl = url;
+}
+
bool DolphinView::itemsExpandable() const
{
return (m_detailsView != 0) && m_detailsView->itemsExpandable();
changeSelection(m_selectedItems);
}
-void DolphinView::slotJobRecordingFinished(CommandType command)
-{
- // Assure that the pasted items get selected. This must be done
- // asynchronously in slotDirListerCompleted().
- m_selectClipboardItems = ((command == KIO::FileUndoManager::Copy) ||
- (command == KIO::FileUndoManager::Move)) &&
- !hasSelection();
-}
-
void DolphinView::emitContentsMoved()
{
// only emit the contents moved signal if:
void DolphinView::slotDirListerCompleted()
{
- if (!m_currentItemUrl.isEmpty()) {
+ if (!m_activeItemUrl.isEmpty()) {
// assure that the current item remains visible
- const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl);
+ const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_activeItemUrl);
if (dirIndex.isValid()) {
const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
QAbstractItemView* view = itemView();
if (clearSelection) {
view->clearSelection();
}
+ m_activeItemUrl.clear();
}
- m_currentItemUrl.clear();
}
- if (m_selectClipboardItems) {
- m_selectClipboardItems = false;
-
- // select all items that have been pasted from the clipboard to
- // the current directory
- const QMimeData* mimeData = QApplication::clipboard()->mimeData();
- const KUrl::List copiedUrls = KUrl::List::fromMimeData(mimeData);
-
- QSet<QString> fileNames;
- foreach (const KUrl& url, copiedUrls) {
- fileNames.insert(url.fileName());
- }
-
+ if (!m_newFileNames.isEmpty()) {
+ // select all newly added items created by a paste operation or
+ // a drag & drop operation
QItemSelectionModel* selectionModel = itemView()->selectionModel();
const int rowCount = m_proxyModel->rowCount();
for (int row = 0; row < rowCount; ++row) {
const QModelIndex proxyIndex = m_proxyModel->index(row, 0);
const QModelIndex dirIndex = m_proxyModel->mapToSource(proxyIndex);
const KUrl url = m_dolphinModel->itemForIndex(dirIndex).url();
- if (fileNames.contains(url.fileName())) {
+ if (m_newFileNames.contains(url.fileName())) {
selectionModel->select(proxyIndex, QItemSelectionModel::Select);
}
}
+
+ m_newFileNames.clear();
}
}
void DolphinView::pasteToUrl(const KUrl& url)
{
+ addNewFileNames(QApplication::clipboard()->mimeData());
KonqOperations::doPaste(this, url);
}
return m_dolphinModel->mimeData(selection.indexes());
}
+void DolphinView::addNewFileNames(const QMimeData* mimeData)
+{
+ const KUrl::List urls = KUrl::List::fromMimeData(mimeData);
+ foreach (const KUrl& url, urls) {
+ m_newFileNames.insert(url.fileName());
+ }
+}
#include "dolphinview.moc"