mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: remove non-operational KIO::FileUndoManager bits
yep, half of that class was non-operationl Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b5b73968c3
commit
8f72524923
5 changed files with 14 additions and 176 deletions
|
@ -78,13 +78,6 @@ set(kiocore_STAT_SRCS
|
||||||
kio/kautomount.cpp
|
kio/kautomount.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
qt4_add_dbus_adaptor(kiocore_STAT_SRCS
|
|
||||||
kio/org.kde.kio.FileUndoManager.xml
|
|
||||||
fileundomanager_p.h KIO::FileUndoManagerPrivate
|
|
||||||
fileundomanager_adaptor
|
|
||||||
KIOFileUndoManagerAdaptor
|
|
||||||
)
|
|
||||||
|
|
||||||
set(kbookmarks_STAT_SRCS
|
set(kbookmarks_STAT_SRCS
|
||||||
bookmarks/kbookmark.cc
|
bookmarks/kbookmark.cc
|
||||||
bookmarks/kbookmarkmanager.cc
|
bookmarks/kbookmarkmanager.cc
|
||||||
|
@ -273,13 +266,6 @@ install(
|
||||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}
|
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
|
||||||
FILES
|
|
||||||
kio/org.kde.KDirNotify.xml
|
|
||||||
kio/org.kde.kio.FileUndoManager.xml
|
|
||||||
DESTINATION ${KDE4_DBUS_INTERFACES_INSTALL_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
kfile/images/yes.png
|
kfile/images/yes.png
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "fileundomanager.h"
|
#include "fileundomanager.h"
|
||||||
#include "fileundomanager_p.h"
|
#include "fileundomanager_p.h"
|
||||||
#include "clipboardupdater_p.h"
|
#include "clipboardupdater_p.h"
|
||||||
#include "fileundomanager_adaptor.h"
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <kdirnotify.h>
|
#include <kdirnotify.h>
|
||||||
|
@ -33,8 +32,6 @@
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
#include <kjobtrackerinterface.h>
|
#include <kjobtrackerinterface.h>
|
||||||
|
|
||||||
#include <QtDBus/QtDBus>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
using namespace KIO;
|
using namespace KIO;
|
||||||
|
@ -220,17 +217,6 @@ FileUndoManagerPrivate::FileUndoManagerPrivate(FileUndoManager* qq)
|
||||||
: m_uiInterface(new FileUndoManager::UiInterface()),
|
: m_uiInterface(new FileUndoManager::UiInterface()),
|
||||||
m_undoJob(0), m_nextCommandIndex(1000), q(qq)
|
m_undoJob(0), m_nextCommandIndex(1000), q(qq)
|
||||||
{
|
{
|
||||||
m_syncronized = initializeFromKDesky();
|
|
||||||
(void) new KIOFileUndoManagerAdaptor(this);
|
|
||||||
const QString dbusPath = "/FileUndoManager";
|
|
||||||
const QString dbusInterface = "org.kde.kio.FileUndoManager";
|
|
||||||
|
|
||||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
|
||||||
dbus.registerObject(dbusPath, this);
|
|
||||||
dbus.connect(QString(), dbusPath, dbusInterface, "lock", this, SLOT(slotLock()));
|
|
||||||
dbus.connect(QString(), dbusPath, dbusInterface, "pop", this, SLOT(slotPop()));
|
|
||||||
dbus.connect(QString(), dbusPath, dbusInterface, "push", this, SLOT(slotPush(QByteArray)));
|
|
||||||
dbus.connect(QString(), dbusPath, dbusInterface, "unlock", this, SLOT(slotUnlock()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUndoManager::FileUndoManager()
|
FileUndoManager::FileUndoManager()
|
||||||
|
@ -272,7 +258,7 @@ void FileUndoManager::recordCopyJob(KIO::CopyJob* copyJob)
|
||||||
|
|
||||||
void FileUndoManagerPrivate::addCommand(const UndoCommand &cmd)
|
void FileUndoManagerPrivate::addCommand(const UndoCommand &cmd)
|
||||||
{
|
{
|
||||||
broadcastPush(cmd);
|
push(cmd);
|
||||||
emit q->jobRecordingFinished(cmd.m_type);
|
emit q->jobRecordingFinished(cmd.m_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +315,7 @@ void FileUndoManager::undo()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a copy of the command to undo before broadcastPop() pops it.
|
// Make a copy of the command to undo before slotPop() pops it.
|
||||||
UndoCommand cmd = d->m_commands.last();
|
UndoCommand cmd = d->m_commands.last();
|
||||||
assert(cmd.m_valid);
|
assert(cmd.m_valid);
|
||||||
d->m_current = cmd;
|
d->m_current = cmd;
|
||||||
|
@ -355,8 +341,8 @@ void FileUndoManager::undo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->broadcastPop();
|
d->pop();
|
||||||
d->broadcastLock();
|
d->lock();
|
||||||
|
|
||||||
d->m_dirCleanupStack.clear();
|
d->m_dirCleanupStack.clear();
|
||||||
d->m_dirStack.clear();
|
d->m_dirStack.clear();
|
||||||
|
@ -594,9 +580,7 @@ void FileUndoManagerPrivate::stepRemovingDirectories()
|
||||||
m_currentJob = KIO::rmdir(dir);
|
m_currentJob = KIO::rmdir(dir);
|
||||||
m_undoJob->emitDeleting(dir);
|
m_undoJob->emitDeleting(dir);
|
||||||
addDirToUpdate(dir);
|
addDirToUpdate(dir);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_current.m_valid = false;
|
m_current.m_valid = false;
|
||||||
m_currentJob = 0;
|
m_currentJob = 0;
|
||||||
if (m_undoJob)
|
if (m_undoJob)
|
||||||
|
@ -610,125 +594,38 @@ void FileUndoManagerPrivate::stepRemovingDirectories()
|
||||||
org::kde::KDirNotify::emitFilesAdded(it.url());
|
org::kde::KDirNotify::emitFilesAdded(it.url());
|
||||||
}
|
}
|
||||||
emit q->undoJobFinished();
|
emit q->undoJobFinished();
|
||||||
broadcastUnlock();
|
unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const ref doesn't work due to QDataStream
|
void FileUndoManagerPrivate::push(const UndoCommand &cmd)
|
||||||
void FileUndoManagerPrivate::slotPush(QByteArray data)
|
|
||||||
{
|
|
||||||
QDataStream strm(&data, QIODevice::ReadOnly);
|
|
||||||
UndoCommand cmd;
|
|
||||||
strm >> cmd;
|
|
||||||
pushCommand(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileUndoManagerPrivate::pushCommand(const UndoCommand& cmd)
|
|
||||||
{
|
{
|
||||||
m_commands.append(cmd);
|
m_commands.append(cmd);
|
||||||
emit q->undoAvailable(true);
|
emit q->undoAvailable(true);
|
||||||
emit q->undoTextChanged(q->undoText());
|
emit q->undoTextChanged(q->undoText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileUndoManagerPrivate::slotPop()
|
void FileUndoManagerPrivate::pop()
|
||||||
{
|
{
|
||||||
m_commands.removeLast();
|
m_commands.removeLast();
|
||||||
emit q->undoAvailable(q->undoAvailable());
|
emit q->undoAvailable(q->undoAvailable());
|
||||||
emit q->undoTextChanged(q->undoText());
|
emit q->undoTextChanged(q->undoText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileUndoManagerPrivate::slotLock()
|
void FileUndoManagerPrivate::lock()
|
||||||
{
|
{
|
||||||
// assert(!m_lock);
|
// assert(!m_lock);
|
||||||
m_lock = true;
|
m_lock = true;
|
||||||
emit q->undoAvailable(q->undoAvailable());
|
emit q->undoAvailable(q->undoAvailable());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileUndoManagerPrivate::slotUnlock()
|
void FileUndoManagerPrivate::unlock()
|
||||||
{
|
{
|
||||||
// assert(m_lock);
|
// assert(m_lock);
|
||||||
m_lock = false;
|
m_lock = false;
|
||||||
emit q->undoAvailable(q->undoAvailable());
|
emit q->undoAvailable(q->undoAvailable());
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray FileUndoManagerPrivate::get() const
|
|
||||||
{
|
|
||||||
QByteArray data;
|
|
||||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
|
||||||
stream << m_commands;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileUndoManagerPrivate::broadcastPush(const UndoCommand &cmd)
|
|
||||||
{
|
|
||||||
if (!m_syncronized) {
|
|
||||||
pushCommand(cmd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray data;
|
|
||||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
|
||||||
stream << cmd;
|
|
||||||
emit push(data); // DBUS signal
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileUndoManagerPrivate::broadcastPop()
|
|
||||||
{
|
|
||||||
if (!m_syncronized) {
|
|
||||||
slotPop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit pop(); // DBUS signal
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileUndoManagerPrivate::broadcastLock()
|
|
||||||
{
|
|
||||||
// assert(!m_lock);
|
|
||||||
|
|
||||||
if (!m_syncronized) {
|
|
||||||
slotLock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit lock(); // DBUS signal
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileUndoManagerPrivate::broadcastUnlock()
|
|
||||||
{
|
|
||||||
// assert(m_lock);
|
|
||||||
|
|
||||||
if (!m_syncronized) {
|
|
||||||
slotUnlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit unlock(); // DBUS signal
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FileUndoManagerPrivate::initializeFromKDesky()
|
|
||||||
{
|
|
||||||
// ### workaround for dcop problem and upcoming 2.1 release:
|
|
||||||
// in case of huge io operations the amount of data sent over
|
|
||||||
// dcop (containing undo information broadcasted for global undo
|
|
||||||
// to all konqueror instances) can easily exceed the 64kb limit
|
|
||||||
// of dcop. In order not to run into trouble we disable global
|
|
||||||
// undo for now! (Simon)
|
|
||||||
// ### FIXME: post 2.1
|
|
||||||
// TODO KDE4: port to DBUS and test
|
|
||||||
return false;
|
|
||||||
#if 0
|
|
||||||
DCOPClient *client = kapp->dcopClient();
|
|
||||||
|
|
||||||
if (client->appId() == "kdesktop") // we are master :)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!client->isApplicationRegistered("kdesktop"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
d->m_commands = DCOPRef("kdesktop", "FileUndoManager").call("get");
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileUndoManager::setUiInterface(UiInterface* ui)
|
void FileUndoManager::setUiInterface(UiInterface* ui)
|
||||||
{
|
{
|
||||||
delete d->m_uiInterface;
|
delete d->m_uiInterface;
|
||||||
|
|
|
@ -31,8 +31,6 @@ class KJob;
|
||||||
|
|
||||||
namespace KIO {
|
namespace KIO {
|
||||||
|
|
||||||
class FileUndoManagerAdaptor;
|
|
||||||
|
|
||||||
struct BasicOperation
|
struct BasicOperation
|
||||||
{
|
{
|
||||||
typedef QList<BasicOperation> Stack;
|
typedef QList<BasicOperation> Stack;
|
||||||
|
@ -44,7 +42,7 @@ struct BasicOperation
|
||||||
bool m_renamed;
|
bool m_renamed;
|
||||||
|
|
||||||
enum Type { File, Link, Directory };
|
enum Type { File, Link, Directory };
|
||||||
Type m_type:2;
|
Type m_type;
|
||||||
|
|
||||||
KUrl m_src;
|
KUrl m_src;
|
||||||
KUrl m_dst;
|
KUrl m_dst;
|
||||||
|
@ -96,8 +94,6 @@ private:
|
||||||
|
|
||||||
enum UndoState { MAKINGDIRS = 0, MOVINGFILES, STATINGFILE, REMOVINGDIRS, REMOVINGLINKS };
|
enum UndoState { MAKINGDIRS = 0, MOVINGFILES, STATINGFILE, REMOVINGDIRS, REMOVINGLINKS };
|
||||||
|
|
||||||
// The private class is, exceptionally, a real QObject
|
|
||||||
// so that it can be the class with the DBUS adaptor forwarding its signals.
|
|
||||||
class FileUndoManagerPrivate : public QObject
|
class FileUndoManagerPrivate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -109,15 +105,7 @@ public:
|
||||||
delete m_uiInterface;
|
delete m_uiInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushCommand( const UndoCommand& cmd );
|
|
||||||
|
|
||||||
void broadcastPush( const UndoCommand &cmd );
|
|
||||||
void broadcastPop();
|
|
||||||
void broadcastLock();
|
|
||||||
void broadcastUnlock();
|
|
||||||
|
|
||||||
void addDirToUpdate( const KUrl& url );
|
void addDirToUpdate( const KUrl& url );
|
||||||
bool initializeFromKDesky();
|
|
||||||
|
|
||||||
void undoStep();
|
void undoStep();
|
||||||
|
|
||||||
|
@ -126,9 +114,6 @@ public:
|
||||||
void stepRemovingLinks();
|
void stepRemovingLinks();
|
||||||
void stepRemovingDirectories();
|
void stepRemovingDirectories();
|
||||||
|
|
||||||
/// called by FileUndoManagerAdaptor
|
|
||||||
QByteArray get() const;
|
|
||||||
|
|
||||||
friend class UndoJob;
|
friend class UndoJob;
|
||||||
/// called by UndoJob
|
/// called by UndoJob
|
||||||
void stopUndo( bool step );
|
void stopUndo( bool step );
|
||||||
|
@ -137,7 +122,6 @@ public:
|
||||||
/// called by UndoCommandRecorder
|
/// called by UndoCommandRecorder
|
||||||
void addCommand( const UndoCommand &cmd );
|
void addCommand( const UndoCommand &cmd );
|
||||||
|
|
||||||
bool m_syncronized;
|
|
||||||
bool m_lock;
|
bool m_lock;
|
||||||
|
|
||||||
UndoCommand::Stack m_commands;
|
UndoCommand::Stack m_commands;
|
||||||
|
@ -156,24 +140,12 @@ public:
|
||||||
|
|
||||||
FileUndoManager* q;
|
FileUndoManager* q;
|
||||||
|
|
||||||
// DBUS interface
|
void push(const UndoCommand &cmd);
|
||||||
Q_SIGNALS:
|
|
||||||
/// DBUS signal
|
|
||||||
void push(const QByteArray &command);
|
|
||||||
/// DBUS signal
|
|
||||||
void pop();
|
void pop();
|
||||||
/// DBUS signal
|
|
||||||
void lock();
|
void lock();
|
||||||
/// DBUS signal
|
|
||||||
void unlock();
|
void unlock();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
// Those four slots are connected to DBUS signals
|
|
||||||
void slotPush(QByteArray);
|
|
||||||
void slotPop();
|
|
||||||
void slotLock();
|
|
||||||
void slotUnlock();
|
|
||||||
|
|
||||||
void slotResult(KJob*);
|
void slotResult(KJob*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
|
||||||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
|
||||||
<node>
|
|
||||||
<interface name="org.kde.libkonq.FileUndoManager">
|
|
||||||
<method name="get">
|
|
||||||
<arg name="commands" type="ay" direction="out"/>
|
|
||||||
</method>
|
|
||||||
<signal name="lock"/>
|
|
||||||
<signal name="pop"/>
|
|
||||||
<signal name="push">
|
|
||||||
<arg name="command" type="ay" direction="out"/>
|
|
||||||
</signal>
|
|
||||||
<signal name="unlock"/>
|
|
||||||
</interface>
|
|
||||||
</node>
|
|
|
@ -218,8 +218,6 @@ void FileUndoManagerTest::testCopyFiles()
|
||||||
// Don't use QFile::exists, it's a broken symlink...
|
// Don't use QFile::exists, it's a broken symlink...
|
||||||
QVERIFY( QFileInfo( destLink() ).isSymLink() );
|
QVERIFY( QFileInfo( destLink() ).isSymLink() );
|
||||||
|
|
||||||
// might have to wait for dbus signal here... but this is currently disabled.
|
|
||||||
//QTest::qWait( 20 );
|
|
||||||
QVERIFY( FileUndoManager::self()->undoAvailable() );
|
QVERIFY( FileUndoManager::self()->undoAvailable() );
|
||||||
QCOMPARE( spyUndoAvailable.count(), 1 );
|
QCOMPARE( spyUndoAvailable.count(), 1 );
|
||||||
QCOMPARE( spyTextChanged.count(), 1 );
|
QCOMPARE( spyTextChanged.count(), 1 );
|
||||||
|
|
Loading…
Add table
Reference in a new issue