4141 wl_threading
4242)
4343from wordless .wl_widgets import (
44+ wl_boxes ,
4445 wl_labels ,
4546 wl_layouts ,
4647 wl_tables ,
@@ -121,11 +122,20 @@ def __init__(self, main):
121122 ) = wl_widgets .wl_widgets_search_settings_tokens (self , tab = self .tab )
122123 self .checkbox_match_dependency_relations = QtWidgets .QCheckBox (self .tr ('Match dependency relations' ), self )
123124
125+ self .label_search_term_position = QtWidgets .QLabel (self .tr ('Search term position:' ), self )
126+ self .combo_box_search_term_position = wl_boxes .Wl_Combo_Box (self )
127+
124128 (
125129 self .label_context_settings ,
126130 self .button_context_settings
127131 ) = wl_widgets .wl_widgets_context_settings (self , tab = self .tab )
128132
133+ self .combo_box_search_term_position .addItems ([
134+ self .tr ('Head/dependent' ),
135+ self .tr ('Head' ),
136+ self .tr ('Dependent' )
137+ ])
138+
129139 self .checkbox_multi_search_mode .stateChanged .connect (self .search_settings_changed )
130140 self .line_edit_search_term .textChanged .connect (self .search_settings_changed )
131141 self .line_edit_search_term .returnPressed .connect (self .table_dependency_parser .button_generate_table .click )
@@ -140,6 +150,13 @@ def __init__(self, main):
140150 self .checkbox_match_without_tags .stateChanged .connect (self .search_settings_changed )
141151 self .checkbox_match_tags .stateChanged .connect (self .search_settings_changed )
142152 self .checkbox_match_dependency_relations .stateChanged .connect (self .search_settings_changed )
153+ self .combo_box_search_term_position .currentTextChanged .connect (self .search_settings_changed )
154+
155+ layout_search_term_position = wl_layouts .Wl_Layout ()
156+ layout_search_term_position .addWidget (self .label_search_term_position , 0 , 0 )
157+ layout_search_term_position .addWidget (self .combo_box_search_term_position , 0 , 1 )
158+
159+ layout_search_term_position .setColumnStretch (1 , 1 )
143160
144161 layout_context_settings = wl_layouts .Wl_Layout ()
145162 layout_context_settings .addWidget (self .label_context_settings , 0 , 0 )
@@ -163,7 +180,11 @@ def __init__(self, main):
163180
164181 self .group_box_search_settings .layout ().addWidget (wl_layouts .Wl_Separator (self ), 10 , 0 , 1 , 2 )
165182
166- self .group_box_search_settings .layout ().addLayout (layout_context_settings , 11 , 0 , 1 , 2 )
183+ self .group_box_search_settings .layout ().addLayout (layout_search_term_position , 11 , 0 , 1 , 2 )
184+
185+ self .group_box_search_settings .layout ().addWidget (wl_layouts .Wl_Separator (self ), 12 , 0 , 1 , 2 )
186+
187+ self .group_box_search_settings .layout ().addLayout (layout_context_settings , 13 , 0 , 1 , 2 )
167188
168189 # Table Settings
169190 self .group_box_table_settings = QtWidgets .QGroupBox (self .tr ('Table Settings' ), self )
@@ -243,6 +264,7 @@ def load_settings(self, defaults = False):
243264 self .checkbox_match_without_tags .setChecked (settings ['search_settings' ]['match_without_tags' ])
244265 self .checkbox_match_tags .setChecked (settings ['search_settings' ]['match_tags' ])
245266 self .checkbox_match_dependency_relations .setChecked (settings ['search_settings' ]['match_dependency_relations' ])
267+ self .combo_box_search_term_position .setCurrentText (settings ['search_settings' ]['search_term_position' ])
246268
247269 # Context Settings
248270 if defaults :
@@ -295,6 +317,7 @@ def search_settings_changed(self):
295317 settings ['match_without_tags' ] = self .checkbox_match_without_tags .isChecked ()
296318 settings ['match_tags' ] = self .checkbox_match_tags .isChecked ()
297319 settings ['match_dependency_relations' ] = self .checkbox_match_dependency_relations .isChecked ()
320+ settings ['search_term_position' ] = self .combo_box_search_term_position .currentText ()
298321
299322 # Match dependency relations
300323 if settings ['match_dependency_relations' ]:
@@ -551,7 +574,19 @@ def run(self):
551574 (
552575 (
553576 not settings ['search_settings' ]['match_dependency_relations' ]
554- and (token in search_terms or token .head in search_terms )
577+ and settings ['search_settings' ]['search_term_position' ] == self .tr ('Head/dependent' )
578+ and (
579+ token in search_terms
580+ or token .head in search_terms
581+ )
582+ ) or (
583+ not settings ['search_settings' ]['match_dependency_relations' ]
584+ and settings ['search_settings' ]['search_term_position' ] == self .tr ('Head' )
585+ and token .head in search_terms
586+ ) or (
587+ not settings ['search_settings' ]['match_dependency_relations' ]
588+ and settings ['search_settings' ]['search_term_position' ] == self .tr ('Dependent' )
589+ and token in search_terms
555590 ) or (
556591 settings ['search_settings' ]['match_dependency_relations' ]
557592 and token .dependency_relation in wl_texts .to_display_texts (search_terms )
0 commit comments