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

Selection is modified when checking/uncheckin checkable items

    XMLWordPrintable

Details

    Description

      This can interfere with existing selections and does not seem to make sense in certain cases.

      Here's a patch to modify this behavior:

      ---                    
      
      diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
      index d4ce8f6..acecdbf 100644                                                         
      --- a/src/gui/itemviews/qitemdelegate.cpp                                             
      +++ b/src/gui/itemviews/qitemdelegate.cpp                                             
      @@ -1277,7 +1277,7 @@ bool QItemDelegate::editorEvent(QEvent *event,                  
                                                                                            
           // make sure that we have the right event type                                   
           if ((event->type() == QEvent::MouseButtonRelease)                                
      -        || (event->type() == QEvent::MouseButtonDblClick)) {                         
      +        || (event->type() == QEvent::MouseButtonPress)) {                            
               QRect checkRect = check(option, option.rect, Qt::Checked);                   
               QRect emptyRect;                                                             
               doLayout(option, &checkRect, &emptyRect, &emptyRect, false);                 
      @@ -1286,7 +1286,7 @@ bool QItemDelegate::editorEvent(QEvent *event,                  
                   return false;                                                            
                                                                                            
               // eat the double click events inside the check rect                         
      -        if (event->type() == QEvent::MouseButtonDblClick)                            
      +        if (event->type() == QEvent::MouseButtonPress)                               
                   return true;
      
           } else if (event->type() == QEvent::KeyPress) {
      diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
      index aec943c..cea83cd 100644
      --- a/src/gui/itemviews/qstyleditemdelegate.cpp
      +++ b/src/gui/itemviews/qstyleditemdelegate.cpp
      @@ -732,7 +732,7 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
      
           // make sure that we have the right event type
           if ((event->type() == QEvent::MouseButtonRelease)
      -        || (event->type() == QEvent::MouseButtonDblClick)) {
      +        || (event->type() == QEvent::MouseButtonPress)) {
               QStyleOptionViewItemV4 viewOpt(option);
               initStyleOption(&viewOpt, index);
               QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, widget);
      @@ -741,7 +741,7 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
                   return false;
      
               // eat the double click events inside the check rect
      -        if (event->type() == QEvent::MouseButtonDblClick)
      +        if (event->type() == QEvent::MouseButtonPress)
                   return true;
      
           } else if (event->type() == QEvent::KeyPress) {
      --
      

      Attachments

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

        Activity

          People

            ntg Pierre Rossi
            ntg Pierre Rossi
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes