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

Add support for transferring a HeaderView section move passively to the model

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.8.0
    • None

    Description

      I propose adding a new enum related to movableColumns and movableRows in HorizontalHeaderView and VerticalHeaderView.

      Currently when enabling movableColumns (or Rows) and moving a column, the HeaderView will move the column visually but will not transfer this to the model.
      Internally it maintains a mapping between logical and visual columns indices.

      This is a valid usage when just wanting to change the columns order in the view and not in the underlying data, to put a more important column before an other for example.

      This is not the only usage for this feature though. One might want to change the underlying data instead, for example reordering rows in a view might be wanted for changing a priority number in a todo list. Another example might be a spreadsheet where the order of the rows/columns is part of the data.

      To enable this, I propose to add a property moveMode with the options: MoveVisually/MoveInModel/MoveSignalOnly (names to be discussed).

      • MoveVisually: This will have the same behavior as currently
      • MoveInModel: This will call the underlying QAIM::moveRow/moveColumn without maintaining a visual mapping.
      • MoveSignalOnly: This will do nothing bug call the rowMoved/columnMoved signal (or a new signal or callable property), letting the user code handle the moving logic.

      Not having this option already lead to unfortunate code in the SpreadSheet model example. The model has to do its own column/row mapping to counteract the one done in the view to make it so the headers keep their order in the view.
      https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quickcontrols/spreadsheets/Spreadsheets/ColumnHeaderView.qml?h=6.8.1#n21

      https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quickcontrols/spreadsheets/Spreadsheets/spreadmodel.cpp?h=6.8.1 (cf. headerData, getViewColumn/Row, mapColumn/Row)

      Things to consider:
      Should this be added in TableView or HeaderView?
      A different behavior for the rows and columns should be possible.
      What if the HeaderView does not use the TableView's model?
      The parameters of the column/rowMoved signals (int logicalIndex, int oldVisualIndex, int newVisualIndex) do not make much sense when not mapping with visual indices. Should we just say that logicalIndex would be equal to oldVisualIndex and move on?
      This should affect the moveColumn and moveRow functions in TableView too I guess (answering the first question of this list).

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            grecko Pierre-Yves Siret
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes