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

Use KonqMimeData for the cut- and copy-operation instead of using bool property inside DolphinMainWindow. This assures that cut- and copy-operations also work within multiple Dolphin main windows.

svn path=/trunk/playground/utils/dolphin/; revision=614351
This commit is contained in:
Peter Penz 2006-12-17 13:47:45 +00:00
parent c28c72619c
commit 8b240249db
3 changed files with 11 additions and 51 deletions

View File

@ -57,7 +57,7 @@ kde4_add_kcfg_files(dolphin_SRCS
kde4_add_executable(dolphin ${dolphin_SRCS})
target_link_libraries(dolphin ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} )
target_link_libraries(dolphin ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} konq )
install(TARGETS dolphin DESTINATION ${BIN_INSTALL_DIR})

View File

@ -51,6 +51,7 @@
#include <kstandarddirs.h>
#include <krun.h>
#include <klocale.h>
#include <konqmimedata.h>
#include <qclipboard.h>
#include <q3dragobject.h>
@ -79,31 +80,19 @@
DolphinMainWindow::DolphinMainWindow() :
KMainWindow(0),
m_splitter(0),
m_activeView(0),
m_clipboardContainsCutData(false)
m_activeView(0)
{
setObjectName("Dolphin");
m_view[PrimaryIdx] = 0;
m_view[SecondaryIdx] = 0;
// TODO: the following members are not used yet. See documentation
// of DolphinMainWindow::linkGroupActions() and DolphinMainWindow::linkToDeviceActions()
// in the header file for details.
}
DolphinMainWindow::~DolphinMainWindow()
{
qDeleteAll(m_fileGroupActions);
//qDeleteAll(m_linkToDeviceActions);
//qDeleteAll(m_linkGroupActions);
m_fileGroupActions.clear();
//m_linkGroupActions.clear();
//m_linkToDeviceActions.clear();
/*
* bye, bye managed window
*/
DolphinApplication::app()->removeMainWindow( this );
DolphinApplication::app()->removeMainWindow(this);
}
void DolphinMainWindow::setActiveView(DolphinView* view)
@ -653,25 +642,19 @@ void DolphinMainWindow::slotRedoTextChanged(const QString& text)
void DolphinMainWindow::cut()
{
// TODO: 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
m_clipboardContainsCutData = true;
QMimeData* mimeData = new QMimeData();
const KUrl::List selectedUrls = m_activeView->selectedUrls();
selectedUrls.populateMimeData(mimeData);
const KUrl::List kdeUrls = m_activeView->selectedUrls();
const KUrl::List mostLocalUrls;
KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true);
QApplication::clipboard()->setMimeData(mimeData);
}
void DolphinMainWindow::copy()
{
m_clipboardContainsCutData = false;
QMimeData* mimeData = new QMimeData();
const KUrl::List selectedUrls = m_activeView->selectedUrls();
selectedUrls.populateMimeData(mimeData);
const KUrl::List kdeUrls = m_activeView->selectedUrls();
const KUrl::List mostLocalUrls;
KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false);
QApplication::clipboard()->setMimeData(mimeData);
}
@ -702,15 +685,8 @@ void DolphinMainWindow::paste()
}
}
// 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) {
if (KonqMimeData::decodeIsCutSelection(mimeData)) {
moveUrls(sourceUrls, destUrl);
m_clipboardContainsCutData = false;
clipboard->clear();
}
else {

View File

@ -93,20 +93,12 @@ public:
void dropUrls(const KUrl::List& urls,
const KUrl& destination);
/**
* Returns 'true', if the clipboard contains data
* which has been cutted by the Cut action (Ctrl + X).
*/
bool clipboardContainsCutData() const { return m_clipboardContainsCutData; }
/**
* Returns the list of actions which are part of the file group
* of the 'Create New...' sub menu. Usually the list contains actions
* for creating folders, text files, HTML files etc.
*/
QLinkedList<QAction*> fileGroupActions() const { return m_fileGroupActions; }
//QLinkedList<QAction*>& linkGroupActions() const { return m_linkGroupActions; }
//QLinkedList<QAction*>& linkToDeviceActions() const { return m_linkToDeviceActions; }
/**
* Refreshs the views of the main window by recreating them dependent from
@ -411,9 +403,6 @@ private:
};
DolphinView* m_view[SecondaryIdx + 1];
/// If set to true, the clipboard contains data which should be cutted after pasting.
bool m_clipboardContainsCutData;
/**
* Asynchronous operations like 'Move' and 'Copy' may only be added as undo
* operation after they have been finished successfully. When an asynchronous
@ -442,11 +431,6 @@ private:
QLinkedList<QAction*> m_fileGroupActions;
KSortableList<CreateFileEntry,QString> m_createFileTemplates;
// TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
// and DolphinMainWindow::linkToDeviceActions() in for details.
//QLinkedList<QAction*> m_linkGroupActions;
//QLinkedList<QAction*> m_linkToDeviceActions;
};
#endif // _DOLPHIN_H_