summaryrefslogtreecommitdiffstats
path: root/src/gvcore/fileoperation.cpp
blob: cd26ade078e06870fb6103e82a25c99010b5a3c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
Gwenview - A simple image viewer for TDE
Copyright 2000-2004 Aur�lien G�teau

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.

*/
// Self
#include "fileoperation.moc"

// TQt
#include <tqcursor.h>
#include <tqpopupmenu.h>
#include <tqobject.h>

// KDE
#include <tdeconfig.h>
#include <kiconloader.h>
#include <tdelocale.h>

// Local
#include "fileopobject.h"
#include "fileoperationconfig.h"

namespace Gwenview {


namespace FileOperation {

void copyTo(const KURL::List& srcURL,TQWidget* parent) {
	FileOpObject* op=new FileOpCopyToObject(srcURL,parent);
	(*op)();
}

void linkTo(const KURL::List& srcURL,TQWidget* parent) {
	FileOpObject* op=new FileOpLinkToObject(srcURL,parent);
	(*op)();
}

void moveTo(const KURL::List& srcURL,TQWidget* parent,TQObject* receiver,const char* slot) {
	FileOpObject* op=new FileOpMoveToObject(srcURL,parent);
	if (receiver && slot) TQObject::connect(op,TQ_SIGNAL(success()),receiver,slot);
	(*op)();
}

void makeDir(const KURL& parentURL, TQWidget* parent, TQObject* receiver, const char* slot) {
    FileOpObject* op=new FileOpMakeDirObject(parentURL, parent);
	if (receiver && slot) TQObject::connect(op,TQ_SIGNAL(success()),receiver,slot);
	(*op)();
}

void del(const KURL::List& url,TQWidget* parent,TQObject* receiver,const char* slot) {
	FileOpObject* op = new FileOpDelObject(url,parent);
	if (receiver && slot) TQObject::connect(op,TQ_SIGNAL(success()),receiver,slot);
	(*op)();
}


void trash(const KURL::List& url, TQWidget* parent, TQObject* receiver, const char* slot) {
	FileOpObject* op = new FileOpTrashObject(url,parent);
	if (receiver && slot) TQObject::connect(op,TQ_SIGNAL(success()),receiver,slot);
	(*op)();
}


void realDelete(const KURL::List& url, TQWidget* parent, TQObject* receiver, const char* slot) {
	FileOpObject* op = new FileOpRealDeleteObject(url,parent);
	if (receiver && slot) TQObject::connect(op,TQ_SIGNAL(success()),receiver,slot);
	(*op)();
}


void rename(const KURL& url,TQWidget* parent,TQObject* receiver,const char* slot) {
	FileOpObject* op=new FileOpRenameObject(url,parent);
	if (receiver && slot) TQObject::connect(op,TQ_SIGNAL(renamed(const TQString&)),receiver,slot);
	(*op)();
}


void fillDropURLMenu(TQPopupMenu* menu, const KURL::List& urls, const KURL& target, bool* wasMoved) {
	DropMenuContext* context=new DropMenuContext(menu, urls, target, wasMoved);
	menu->insertItem( SmallIcon("goto"), i18n("&Move Here"),
		context, TQ_SLOT(move()) );
	menu->insertItem( SmallIcon("edit-copy"), i18n("&Copy Here"),
		context, TQ_SLOT(copy()) );
	menu->insertItem( SmallIcon("www"), i18n("&Link Here"),
		context, TQ_SLOT(link()) );
}


void openDropURLMenu(TQWidget* parent, const KURL::List& urls, const KURL& target, bool* wasMoved) {
	TQPopupMenu menu(parent);
	if (wasMoved) *wasMoved=false;

	fillDropURLMenu(&menu, urls, target, wasMoved);
	menu.insertSeparator();
	menu.insertItem( SmallIcon("cancel"), i18n("Cancel") );

	menu.setMouseTracking(true);
	menu.exec(TQCursor::pos());
}


} // namespace FileOperation

} // namespace