117 @return generated code (string) |
117 @return generated code (string) |
118 """ |
118 """ |
119 # calculate our indentation level and the indentation string |
119 # calculate our indentation level and the indentation string |
120 il = indLevel + 1 |
120 il = indLevel + 1 |
121 istring = il * indString |
121 istring = il * indString |
|
122 estring = os.linesep + indLevel * indString |
122 |
123 |
123 # now generate the code |
124 # now generate the code |
124 code = 'QInputDialog.' |
125 code = 'QInputDialog.' |
125 if self.rText.isChecked(): |
126 if self.rText.isChecked(): |
126 code += 'getText(\\{0}{1}'.format(os.linesep, istring) |
127 code += 'getText({0}{1}'.format(os.linesep, istring) |
127 code += 'None,{0}{1}'.format(os.linesep, istring) |
128 code += 'None,{0}{1}'.format(os.linesep, istring) |
128 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
129 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
129 self.eCaption.text(), os.linesep, istring) |
130 self.eCaption.text(), os.linesep, istring) |
130 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
131 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
131 self.eLabel.text(), os.linesep, istring) |
132 self.eLabel.text(), os.linesep, istring) |
136 else: |
137 else: |
137 code += 'QLineEdit.Password' |
138 code += 'QLineEdit.Password' |
138 if self.eTextDefault.text(): |
139 if self.eTextDefault.text(): |
139 code += ',{0}{1}self.trUtf8("{2}")'.format( |
140 code += ',{0}{1}self.trUtf8("{2}")'.format( |
140 os.linesep, istring, self.eTextDefault.text()) |
141 os.linesep, istring, self.eTextDefault.text()) |
141 code += '){0}'.format(os.linesep) |
142 code += '){0}'.format(estring) |
142 elif self.rInteger.isChecked(): |
143 elif self.rInteger.isChecked(): |
143 code += 'getInteger(\\{0}{1}'.format(os.linesep, istring) |
144 code += 'getInteger({0}{1}'.format(os.linesep, istring) |
144 code += 'None,{0}{1}'.format(os.linesep, istring) |
145 code += 'None,{0}{1}'.format(os.linesep, istring) |
145 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
146 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
146 self.eCaption.text(), os.linesep, istring) |
147 self.eCaption.text(), os.linesep, istring) |
147 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
148 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
148 self.eLabel.text(), os.linesep, istring) |
149 self.eLabel.text(), os.linesep, istring) |
149 code += '{0:d}, {1:d}, {2:d}, {3:d}){4}'.format( |
150 code += '{0:d}, {1:d}, {2:d}, {3:d}){4}'.format( |
150 self.sIntDefault.value(), self.sIntFrom.value(), |
151 self.sIntDefault.value(), self.sIntFrom.value(), |
151 self.sIntTo.value(), self.sIntStep.value(), os.linesep) |
152 self.sIntTo.value(), self.sIntStep.value(), estring) |
152 elif self.rDouble.isChecked(): |
153 elif self.rDouble.isChecked(): |
153 try: |
154 try: |
154 doubleDefault = float(self.eDoubleDefault.text()) |
155 doubleDefault = float(self.eDoubleDefault.text()) |
155 except ValueError: |
156 except ValueError: |
156 doubleDefault = 0 |
157 doubleDefault = 0 |
160 doubleFrom = -2147483647 |
161 doubleFrom = -2147483647 |
161 try: |
162 try: |
162 doubleTo = float(self.eDoubleTo.text()) |
163 doubleTo = float(self.eDoubleTo.text()) |
163 except ValueError: |
164 except ValueError: |
164 doubleTo = 2147483647 |
165 doubleTo = 2147483647 |
165 code += 'getDouble(\\{0}{1}'.format(os.linesep, istring) |
166 code += 'getDouble({0}{1}'.format(os.linesep, istring) |
166 code += 'None,{0}{1}'.format(os.linesep, istring) |
167 code += 'None,{0}{1}'.format(os.linesep, istring) |
167 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
168 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
168 self.eCaption.text(), os.linesep, istring) |
169 self.eCaption.text(), os.linesep, istring) |
169 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
170 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
170 self.eLabel.text(), os.linesep, istring) |
171 self.eLabel.text(), os.linesep, istring) |
171 code += '{0}, {1}, {2}, {3:d}){4}'.format( |
172 code += '{0}, {1}, {2}, {3:d}){4}'.format( |
172 doubleDefault, doubleFrom, doubleTo, |
173 doubleDefault, doubleFrom, doubleTo, |
173 self.sDoubleDecimals.value(), os.linesep) |
174 self.sDoubleDecimals.value(), estring) |
174 elif self.rItem.isChecked(): |
175 elif self.rItem.isChecked(): |
175 code += 'getItem(\\{0}{1}'.format(os.linesep, istring) |
176 code += 'getItem({0}{1}'.format(os.linesep, istring) |
176 code += 'None,{0}{1}'.format(os.linesep, istring) |
177 code += 'None,{0}{1}'.format(os.linesep, istring) |
177 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
178 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
178 self.eCaption.text(), os.linesep, istring) |
179 self.eCaption.text(), os.linesep, istring) |
179 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
180 code += 'self.trUtf8("{0}"),{1}{2}'.format( |
180 self.eLabel.text(), os.linesep, istring) |
181 self.eLabel.text(), os.linesep, istring) |
181 code += '{0},{1}{2}'.format(self.eVariable.text(), os.linesep, istring) |
182 code += '{0},{1}{2}'.format(self.eVariable.text(), os.linesep, istring) |
182 code += '{0:d}, {1}){2}'.format( |
183 code += '{0:d}, {1}){2}'.format( |
183 self.sCurrentItem.value(), self.cEditable.isChecked(), os.linesep) |
184 self.sCurrentItem.value(), self.cEditable.isChecked(), estring) |
184 |
185 |
185 return code |
186 return code |
186 |
187 |
187 def getCode(self, indLevel, indString): |
188 def getCode(self, indLevel, indString): |
188 """ |
189 """ |