2
2
from PyQt5 .QtCore import Qt , QCoreApplication , pyqtSignal , QVariant
3
3
from PyQt5 .QtGui import QPixmap , QPainter , QColor
4
4
from PyQt5 .QtWidgets import (QVBoxLayout , QHBoxLayout , QLabel , QTextEdit , QWidget , QComboBox , QCheckBox ,
5
- QPushButton )
5
+ QPushButton , QStackedWidget )
6
6
from PyQt5 .QtCore import QCoreApplication as QC
7
7
import logging
8
8
import os .path
@@ -17,12 +17,14 @@ class ExecReturn(ElementMaster):
17
17
pixmap_path = 'images/ExecReturn.png'
18
18
child_pos = (False , False )
19
19
20
+ query_grid_config = pyqtSignal (name = 'query_grid_config' )
21
+
20
22
def __init__ (self , row , column ):
21
23
self .row = row
22
24
self .column = column
23
25
24
- # currentdata, currentindex , ischecked
25
- self .config = (None , None , False )
26
+ # grid, wrk_selecctor_index, wrk_pos , ischecked
27
+ self .config = (0 , 0 , ( 0 , 0 ) , False )
26
28
super ().__init__ (self .row , self .column , QPixmap (self .pixmap_path ), True , self .config )
27
29
super ().edit_sig .connect (self .edit )
28
30
logging .debug ('ExecReturn called at row {}, column {}' .format (row , column ))
@@ -43,15 +45,19 @@ def __getstate__(self):
43
45
def openEditor (self ):
44
46
logging .debug ('openEditor() called ExecReturn' )
45
47
48
+
46
49
def edit (self ):
47
50
logging .debug ('edit() called ExecReturn' )
48
51
self .returnEditLayout = QVBoxLayout ()
49
52
50
53
self .returnEdit = ElementEditor (self )
51
54
self .returnEdit .setWindowTitle (QC .translate ('' , 'Edit Return' ))
52
55
53
- self .top_text = QLabel ()
54
- self .top_text .setText (QC .translate ('' , 'Go to element:' ))
56
+ self .grid_text = QLabel ()
57
+ self .grid_text .setText (QC .translate ('' , 'Go to grid:' ))
58
+
59
+ self .element_text = QLabel ()
60
+ self .element_text .setText (QC .translate ('' , 'Go to element:' ))
55
61
56
62
self .help_text = QWidget ()
57
63
self .help_text_layout = QVBoxLayout (self .help_text )
@@ -83,17 +89,21 @@ def edit(self):
83
89
self .log_line_layout .addStretch (1 )
84
90
85
91
86
- self .element_selector = QComboBox ()
87
- self .populateSelector ()
92
+ self .element_selector = QStackedWidget ()
93
+
94
+ self .grid_selector = QComboBox ()
88
95
89
- if self .config [1 ]:
90
- self .element_selector .setCurrentIndex (self .config [1 ])
91
- if self .config [2 ]:
92
- self .log_checkbox .setChecked (True )
96
+ # emmiting signal
97
+ self .query_grid_config .emit ()
98
+ self .grid_selector .currentIndexChanged .connect (self .gridIndexChanged )
99
+
100
+ self .loadLastConfig ()
93
101
94
102
self .confirm_button .clicked .connect (self .returnEdit .closeEvent )
95
103
self .returnEdit .window_closed .connect (self .edit_done )
96
- self .returnEditLayout .addWidget (self .top_text )
104
+ self .returnEditLayout .addWidget (self .grid_text )
105
+ self .returnEditLayout .addWidget (self .grid_selector )
106
+ self .returnEditLayout .addWidget (self .element_text )
97
107
self .returnEditLayout .addWidget (self .element_selector )
98
108
self .returnEditLayout .addWidget (self .log_line )
99
109
self .returnEditLayout .addWidget (self .help_text )
@@ -102,17 +112,41 @@ def edit(self):
102
112
self .returnEdit .setLayout (self .returnEditLayout )
103
113
self .returnEdit .show ()
104
114
105
- def populateSelector (self ):
115
+ def baustelle (self , config ):
116
+
117
+ self .wrk_selectors_arr = []
118
+
119
+ logging .debug ('ExecReturn::baustelle config: {}' .format (config ))
120
+ for index , wrk_area in enumerate (config ):
121
+ self .grid_selector .addItem ('Grid {}' .format (index + 1 ))
106
122
107
- index = self .parent ().returnCurrentElements ()
123
+ self .wrk_selectors_arr .append (QComboBox ())
124
+ self .element_selector .addWidget (self .wrk_selectors_arr [index ])
125
+ for pos in wrk_area :
126
+ self .wrk_selectors_arr [index ].addItem ('{} {}' .format (pos [0 ], alphabet [pos [1 ]]), QVariant (pos ))
108
127
109
- for pos in index :
110
- if self .getPos () != pos :
111
- self .element_selector .addItem ('{} {}' .format (pos [0 ], alphabet [pos [1 ]]), QVariant (pos ))
128
+ def gridIndexChanged (self , index ):
129
+
130
+ logging .debug ('ExecReturn::gridIndexChanged() called: {}' .format (index ))
131
+ self .element_selector .setCurrentIndex (index )
132
+
133
+
134
+ def loadLastConfig (self ):
135
+
136
+ grid , wrk_selecctor_index , wrk_pos , log_state = self .config
137
+
138
+ self .grid_selector .setCurrentIndex (grid )
139
+ self .element_selector .setCurrentIndex (grid )
140
+ self .wrk_selectors_arr [grid ].setCurrentIndex (wrk_selecctor_index )
141
+ self .log_checkbox .setChecked (log_state )
112
142
113
143
def edit_done (self ):
114
144
logging .debug ('edit_done() called ExecReturn' )
115
- self .config = (self .element_selector .currentData (), self .element_selector .currentIndex (), self .log_checkbox .isChecked ())
145
+ grid = self .grid_selector .currentIndex ()
146
+ wrk_selecctor_index = self .wrk_selectors_arr [grid ].currentIndex ()
147
+ wrk_pos = self .wrk_selectors_arr [grid ].currentData ()
148
+
149
+ self .config = (grid , wrk_selecctor_index , wrk_pos , self .log_checkbox .isChecked ())
116
150
self .addFunction (ReturnFunction )
117
151
118
152
class ReturnFunction (Function ):
@@ -122,7 +156,9 @@ def __init__(self, config, b_debug, row, column):
122
156
123
157
def execute (self , record ):
124
158
125
- log_txt = '{{BASIC RETURN}} Return to {}|{}' .format (self .config [0 ][0 ], alphabet [self .config [0 ][1 ]])
126
- result = Record (self .getPos (), self .config [0 ], record , log = self .config [2 ], log_txt = log_txt )
159
+ grid , wrk_selecctor_index , wrk_pos , log_state = self .config
160
+ target_0 = (grid , wrk_pos [0 ], wrk_pos [1 ])
161
+ log_txt = '{{BASIC RETURN}} Grid {} - Pos {}|{}' .format (grid , wrk_pos [0 ], alphabet [wrk_pos [1 ]])
162
+ result = Record (self .getPos (), target_0 , record , log = log_state , log_txt = log_txt )
127
163
return result
128
164
0 commit comments