1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Reanimated cut-, copy- and paste- functionality as preparation for moving to KonqUndoManager.

svn path=/trunk/playground/utils/dolphin/; revision=614325
This commit is contained in:
Peter Penz 2006-12-17 11:52:26 +00:00
parent 3b4dfa2040
commit c28c72619c
3 changed files with 40 additions and 34 deletions

View File

@ -657,33 +657,33 @@ void DolphinMainWindow::cut()
// apps. The "application/x-kde-cutselection" mimetype should be used instead, see KonqMimeData
// in libkonq
m_clipboardContainsCutData = true;
/* KDE4-TODO: Q3DragObject* data = new KUrlDrag(m_activeView->selectedUrls(),
widget());
QApplication::clipboard()->setData(data);*/
QMimeData* mimeData = new QMimeData();
const KUrl::List selectedUrls = m_activeView->selectedUrls();
selectedUrls.populateMimeData(mimeData);
QApplication::clipboard()->setMimeData(mimeData);
}
void DolphinMainWindow::copy()
{
m_clipboardContainsCutData = false;
/* KDE4-TODO:
Q3DragObject* data = new KUrlDrag(m_activeView->selectedUrls(),
widget());
QApplication::clipboard()->setData(data);*/
QMimeData* mimeData = new QMimeData();
const KUrl::List selectedUrls = m_activeView->selectedUrls();
selectedUrls.populateMimeData(mimeData);
QApplication::clipboard()->setMimeData(mimeData);
}
void DolphinMainWindow::paste()
{
/* KDE4-TODO: - see KonqOperations::doPaste
QClipboard* clipboard = QApplication::clipboard();
QMimeSource* data = clipboard->data();
if (!KUrlDrag::canDecode(data)) {
return;
}
const QMimeData* mimeData = clipboard->mimeData();
clearStatusBar();
KUrl::List sourceUrls;
KUrlDrag::decode(data, sourceUrls);
const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
// per default the pasting is done into the current Url of the view
KUrl destUrl(m_activeView->url());
@ -702,8 +702,12 @@ void DolphinMainWindow::paste()
}
}
updateViewProperties(sourceUrls);
// TODO #1: use libkonq commands (see doPaste() implementation
// KIO::Job* job = KIO::pasteClipboard(destUrl, this, false);
// ...
// TODO #2: this boolean doesn't work between instances of dolphin or with konqueror or with other
// apps. The "application/x-kde-cutselection" mimetype should be used instead, see KonqMimeData
// in libkonq
if (m_clipboardContainsCutData) {
moveUrls(sourceUrls, destUrl);
m_clipboardContainsCutData = false;
@ -711,7 +715,7 @@ void DolphinMainWindow::paste()
}
else {
copyUrls(sourceUrls, destUrl);
}*/
}
}
void DolphinMainWindow::updatePasteAction()
@ -723,13 +727,12 @@ void DolphinMainWindow::updatePasteAction()
QString text(i18n("Paste"));
QClipboard* clipboard = QApplication::clipboard();
const QMimeData* data = clipboard->mimeData();
/* KDE4-TODO:
if (KUrlDrag::canDecode(data)) {
const QMimeData* mimeData = clipboard->mimeData();
KUrl::List urls = KUrl::List::fromMimeData(mimeData);
if (!urls.isEmpty()) {
pasteAction->setEnabled(true);
KUrl::List urls;
KUrlDrag::decode(data, urls);
const int count = urls.count();
if (count == 1) {
pasteAction->setText(i18n("Paste 1 File"));
@ -738,10 +741,10 @@ void DolphinMainWindow::updatePasteAction()
pasteAction->setText(i18n("Paste %1 Files").arg(count));
}
}
else {*/
else {
pasteAction->setEnabled(false);
pasteAction->setText(i18n("Paste"));
//}
}
if (pasteAction->isEnabled()) {
KUrl::List urls = m_activeView->selectedUrls();
@ -1597,9 +1600,9 @@ void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
}
void DolphinMainWindow::addPendingUndoJob(KIO::Job* job,
DolphinCommand::Type commandType,
const KUrl::List& source,
const KUrl& dest)
DolphinCommand::Type commandType,
const KUrl::List& source,
const KUrl& dest)
{
connect(job, SIGNAL(result(KJob*)),
this, SLOT(addUndoOperation(KJob*)));

View File

@ -76,13 +76,15 @@ void UndoManager::addCommand(const DolphinCommand& command)
{
++m_historyIndex;
QList<DolphinCommand>::iterator it = m_history.begin();
it += m_historyIndex;
if (m_recordMacro) {
DolphinCommand macroCommand = command;
macroCommand.m_macroIndex = m_macroCounter;
m_history.insert(m_history.at(m_historyIndex), macroCommand);
m_history.insert(it, macroCommand);
}
else {
m_history.insert(m_history.at(m_historyIndex), command);
m_history.insert(it, command);
}
emit undoAvailable(true);
@ -125,7 +127,7 @@ void UndoManager::undo(DolphinMainWindow* mainWindow)
calcStepsCount(macroCount, progressCount);
/*
* KDE4, ### TODO Only here to avoid possible crash
* KDE4, ### TODO Only here to avoid possible crash
*/
ProgressIndicator progressIndicator(mainWindow, i18n("Executing undo operation..."),
i18n("Executed undo operation."),

View File

@ -21,9 +21,10 @@
#ifndef UNDOMANAGER_H
#define UNDOMANAGER_H
#include <qobject.h>
#include <QObject>
#include <QPointer>
#include <q3valuelist.h>
#include <QList>
#include <kurl.h>
#include <kio/jobclasses.h>
@ -127,7 +128,7 @@ public slots:
/**
* Performs a redo operation on the last command where an undo
* operation has been applied.
*
*
* @param mainwindow The mainwindow where to show progress
*/
void redo(DolphinMainWindow* mainwindow);
@ -182,7 +183,7 @@ private:
bool m_recordMacro;
int m_historyIndex;
int m_macroCounter;
Q3ValueList<DolphinCommand> m_history;
QList<DolphinCommand> m_history;
/**
* Dependent from the current history index \a m_historyIndex