309 */ |
309 */ |
310 void HbFormatDialog::setStyleBullet(bool toggled) |
310 void HbFormatDialog::setStyleBullet(bool toggled) |
311 { |
311 { |
312 Q_D(HbFormatDialog); |
312 Q_D(HbFormatDialog); |
313 |
313 |
|
314 int indent; |
|
315 QTextListFormat::Style style; |
314 QTextCursor cursor = d->editor->textCursor(); |
316 QTextCursor cursor = d->editor->textCursor(); |
315 QTextListFormat::Style style; |
317 |
|
318 cursor.beginEditBlock(); |
316 if (toggled) { |
319 if (toggled) { |
|
320 indent = 1; |
317 style = QTextListFormat::ListDisc; |
321 style = QTextListFormat::ListDisc; |
318 } else { |
322 } else { |
|
323 indent = 0; |
319 style = QTextListFormat::ListStyleUndefined; |
324 style = QTextListFormat::ListStyleUndefined; |
320 } |
325 } |
321 QTextBlockFormat blockFmt; |
|
322 cursor.beginEditBlock(); |
|
323 blockFmt = cursor.blockFormat(); |
|
324 QTextListFormat listFmt; |
326 QTextListFormat listFmt; |
325 int indent = blockFmt.indent() + 1; |
|
326 if (cursor.currentList()) { |
327 if (cursor.currentList()) { |
327 listFmt = cursor.currentList()->format(); |
328 listFmt = cursor.currentList()->format(); |
328 if (!toggled) |
|
329 indent = 0; |
|
330 } else { |
|
331 blockFmt.setIndent(0); |
|
332 cursor.setBlockFormat(blockFmt); |
|
333 } |
329 } |
334 listFmt.setIndent(indent); |
330 listFmt.setIndent(indent); |
335 listFmt.setStyle(style); |
331 listFmt.setStyle(style); |
336 cursor.createList(listFmt); |
332 if (!cursor.currentList()) { |
|
333 cursor.createList(listFmt); |
|
334 } else { |
|
335 cursor.currentList()->setFormat(listFmt); |
|
336 } |
337 cursor.endEditBlock(); |
337 cursor.endEditBlock(); |
338 } |
338 } |
339 |
339 |
340 /*! |
340 /*! |
341 Sets alignment to left for the selected paragraphs or a paragraph containing cursor. |
341 Sets alignment to left for the selected paragraphs or a paragraph containing cursor. |