224 if self.__lineEditKind: |
224 if self.__lineEditKind: |
225 return self._editor.text() |
225 return self._editor.text() |
226 else: |
226 else: |
227 return self._editor.currentText() |
227 return self._editor.currentText() |
228 |
228 |
229 def setText(self, path): |
229 def setText(self, path, toNative=True): |
230 """ |
230 """ |
231 Public method to set the current path. |
231 Public method to set the current path. |
232 |
232 |
233 @param path path to be set |
233 @param path path to be set |
234 @type str |
234 @type str |
|
235 @param toNative flag indicating to convert the path into |
|
236 a native format |
|
237 @type bool |
235 """ |
238 """ |
236 if self.__mode == E5PathPickerModes.OpenFilesMode: |
239 if self.__mode == E5PathPickerModes.OpenFilesMode: |
237 self._setEditorText(path) |
240 self._setEditorText(path) |
238 else: |
241 else: |
239 path = Utilities.toNativeSeparators(path) |
242 if toNative: |
|
243 path = Utilities.toNativeSeparators(path) |
240 self._setEditorText(path) |
244 self._setEditorText(path) |
241 if self._completer: |
245 if self._completer: |
242 self._completer.setRootPath(path) |
246 self._completer.setRootPath(path) |
243 |
247 |
244 def text(self): |
248 def text(self, toNative=True): |
245 """ |
249 """ |
246 Public method to get the current path. |
250 Public method to get the current path. |
247 |
251 |
|
252 @param toNative flag indicating to convert the path into |
|
253 a native format |
|
254 @type bool |
248 @return current path |
255 @return current path |
249 @rtype str |
256 @rtype str |
250 """ |
257 """ |
251 if self.__mode == E5PathPickerModes.OpenFilesMode: |
258 if self.__mode == E5PathPickerModes.OpenFilesMode: |
252 return ";".join( |
259 if toNative: |
253 [Utilities.toNativeSeparators(path) |
260 return ";".join( |
254 for path in self._editorText().split(";")]) |
261 [Utilities.toNativeSeparators(path) |
255 else: |
262 for path in self._editorText().split(";")]) |
256 return os.path.expanduser( |
263 else: |
257 Utilities.toNativeSeparators(self._editorText())) |
264 return self._editorText() |
258 |
265 else: |
259 def setEditText(self, path): |
266 if toNative: |
|
267 return os.path.expanduser( |
|
268 Utilities.toNativeSeparators(self._editorText())) |
|
269 else: |
|
270 return os.path.expanduser(self._editorText()) |
|
271 |
|
272 def setEditText(self, path, toNative=True): |
260 """ |
273 """ |
261 Public method to set the current path. |
274 Public method to set the current path. |
262 |
275 |
263 @param path path to be set |
276 @param path path to be set |
264 @type str |
277 @type str |
265 """ |
278 @param toNative flag indicating to convert the path into |
266 self.setText(path) |
279 a native format |
267 |
280 @type bool |
268 def currentText(self): |
281 """ |
|
282 self.setText(path, toNative=toNative) |
|
283 |
|
284 def currentText(self, toNative=True): |
269 """ |
285 """ |
270 Public method to get the current path. |
286 Public method to get the current path. |
271 |
287 |
|
288 @param toNative flag indicating to convert the path into |
|
289 a native format |
|
290 @type bool |
272 @return current path |
291 @return current path |
273 @rtype str |
292 @rtype str |
274 """ |
293 """ |
275 return self.text() |
294 return self.text(toNative=toNative) |
276 |
295 |
277 def setPath(self, path): |
296 def setPath(self, path, toNative=True): |
278 """ |
297 """ |
279 Public method to set the current path. |
298 Public method to set the current path. |
280 |
299 |
281 @param path path to be set |
300 @param path path to be set |
282 @type str |
301 @type str |
283 """ |
302 @param toNative flag indicating to convert the path into |
284 self.setText(path) |
303 a native format |
285 |
304 @type bool |
286 def path(self): |
305 """ |
|
306 self.setText(path, toNative=toNative) |
|
307 |
|
308 def path(self, toNative=True): |
287 """ |
309 """ |
288 Public method to get the current path. |
310 Public method to get the current path. |
289 |
311 |
|
312 @param toNative flag indicating to convert the path into |
|
313 a native format |
|
314 @type bool |
290 @return current path |
315 @return current path |
291 @rtype str |
316 @rtype str |
292 """ |
317 """ |
293 return self.text() |
318 return self.text(toNative=toNative) |
294 |
319 |
295 def paths(self): |
320 def paths(self, toNative=True): |
296 """ |
321 """ |
297 Public method to get the list of entered paths. |
322 Public method to get the list of entered paths. |
298 |
323 |
|
324 @param toNative flag indicating to convert the path into |
|
325 a native format |
|
326 @type bool |
299 @return entered paths |
327 @return entered paths |
300 @rtype list of str |
328 @rtype list of str |
301 """ |
329 """ |
302 if self.__mode == E5PathPickerModes.OpenFilesMode: |
330 if self.__mode == E5PathPickerModes.OpenFilesMode: |
303 return self.path().split(";") |
331 return self.path(toNative=toNative).split(";") |
304 else: |
332 else: |
305 return [self.path()] |
333 return [self.path(toNative=toNative)] |
306 |
334 |
307 def firstPath(self): |
335 def firstPath(self, toNative=True): |
308 """ |
336 """ |
309 Public method to get the first path of a list of entered paths. |
337 Public method to get the first path of a list of entered paths. |
310 |
338 |
|
339 @param toNative flag indicating to convert the path into |
|
340 a native format |
|
341 @type bool |
311 @return first path |
342 @return first path |
312 @rtype str |
343 @rtype str |
313 """ |
344 """ |
314 return self.paths()[0] |
345 return self.paths(toNative=toNative)[0] |
315 |
346 |
316 def lastPath(self): |
347 def lastPath(self, toNative=True): |
317 """ |
348 """ |
318 Public method to get the last path of a list of entered paths. |
349 Public method to get the last path of a list of entered paths. |
319 |
350 |
|
351 @param toNative flag indicating to convert the path into |
|
352 a native format |
|
353 @type bool |
320 @return last path |
354 @return last path |
321 @rtype str |
355 @rtype str |
322 """ |
356 """ |
323 return self.paths()[-1] |
357 return self.paths(toNative=toNative)[-1] |
324 |
358 |
325 def setEditorEnabled(self, enable): |
359 def setEditorEnabled(self, enable): |
326 """ |
360 """ |
327 Public method to set the path editor's enabled state. |
361 Public method to set the path editor's enabled state. |
328 |
362 |