322 return |
322 return |
323 |
323 |
324 from .ImageMarkupDialog import ImageMarkupDialog |
324 from .ImageMarkupDialog import ImageMarkupDialog |
325 dlg = ImageMarkupDialog(ImageMarkupDialog.RestMode) |
325 dlg = ImageMarkupDialog(ImageMarkupDialog.RestMode) |
326 if dlg.exec_() == QDialog.Accepted: |
326 if dlg.exec_() == QDialog.Accepted: |
327 address, altText, title, originalSize, width, height = \ |
327 address, altText, title, originalSize, width, height = ( |
328 dlg.getData() |
328 dlg.getData() |
|
329 ) |
329 |
330 |
330 lineSeparator = editor.getLineSeparator() |
331 lineSeparator = editor.getLineSeparator() |
331 markup = ".. image:: {0}{1}".format(address, lineSeparator) |
332 markup = ".. image:: {0}{1}".format(address, lineSeparator) |
332 lines = 1 |
333 lines = 1 |
333 if altText: |
334 if altText: |
397 else: |
398 else: |
398 markup = " * " |
399 markup = " * " |
399 lineSeparator = editor.getLineSeparator() |
400 lineSeparator = editor.getLineSeparator() |
400 editor.beginUndoAction() |
401 editor.beginUndoAction() |
401 if editor.hasSelectedText(): |
402 if editor.hasSelectedText(): |
402 startLine, startIndex, endLine, endIndex = \ |
403 startLine, startIndex, endLine, endIndex = ( |
403 editor.getSelection() |
404 editor.getSelection() |
|
405 ) |
404 if endIndex == 0: |
406 if endIndex == 0: |
405 endLine -= 1 |
407 endLine -= 1 |
406 for line in range(startLine, endLine + 1): |
408 for line in range(startLine, endLine + 1): |
407 editor.insertAt(markup, line, 0) |
409 editor.insertAt(markup, line, 0) |
408 editor.setCursorPosition(endLine + 1, 0) |
410 editor.setCursorPosition(endLine + 1, 0) |
417 0, 0, 99, 1) |
419 0, 0, 99, 1) |
418 if ok: |
420 if ok: |
419 if listElements == 0: |
421 if listElements == 0: |
420 listElements = 1 |
422 listElements = 1 |
421 cline, cindex = editor.getCursorPosition() |
423 cline, cindex = editor.getCursorPosition() |
422 listBody = \ |
424 listBody = ( |
423 listElements * "{1}{0}".format(lineSeparator, markup) |
425 listElements * "{1}{0}".format(lineSeparator, markup) |
|
426 ) |
424 if cindex == 0: |
427 if cindex == 0: |
425 editor.insertAt(listBody, cline, cindex) |
428 editor.insertAt(listBody, cline, cindex) |
426 editor.setCursorPosition(cline, len(markup)) |
429 editor.setCursorPosition(cline, len(markup)) |
427 else: |
430 else: |
428 if cline == editor.lines() - 1: |
431 if cline == editor.lines() - 1: |