def itemClicked self item column if item result prot in self clickActi

 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
def itemClicked(self, item, column):
if item.result.prot in self.clickAction:
action = self.clickAction[item.result.prot]
replacedAction = ""
started = False
word = ""
subs = {
"{host}" : item.result.host,
"{name}" : item.result.name + item.result.extension,
"{path}" : item.result.path,
"{prot}" : item.result.prot,
"{uname}" : QUrl(item.result.name + item.result.extension).toEncoded(),
"{upath}" : QUrl(item.result.path).toEncoded(),
"{copy}" : "",
"{screen!}" : "",
"{{}" : "{",
"{split}" : "\0",
}
copy = False
screen = False
for c in action:
if c == "{":
started = True
if started:
word = word + c
else:
replacedAction = replacedAction + c
if started and c == "}":
started = False
if word == "{copy}":
copy = True
if word == "{screen!}":
screen = True
if word in subs:
word = subs[word]
replacedAction = replacedAction + word
word = ""
replacedAction = replacedAction + word
if screen:
replacedAction = replacedAction.replace("!", "\\!")
if copy:
QtGui.QApplication.clipboard().setText(replacedAction)
self.emit(SIGNAL("statusChanged"), "Copyied: \"%s\"" % replacedAction, 3000)
else:
t = replacedAction.split("\0")
os.spawnvp(os.P_NOWAIT, t[0], t)
self.emit(SIGNAL("statusChanged"), "Executed: %s" % " ".join(t), 3000)
else:
text = item.result.prot+"://"+item.result.host+item.result.path+item.result.name
QtGui.QApplication.clipboard().setText(text)
self.emit(SIGNAL("statusChanged"), "Copyied: \"%s\"" % text, 3000)