10
10
QHBoxLayout ,
11
11
QLabel ,
12
12
QPushButton ,
13
- QComboBox ,
13
+ QListWidget ,
14
14
)
15
15
16
16
from src .core .library import Library
17
17
18
18
19
19
class AddFieldModal (QWidget ):
20
- done = Signal (int )
20
+ done = Signal (list )
21
21
22
22
def __init__ (self , library : "Library" ):
23
23
# [Done]
@@ -37,31 +37,25 @@ def __init__(self, library: "Library"):
37
37
self .title_widget .setStyleSheet (
38
38
# 'background:blue;'
39
39
# 'text-align:center;'
40
- "font-weight:bold;" "font-size:14px;" "padding-top: 6px" ""
40
+ "font-weight:bold;" "font-size:14px;" "padding-top: 6px"
41
41
)
42
42
self .title_widget .setText ("Add Field" )
43
43
self .title_widget .setAlignment (Qt .AlignmentFlag .AlignCenter )
44
44
45
- self .combo_box = QComboBox ()
46
- self .combo_box .setEditable (False )
47
- # self.combo_box.setMaxVisibleItems(5)
48
- self .combo_box .setStyleSheet ("combobox-popup:0;" )
49
- self .combo_box .view ().setVerticalScrollBarPolicy (
50
- Qt .ScrollBarPolicy .ScrollBarAsNeeded
51
- )
45
+ self .list_widget = QListWidget ()
46
+ self .list_widget .setSelectionMode (QListWidget .SelectionMode .ExtendedSelection )
47
+
48
+ items = []
52
49
for df in self .lib .default_fields :
53
- self . combo_box . addItem (
54
- f' { df [ "name" ] } ( { df [ "type" ]. replace ( "_" , " " ). title () } )'
55
- )
50
+ items . append ( f' { df [ "name" ] } ( { df [ "type" ]. replace ( "_" , " " ). title () } )' )
51
+
52
+ self . list_widget . addItems ( items )
56
53
57
54
self .button_container = QWidget ()
58
55
self .button_layout = QHBoxLayout (self .button_container )
59
56
self .button_layout .setContentsMargins (6 , 6 , 6 , 6 )
60
57
self .button_layout .addStretch (1 )
61
58
62
- # self.cancel_button = QPushButton()
63
- # self.cancel_button.setText('Cancel')
64
-
65
59
self .cancel_button = QPushButton ()
66
60
self .cancel_button .setText ("Cancel" )
67
61
self .cancel_button .clicked .connect (self .hide )
@@ -74,17 +68,12 @@ def __init__(self, library: "Library"):
74
68
self .save_button .setDefault (True )
75
69
self .save_button .clicked .connect (self .hide )
76
70
self .save_button .clicked .connect (
77
- lambda : self .done .emit (self .combo_box . currentIndex ())
71
+ lambda : self .done .emit (self .list_widget . selectedIndexes ())
78
72
)
79
- # self.save_button.clicked.connect(lambda: save_callback(widget.get_content()))
80
73
self .button_layout .addWidget (self .save_button )
81
74
82
- # self.returnPressed.connect(lambda: self.done.emit(self.combo_box.currentIndex()))
83
-
84
- # self.done.connect(lambda x: callback(x))
85
-
86
75
self .root_layout .addWidget (self .title_widget )
87
- self .root_layout .addWidget (self .combo_box )
88
- # self.root_layout.setStretch(1,2)
76
+ self .root_layout .addWidget (self .list_widget )
77
+
89
78
self .root_layout .addStretch (1 )
90
79
self .root_layout .addWidget (self .button_container )
0 commit comments