src/hbwidgets/editors/hbformatdialog.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
--- a/src/hbwidgets/editors/hbformatdialog.cpp	Mon May 03 12:48:33 2010 +0300
+++ b/src/hbwidgets/editors/hbformatdialog.cpp	Fri May 14 16:09:54 2010 +0300
@@ -311,29 +311,29 @@
 {
     Q_D(HbFormatDialog);
 
-    QTextCursor cursor = d->editor->textCursor();
+    int indent;
     QTextListFormat::Style style;
+    QTextCursor cursor = d->editor->textCursor();
+
+    cursor.beginEditBlock();
     if (toggled) {
+        indent = 1;
         style = QTextListFormat::ListDisc;
     } else {
+        indent = 0;
         style = QTextListFormat::ListStyleUndefined;
     }
-    QTextBlockFormat blockFmt;
-    cursor.beginEditBlock();
-    blockFmt = cursor.blockFormat();
     QTextListFormat listFmt;
-    int indent = blockFmt.indent() + 1;
     if (cursor.currentList()) {
         listFmt = cursor.currentList()->format();
-        if (!toggled)
-            indent = 0;
-     } else {
-        blockFmt.setIndent(0);
-        cursor.setBlockFormat(blockFmt);
     }
     listFmt.setIndent(indent);
     listFmt.setStyle(style);
-    cursor.createList(listFmt);
+    if (!cursor.currentList()) {
+        cursor.createList(listFmt);
+    } else {
+        cursor.currentList()->setFormat(listFmt);
+    }
     cursor.endEditBlock();
 }