Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-65384

QTextList: need API to set the starting number

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • P4: Low
    • 6.6.0
    • None
    • GUI: Text handling
    • None
    • 3f40a8b5b (dev)

    Description

      This was mentioned here http://www.qtcentre.org/threads/62617-QTextList-constructor-question but I've discovered the same problem while trying to write an autotest for the new Markdown writer. Consider

          QTextCursor cursor(document);
      
          QTextList *list1 = cursor.createList(QTextListFormat::ListDecimal);
          cursor.insertText("ListItem 1");
          list1->add(cursor.block());
      

      Now (from the perspective of the writer, later on) what do we expect QTextBlock block.textList()->itemNumber(block) to return? It defaults to zero. (And tst_QTextList::autoNumbering() seems to confirm that it is correct.) It doesn't seem right if it's the view's (or writer's) job to assume that zero should actually mean one. So I think maybe a starting number property should be added to QTextListFormat. It could default to 1, because most people start numbering their lists from 1 when writing documents, but then it's possible to get back the zero-based numbering by setting the style's starting number to 0. It would also be possible to make a new list but continue where a previous list left off. It's not very clear when it's permitted to extend an existing list (after inserting some intervening non-list material) and when it's not permitted, so being able to start a new list with a higher starting number could be a workaround for troublesome use cases.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              srutledg Shawn Rutledge
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change