dolphinsortfilterproxymodel.cpp
renamedialog.cpp
dolphinview.cpp
+ dolphindropcontroller.cpp
)
kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
#include "dolphincolumnview.h"
-#include "dolphinmodel.h"
#include "dolphincolumnwidget.h"
#include "dolphincontroller.h"
-#include "dolphindirlister.h"
-#include "dolphinmodel.h"
-#include "dolphinsortfilterproxymodel.h"
#include "dolphinsettings.h"
#include "dolphin_columnmodesettings.h"
-#include <kcolorutils.h>
-#include <kcolorscheme.h>
-#include <kdirlister.h>
-
-#include <QAbstractProxyModel>
-#include <QApplication>
#include <QPoint>
#include <QScrollBar>
-#include <QTimer>
#include <QTimeLine>
DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* controller) :
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
#include "dolphindirlister.h"
-#include "dolphinmodel.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinsettings.h"
#include "dolphin_columnmodesettings.h"
#include "draganddrophelper.h"
-#include <kcolorutils.h>
#include <kcolorscheme.h>
#include <kdirlister.h>
#include <kfileitem.h>
#include <kmimetyperesolver.h>
#include <konqmimedata.h>
-#include <QAbstractProxyModel>
#include <QApplication>
#include <QClipboard>
+#include <QPainter>
#include <QPoint>
-#include <QScrollBar>
-#include <QTimer>
-#include <QTimeLine>
DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
DolphinColumnView* columnView,
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
+ * Copyright (C) 2007 by David Faure <faure@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "dolphindropcontroller.h"
+#include <klocale.h>
+#include <kicon.h>
+#include <QApplication>
+#include <kdebug.h>
+#include <kmenu.h>
+#include <konq_operations.h>
+
+// TODO replace with KonqOperations::doDrop [or move doDrop code into this class]
+// Note that this means changing the DolphinDropController controller usage
+// to "create with new and let it autodelete" instead of on stack, since doDrop is async.
+
+DolphinDropController::DolphinDropController(QWidget* parentWidget)
+ : QObject(parentWidget), m_parentWidget(parentWidget)
+{
+}
+
+DolphinDropController::~DolphinDropController()
+{
+}
+
+void DolphinDropController::dropUrls(const KUrl::List& urls,
+ const KUrl& destination)
+{
+ kDebug() << "Source" << urls;
+ kDebug() << "Destination:" << destination;
+
+ Qt::DropAction action = Qt::CopyAction;
+
+ Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
+ const bool shiftPressed = modifier & Qt::ShiftModifier;
+ const bool controlPressed = modifier & Qt::ControlModifier;
+ if (shiftPressed && controlPressed) {
+ // shortcut for 'Link Here' is used
+ action = Qt::LinkAction;
+ } else if (shiftPressed) {
+ // shortcut for 'Move Here' is used
+ action = Qt::MoveAction;
+ } else if (controlPressed) {
+ // shortcut for 'Copy Here' is used
+ action = Qt::CopyAction;
+ } else {
+ // open a context menu which offers the following actions:
+ // - Move Here
+ // - Copy Here
+ // - Link Here
+ // - Cancel
+
+ KMenu popup(m_parentWidget);
+
+ QString seq = QKeySequence(Qt::ShiftModifier).toString();
+ seq.chop(1); // chop superfluous '+'
+ QAction* moveAction = popup.addAction(KIcon("go-jump"),
+ i18nc("@action:inmenu",
+ "&Move Here\t<shortcut>%1</shortcut>", seq));
+
+ seq = QKeySequence(Qt::ControlModifier).toString();
+ seq.chop(1);
+ QAction* copyAction = popup.addAction(KIcon("edit-copy"),
+ i18nc("@action:inmenu",
+ "&Copy Here\t<shortcut>%1</shortcut>", seq));
+
+ seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString();
+ seq.chop(1);
+ QAction* linkAction = popup.addAction(KIcon("insert-link"),
+ i18nc("@action:inmenu",
+ "&Link Here\t<shortcut>%1</shortcut>", seq));
+
+ popup.addSeparator();
+ popup.addAction(KIcon("process-stop"), i18nc("@action:inmenu", "Cancel"));
+
+ QAction* activatedAction = popup.exec(QCursor::pos());
+ if (activatedAction == moveAction) {
+ action = Qt::MoveAction;
+ } else if (activatedAction == copyAction) {
+ action = Qt::CopyAction;
+ } else if (activatedAction == linkAction) {
+ action = Qt::LinkAction;
+ } else {
+ return;
+ }
+ }
+
+ switch (action) {
+ case Qt::MoveAction:
+ KonqOperations::copy(m_parentWidget, KonqOperations::MOVE, urls, destination);
+ emit doingOperation(KonqFileUndoManager::MOVE);
+ break;
+
+ case Qt::CopyAction:
+ KonqOperations::copy(m_parentWidget, KonqOperations::COPY, urls, destination);
+ emit doingOperation(KonqFileUndoManager::COPY);
+ break;
+
+ case Qt::LinkAction:
+ KonqOperations::copy(m_parentWidget, KonqOperations::LINK, urls, destination);
+ emit doingOperation(KonqFileUndoManager::LINK);
+ break;
+
+ default:
+ break;
+ }
+}
+
+#include "dolphindropcontroller.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2007 by David Faure <faure@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef DOLPHINDROPCONTROLLER_H
+#define DOLPHINDROPCONTROLLER_H
+
+#include <QObject>
+#include <kurl.h>
+#include <konq_fileundomanager.h>
+
+#include "libdolphin_export.h"
+
+/**
+ * @brief Handler for drop events, shared between DolphinView and TreeViewSidebarPage
+ */
+class LIBDOLPHINPRIVATE_EXPORT DolphinDropController : public QObject
+{
+ Q_OBJECT
+public:
+ explicit DolphinDropController(QWidget* parentWidget);
+ virtual ~DolphinDropController();
+
+ /**
+ * Handles the dropping of URLs to the given
+ * destination. A context menu with the options
+ * 'Move Here', 'Copy Here', 'Link Here' and
+ * 'Cancel' is offered to the user.
+ * @param urls List of URLs which have been
+ * dropped.
+ * @param destination Destination URL, where the
+ * list or URLs should be moved,
+ * copied or linked to.
+ */
+ void dropUrls(const KUrl::List& urls,
+ const KUrl& destination);
+
+signals:
+ /**
+ * Is emitted when renaming, copying, moving, linking etc.
+ * Used for feedback in the mainwindow.
+ */
+ void doingOperation(KonqFileUndoManager::CommandType type);
+
+private:
+ QWidget* m_parentWidget;
+};
+
+#endif // DOLPHINDROPCONTROLLER_H
setDirtyRegion(m_dropRect);
m_dropRect.setSize(QSize()); // set as invalid
+ bool destIsDir = false;
if (index.isValid()) {
const KFileItem item = itemForIndex(index);
if (!item.isNull() && item.isDir()) {
m_dropRect = visualRect(index);
+ destIsDir = true;
}
+ } else { // dropping on viewport
+ destIsDir = true;
}
+ if (destIsDir && event->mimeData()->hasUrls()) {
+ event->acceptProposedAction();
+ }
+
setDirtyRegion(m_dropRect);
}
***************************************************************************/
#include "dolphinmainwindow.h"
+#include "dolphindropcontroller.h"
#include <config-nepomuk.h>
#include <kmenubar.h>
#include <kmessagebox.h>
#include <konqmimedata.h>
-#include <konq_operations.h>
#include <kpropertiesdialog.h>
#include <kprotocolinfo.h>
#include <ktoggleaction.h>
void DolphinMainWindow::dropUrls(const KUrl::List& urls,
const KUrl& destination)
{
- kDebug() << "Source" << urls;
- kDebug() << "Destination:" << destination;
-
- Qt::DropAction action = Qt::CopyAction;
-
- Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
- const bool shiftPressed = modifier & Qt::ShiftModifier;
- const bool controlPressed = modifier & Qt::ControlModifier;
- if (shiftPressed && controlPressed) {
- // shortcut for 'Link Here' is used
- action = Qt::LinkAction;
- } else if (shiftPressed) {
- // shortcut for 'Move Here' is used
- action = Qt::MoveAction;
- } else if (controlPressed) {
- // shortcut for 'Copy Here' is used
- action = Qt::CopyAction;
- } else {
- // open a context menu which offers the following actions:
- // - Move Here
- // - Copy Here
- // - Link Here
- // - Cancel
-
- KMenu popup(this);
-
- QString seq = QKeySequence(Qt::ShiftModifier).toString();
- seq.chop(1); // chop superfluous '+'
- QAction* moveAction = popup.addAction(KIcon("go-jump"),
- i18nc("@action:inmenu",
- "&Move Here\t<shortcut>%1</shortcut>", seq));
-
- seq = QKeySequence(Qt::ControlModifier).toString();
- seq.chop(1);
- QAction* copyAction = popup.addAction(KIcon("edit-copy"),
- i18nc("@action:inmenu",
- "&Copy Here\t<shortcut>%1</shortcut>", seq));
-
- seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString();
- seq.chop(1);
- QAction* linkAction = popup.addAction(KIcon("insert-link"),
- i18nc("@action:inmenu",
- "&Link Here\t<shortcut>%1</shortcut>", seq));
-
- popup.addSeparator();
- popup.addAction(KIcon("process-stop"), i18nc("@action:inmenu", "Cancel"));
-
- QAction* activatedAction = popup.exec(QCursor::pos());
- if (activatedAction == moveAction) {
- action = Qt::MoveAction;
- } else if (activatedAction == copyAction) {
- action = Qt::CopyAction;
- } else if (activatedAction == linkAction) {
- action = Qt::LinkAction;
- } else {
- return;
- }
- }
-
- switch (action) {
- case Qt::MoveAction:
- KonqOperations::copy(this, KonqOperations::MOVE, urls, destination);
- m_undoCommandTypes.append(KonqFileUndoManager::MOVE);
- break;
-
- case Qt::CopyAction:
- KonqOperations::copy(this, KonqOperations::COPY, urls, destination);
- m_undoCommandTypes.append(KonqFileUndoManager::COPY);
- break;
-
- case Qt::LinkAction:
- KonqOperations::copy(this, KonqOperations::LINK, urls, destination);
- m_undoCommandTypes.append(KonqFileUndoManager::LINK);
- break;
-
- default:
- break;
- }
+ DolphinDropController dropController(this);
+ connect(&dropController, SIGNAL(doingOperation(KonqFileUndoManager::CommandType)),
+ this, SLOT(slotDoingOperation(KonqFileUndoManager::CommandType)));
+ dropController.dropUrls(urls, destination);
}
void DolphinMainWindow::changeUrl(const KUrl& url)
public slots:
/**
* Handles the dropping of URLs to the given
- * destination. A context menu with the options
- * 'Move Here', 'Copy Here', 'Link Here' and
- * 'Cancel' is offered to the user.
- * @param urls List of URLs which have been
- * dropped.
- * @param destination Destination URL, where the
- * list or URLs should be moved,
- * copied or linked to.
+ * destination. This is only called by the TreeViewSidebarPage.
*/
void dropUrls(const KUrl::List& urls,
const KUrl& destination);
// TODO sort_by_* actions
// TODO show_*_info actions
- // TODO connect to urlsDropped
-
// TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
// (sort of spacial navigation)
-
- // TODO MMB-click should do something like KonqDirPart::mmbClicked
}
DolphinPart::~DolphinPart()
void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
{
- // Yes, DolphinMainWindow has very similar code :/
const bool hasSelection = !selection.isEmpty();
if (!hasSelection) {
stateChanged("has_no_selection");
void DolphinPart::slotItemTriggered(const KFileItem& item)
{
- qDebug() << QApplication::mouseButtons();
+ // MMB click support.
+ // TODO: this doesn't work, mouseButtons() is always 0.
+ // Issue N176832 for the missing QAIV signal; task 177399
+ kDebug() << QApplication::mouseButtons();
if (QApplication::mouseButtons() & Qt::MidButton) {
- qDebug() << "MMB!!" << item.mimetype();
+ kDebug() << "MMB!!" << item.mimetype();
if (item.mimeTypePtr()->is("inode/directory")) {
KParts::OpenUrlArguments args;
args.setMimeType( item.mimetype() );
emit m_extension->createNewWindow( item.url(), args );
} else {
- qDebug() << "run()";
+ kDebug() << "run()";
item.run();
}
} else {
// Left button. [Right button goes to slotOpenContextMenu before triggered can be emitted]
- qDebug() << "LMB";
+ kDebug() << "LMB";
emit m_extension->openUrlRequest(item.url());
}
}
#include <QBoxLayout>
#include <QTimer>
#include <QScrollBar>
-#include <QClipboard>
#include <kcolorscheme.h>
#include <kdirlister.h>
#include <kio/netaccess.h>
#include <kio/previewjob.h>
#include <kjob.h>
+#include <kmenu.h>
#include <kmimetyperesolver.h>
#include <konqmimedata.h>
#include <konq_operations.h>
#include <kurl.h>
+#include "dolphindropcontroller.h"
#include "dolphinmodel.h"
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
const KUrl& destPath,
const KFileItem& destItem)
{
+ Q_ASSERT(!urls.isEmpty());
const KUrl& destination = !destItem.isNull() && destItem.isDir() ?
destItem.url() : destPath;
const KUrl sourceDir = KUrl(urls.first().directory());
void DolphinView::dropUrls(const KUrl::List& urls,
const KUrl& destination)
{
- emit urlsDropped(urls, destination);
+ DolphinDropController dropController(this);
+ // forward doingOperation signal up to the mainwindow
+ connect(&dropController, SIGNAL(doingOperation(KonqFileUndoManager::CommandType)),
+ this, SIGNAL(doingOperation(KonqFileUndoManager::CommandType)));
+ dropController.dropUrls(urls, destination);
}
void DolphinView::updateSorting(DolphinView::Sorting sorting)
*/
void requestContextMenu(const KFileItem& item, const KUrl& url);
- /**
- * Is emitted if the URLs \a are dropped to the destination URL
- * \a destination. No operation is done within the DolphinView, the
- * receiver of the signal has to take care about the corresponding
- * operation.
- */
- void urlsDropped(const KUrl::List& urls, const KUrl& destination);
-
/**
* Is emitted if an information message with the content \a msg
* should be shown.
const KFileItem& destItem);
/**
- * Drops the URLs \a urls at the
- * destination \a destination.
+ * Handles the dropping of URLs to the given destination.
+ * @see DolphinDropController
*/
void dropUrls(const KUrl::List& urls,
const KUrl& destination);
/**
* Updates the view properties of the current URL to the
- * additional informations given by \a info.
+ * additional information given by \a info.
*/
void updateAdditionalInfo(const KFileItemDelegate::InformationList& info);
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "renamedialogtest.h"
+#include <qtest_kde.h>
#include <renamedialog.h>
QTEST_KDEMAIN(RenameDialogTest, NoGUI)
#include "treeviewsidebarpage.h"
#include "dolphinmodel.h"
-#include "dolphinmainwindow.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
#include "dolphinsettings.h"