From 28c8c408c57f0db6232d6c244384f51de10f97d4 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 6 May 2025 08:12:32 +0200 Subject: [PATCH] list view: Add pressed() and clicked() signals Resolves: #515 --- src/controls/QskListView.cpp | 25 ++++++++++++++++++++++++- src/controls/QskListView.h | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/controls/QskListView.cpp b/src/controls/QskListView.cpp index ede7038f..f39cc1d4 100644 --- a/src/controls/QskListView.cpp +++ b/src/controls/QskListView.cpp @@ -315,9 +315,15 @@ void QskListView::keyReleaseEvent( QKeyEvent* event ) void QskListView::mousePressEvent( QMouseEvent* event ) { + const int row = qskRowAt( this, qskMousePosition( event ) ); + + if( row >= 0 ) + { + Q_EMIT pressed( row ); + } + if ( m_data->selectionMode != NoSelection ) { - const int row = qskRowAt( this, qskMousePosition( event ) ); if ( row >= 0 ) { m_data->setRowState( this, row, Pressed ); @@ -331,6 +337,23 @@ void QskListView::mousePressEvent( QMouseEvent* event ) void QskListView::mouseReleaseEvent( QMouseEvent* event ) { + const int row = qskRowAt( this, qskMousePosition( event ) ); + + if( row == m_data->selectedRow ) + { + Q_EMIT clicked( row ); + } + + if ( m_data->selectionMode != NoSelection ) + { + if ( row >= 0 ) + { + m_data->setRowState( this, row, Pressed ); + setSelectedRow( row ); + return; + } + } + m_data->setRowState( this, -1, Pressed ); Inherited::mouseReleaseEvent( event ); } diff --git a/src/controls/QskListView.h b/src/controls/QskListView.h index a137b25e..f62bb125 100644 --- a/src/controls/QskListView.h +++ b/src/controls/QskListView.h @@ -70,6 +70,8 @@ class QSK_EXPORT QskListView : public QskScrollView void setSelectedRow( int row ); Q_SIGNALS: + void pressed( int row ); + void clicked( int row ); void selectedRowChanged( int row ); void selectionModeChanged();