* used new signals jobRecordingStarted() and jobRecordingFinished from FileUndoManager to inform the user in the statusbar when a recorded command has been finished
svn path=/trunk/KDE/kdebase/apps/; revision=866777
#include "dolphindropcontroller.h"
#include <kfileitem.h>
-#include <klocale.h>
-#include <kicon.h>
-#include <QApplication>
-#include <kdebug.h>
-#include <kmenu.h>
#include <konq_operations.h>
-DolphinDropController::DolphinDropController(QWidget* parentWidget)
- : QObject(parentWidget), m_parentWidget(parentWidget)
-{
-}
-
-DolphinDropController::~DolphinDropController()
-{
-}
-
void DolphinDropController::dropUrls(const KFileItem& destItem,
const KUrl& destPath,
- QDropEvent* event)
+ QDropEvent* event,
+ QWidget* widget)
{
const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile());
const KUrl destination = dropToItem ? destItem.url() : destPath;
const KUrl sourceDir = KUrl(urls.first().directory());
if (sourceDir != destination) {
if (dropToItem) {
- KonqOperations::doDrop(destItem, destination, event, m_parentWidget);
+ KonqOperations::doDrop(destItem, destination, event, widget);
} else {
- KonqOperations::doDrop(KFileItem(), destination, event, m_parentWidget);
+ KonqOperations::doDrop(KFileItem(), destination, event, widget);
}
}
- // TODO: emit doingOperation, so that the main window gets informed about
- // about the finished operations
-}
-
-#include "dolphindropcontroller.moc"
+}
\ No newline at end of file
#ifndef DOLPHINDROPCONTROLLER_H
#define DOLPHINDROPCONTROLLER_H
-#include <QObject>
-#include <kio/fileundomanager.h>
-
#include "libdolphin_export.h"
class QDropEvent;
+class QWidget;
class KUrl;
class KFileItem;
/**
* @brief Handler for drop events, shared between DolphinView and TreeViewSidebarPage
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinDropController : public QObject
+class LIBDOLPHINPRIVATE_EXPORT DolphinDropController
{
- Q_OBJECT
public:
- explicit DolphinDropController(QWidget* parentWidget);
- virtual ~DolphinDropController();
-
/**
* Handles the dropping of URLs to the given
* destination. A context menu with the options
* 'Cancel' is offered to the user.
* @param destItem Item of the destination (can be null, see KFileItem::isNull()).
* @param destPath Path of the destination.
- * @param event Drop event
- */
- void dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event);
-
-signals:
- /**
- * Is emitted when renaming, copying, moving, linking etc.
- * Used for feedback in the mainwindow.
+ * @param event Drop event.
+ * @param widget Source widget where the dragging has been started.
*/
- void doingOperation(KIO::FileUndoManager::CommandType type);
-
-private:
- QWidget* m_parentWidget;
+ static void dropUrls(const KFileItem& destItem,
+ const KUrl& destPath,
+ QDropEvent* event,
+ QWidget* widget);
};
#endif // DOLPHINDROPCONTROLLER_H
void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
{
- DolphinDropController dropController(parent);
- // forward doingOperation signal up to the mainwindow
- connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
- this, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)));
- dropController.dropUrls(KFileItem(), dest, event);
+ DolphinDropController::dropUrls(KFileItem(), dest, event, parent);
}
void DolphinFilePlacesView::emitExtendedUrlChangedSignal(const KUrl& url)
this, SLOT(slotUndoAvailable(bool)));
connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
this, SLOT(slotUndoTextChanged(const QString&)));
+ connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)),
+ this, SLOT(clearStatusBar()));
+ connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
+ this, SLOT(showCommand(CommandType)));
connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)),
this, SLOT(slotHandlePlacesError(const QString&)));
}
m_viewTab[m_tabIndex].secondaryView = container;
}
-void DolphinMainWindow::slotDoingOperation(KIO::FileUndoManager::CommandType commandType)
+void DolphinMainWindow::showCommand(CommandType command)
{
- clearStatusBar();
- m_undoCommandTypes.append(commandType);
+ DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
+ switch (command) {
+ case KIO::FileUndoManager::Copy:
+ statusBar->setMessage(i18nc("@info:status", "Copy operation completed."),
+ DolphinStatusBar::OperationCompleted);
+ break;
+ case KIO::FileUndoManager::Move:
+ statusBar->setMessage(i18nc("@info:status", "Move operation completed."),
+ DolphinStatusBar::OperationCompleted);
+ break;
+ case KIO::FileUndoManager::Link:
+ statusBar->setMessage(i18nc("@info:status", "Link operation completed."),
+ DolphinStatusBar::OperationCompleted);
+ break;
+ case KIO::FileUndoManager::Trash:
+ statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."),
+ DolphinStatusBar::OperationCompleted);
+ break;
+ case KIO::FileUndoManager::Rename:
+ statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."),
+ DolphinStatusBar::OperationCompleted);
+ break;
+
+ case KIO::FileUndoManager::Mkdir:
+ statusBar->setMessage(i18nc("@info:status", "Created folder."),
+ DolphinStatusBar::OperationCompleted);
+ break;
+
+ default:
+ break;
+ }
}
void DolphinMainWindow::refreshViews()
setActiveViewContainer(activeViewContainer);
}
-void DolphinMainWindow::dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event)
-{
- DolphinDropController dropController(this);
- connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
- this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
- dropController.dropUrls(destItem, destPath, event);
-}
-
void DolphinMainWindow::pasteIntoFolder()
{
m_activeViewContainer->view()->pasteIntoFolder();
if (undoAction != 0) {
undoAction->setEnabled(available);
}
-
- if (available && (m_undoCommandTypes.count() > 0)) {
- const KIO::FileUndoManager::CommandType command = m_undoCommandTypes.takeFirst();
- DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
- switch (command) {
- case KIO::FileUndoManager::Copy:
- statusBar->setMessage(i18nc("@info:status", "Copy operation completed."),
- DolphinStatusBar::OperationCompleted);
- break;
- case KIO::FileUndoManager::Move:
- statusBar->setMessage(i18nc("@info:status", "Move operation completed."),
- DolphinStatusBar::OperationCompleted);
- break;
- case KIO::FileUndoManager::Link:
- statusBar->setMessage(i18nc("@info:status", "Link operation completed."),
- DolphinStatusBar::OperationCompleted);
- break;
- case KIO::FileUndoManager::Trash:
- statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."),
- DolphinStatusBar::OperationCompleted);
- break;
- case KIO::FileUndoManager::Rename:
- statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."),
- DolphinStatusBar::OperationCompleted);
- break;
-
- case KIO::FileUndoManager::Mkdir:
- statusBar->setMessage(i18nc("@info:status", "Created folder."),
- DolphinStatusBar::OperationCompleted);
- break;
-
- default:
- break;
- }
-
- }
}
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
connect(treeWidget, SIGNAL(changeSelection(KFileItemList)),
this, SLOT(changeSelection(KFileItemList)));
- connect(treeWidget, SIGNAL(urlsDropped(KFileItem, KUrl, QDropEvent*)),
- this, SLOT(dropUrls(KFileItem, KUrl, QDropEvent*)));
// setup "Terminal"
#ifndef Q_OS_WIN
this, SLOT(slotRequestItemInfo(KFileItem)));
connect(view, SIGNAL(activated()),
this, SLOT(toggleActiveView()));
- connect(view, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
- this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
connect(view, SIGNAL(tabRequested(const KUrl&)),
this, SLOT(openNewTab(const KUrl&)));
#include <QtCore/QList>
+typedef KIO::FileUndoManager::CommandType CommandType;
+
class KAction;
class DolphinViewActionHandler;
class DolphinApplication;
KAction* showMenuBarAction() const;
public slots:
- /**
- * Handles the dropping of URLs to the given
- * destination. This is only called by the TreeViewSidebarPage.
- */
- void dropUrls(const KFileItem& destItem,
- const KUrl& destPath,
- QDropEvent* event);
-
/**
* Pastes the clipboard data into the currently selected folder
* of the active view. If not exactly one folder is selected,
/** Toggles the active view if two views are shown within the main window. */
void toggleActiveView();
- /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
- void slotDoingOperation(KIO::FileUndoManager::CommandType type);
+ /**
+ * Indicates in the statusbar that the execution of the command \a command
+ * has been finished.
+ */
+ void showCommand(CommandType command);
/**
* Activates the tab with the index \a index, which means that the current view
QList<ViewTab> m_viewTab;
DolphinViewActionHandler* m_actionHandler;
-
- /// remember pending undo operations until they are finished
- QList<KIO::FileUndoManager::CommandType> m_undoCommandTypes;
};
inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
KUrl newUrl = oldUrl;
newUrl.setFileName(name);
KonqOperations::rename(this, oldUrl, newUrl);
- emit doingOperation(KIO::FileUndoManager::Rename);
}
}
}
KUrl newUrl = oldUrl;
newUrl.setFileName(newName);
KonqOperations::rename(this, oldUrl, newUrl);
- emit doingOperation(KIO::FileUndoManager::Rename);
}
}
}
void DolphinView::trashSelectedItems()
{
- emit doingOperation(KIO::FileUndoManager::Trash);
const KUrl::List list = simplifiedSelectedUrls();
KonqOperations::del(this, KonqOperations::TRASH, list);
}
const KUrl& destPath,
QDropEvent* event)
{
- DolphinDropController dropController(this);
- // forward doingOperation signal up to the mainwindow
- connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
- this, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)));
- dropController.dropUrls(destItem, destPath, event);
+ DolphinDropController::dropUrls(destItem, destPath, event, this);
}
void DolphinView::updateSorting(DolphinView::Sorting sorting)
const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
if (KonqMimeData::decodeIsCutSelection(mimeData)) {
KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url);
- emit doingOperation(KIO::FileUndoManager::Move);
clipboard->clear();
} else {
KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url);
- emit doingOperation(KIO::FileUndoManager::Copy);
}
}
*/
void startedPathLoading(const KUrl& url);
- /**
- * Is emitted when renaming, copying, moving, linking etc.
- * Used for feedback in the mainwindow.
- */
- void doingOperation(KIO::FileUndoManager::CommandType type);
-
protected:
/** @see QWidget::mouseReleaseEvent */
virtual void mouseReleaseEvent(QMouseEvent* event);
#include "dolphinmodel.h"
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
+#include "dolphindropcontroller.h"
#include "dolphinstatusbar.h"
#include "dolphinmainwindow.h"
#include "dolphindirlister.h"
m_topLayout->setMargin(0);
m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this);
- connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&)),
- m_mainWindow, SLOT(dropUrls(const KUrl::List&, const KUrl&)));
+ connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl&, QDropEvent*)),
+ this, SLOT(dropUrls(const KUrl&, QDropEvent*)));
connect(m_urlNavigator, SIGNAL(activated()),
this, SLOT(activate()));
m_urlNavigator->saveRootUrl(m_view->rootUrl());
}
+void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
+{
+ DolphinDropController::dropUrls(KFileItem(), destination, event, this);
+}
+
void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
{
KUrl url = item.targetUrl();
* into the URL navigator.
*/
void saveRootUrl(const KUrl& url);
+
+ /**
+ * Is connected with the URL navigator and drops the URLs
+ * above the destination \a destination.
+ */
+ void dropUrls(const KUrl& destination, QDropEvent* event);
private:
/**
#include "treeviewsidebarpage.h"
+#include "dolphindropcontroller.h"
#include "dolphinmodel.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
KFileItem item = m_dolphinModel->itemForIndex(dirIndex);
Q_ASSERT(!item.isNull());
if (item.isDir()) {
- emit urlsDropped(item, item.url(), event);
+ DolphinDropController::dropUrls(item, item.url(), event, this);
}
}
}
*/
void changeSelection(const KFileItemList& selection);
- /**
- * This signal is emitted whenever a drop action on this widget needs the
- * MainWindow's attention.
- */
- void urlsDropped(const KFileItem& destItem, const KUrl& destPath, QDropEvent* event);
-
public slots:
/**
* Changes the current selection inside the tree to \a url.