File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,18 @@ class ObjRepoModel(TableModel):
1010 XPATH_COL = 2
1111 LOCATOR_COL = 3
1212
13+ ABBRIVATION_MAP = {
14+ "cel" : "Cell" ,
15+ "lnk" : "Link" ,
16+ "lbl" : "Label" ,
17+ "tgl" : "Toggle" ,
18+ "cir" : "Circle" ,
19+ "btn" : "Button" ,
20+ "txt" : "TextBox" ,
21+ "ddl" : "DropDown" ,
22+ "chk" : "Checkbox"
23+ }
24+
1325 def __init__ (self , df : pd .DataFrame = None ):
1426 super ().__init__ (df = df )
1527
@@ -23,6 +35,21 @@ def create_preset(cls):
2335 ]
2436 return pd .DataFrame (data , columns = columns )
2537
38+ def setData (self , index , value , role = Qt .ItemDataRole .EditRole ):
39+ if not index .isValid ():
40+ return False
41+
42+ result = super ().setData (index , value , role )
43+
44+ if result and role == Qt .ItemDataRole .EditRole and index .column () == self .NAME_COL :
45+ for abbr , full_type in self .ABBRIVATION_MAP .items ():
46+ if value .startswith (abbr ):
47+ type_index = self .index (index .row (), self .TYPE_COL )
48+ super ().setData (type_index , full_type , role )
49+ break
50+ return result
51+
52+
2653 def insertRows (self , position , rows , parent = QModelIndex ()):
2754 success = super ().insertRows (position , rows , parent )
2855 if success :
You can’t perform that action at this time.
0 commit comments