forked from CEFgoose/GEM5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_functions.py
71 lines (62 loc) · 2.96 KB
/
list_functions.py
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
from PyQt5.QtCore import *
#from PyQt5.QtGui import QColor, QIcon
from PyQt5.QtWidgets import *
from confirm_widget import *
#---grab currently selected editor info from table selections
def editor_list_clicked(main):
main.selectedEditors=[]
selectedEditorIndexes=main.editorTable.selectedItems()
for index in selectedEditorIndexes:
index=main.editorTable.indexOfTopLevelItem(index)
main.selectedEditors.append(main.currentEditorsOrdered[index])
for editor in main.selectedEditors:
print(editor.username)
#---remove editor/s from table & editor list
def remove_editors(main):
proceed=confirmationWidget(main,"Remove selectededitors","Are you sure you want to remove selected editors?")
if proceed:
for editor in main.selectedEditors:
main.currentEditorsOrdered.remove(editor)
selectedEditorIndexes=main.editorTable.selectedItems()
for index in selectedEditorIndexes:
index=main.editorTable.indexOfTopLevelItem(index)
main.editorTable.takeTopLevelItem(index)
#--remove ALL editors from table & editor list
def remove_all_editors(main):
proceed=confirmationWidget(main,"Remove all editors","Are you sure you want to remove all editors?")
if proceed:
main.selectedEditors=[]
main.currentEditorsOrdered=[]
main.editorTable.clear()
#---move editor/s up in the editor table
def move_up(main):
for editor in main.selectedEditors:
moving_up_index=main.currentEditorsOrdered.index(editor)
moving_down_index=main.currentEditorsOrdered.index(editor)-1
moving_up_editor=main.currentEditorsOrdered[moving_up_index]
moving_down_editor=main.currentEditorsOrdered[moving_down_index]
main.currentEditorsOrdered[moving_up_index]=moving_down_editor
main.currentEditorsOrdered[moving_down_index]=moving_up_editor
main.editorTable.clear()
for editor in main.currentEditorsOrdered:
editor.construct_list_item(main)
#---move editor/s down in the editor table (move down requires extra index handling)
def move_down(main):
counter=1
for editor in main.selectedEditors:
if len(main.selectedEditors)>1:
moving_up_index=main.currentEditorsOrdered.index(editor)
moving_down_index=main.currentEditorsOrdered.index(editor)+counter
else:
moving_down_index=main.currentEditorsOrdered.index(editor)+1
if moving_down_index>len(main.currentEditorsOrdered)-1:
moving_down_index=0
moving_down_editor=main.currentEditorsOrdered[moving_down_index]
moving_up_index=main.currentEditorsOrdered.index(editor)
moving_up_editor=main.currentEditorsOrdered[moving_up_index]
main.currentEditorsOrdered[moving_down_index]=moving_up_editor
main.currentEditorsOrdered[moving_up_index]=moving_down_editor
counter+=1
main.editorTable.clear()
for editor in main.currentEditorsOrdered:
editor.construct_list_item(main)