Skip to content

Commit 8958af7

Browse files
committedApr 23, 2023
History entry nodes can be double-clicked
1 parent fe4e9b5 commit 8958af7

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed
 

‎python/gui/auto_generated/history/qgshistoryentrynode.sip.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ create the node's content.
6565
.. seealso:: :py:func:`html`
6666
%End
6767

68+
virtual void doubleClicked( const QgsHistoryWidgetContext &context );
69+
%Docstring
70+
Called when the node is double-clicked. The default implementation does nothing.
71+
%End
72+
6873

6974
virtual bool matchesString( const QString &searchString ) const;
7075
%Docstring

‎src/gui/history/qgshistoryentrynode.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ QWidget *QgsHistoryEntryNode::createWidget( const QgsHistoryWidgetContext & )
3636
return nullptr;
3737
}
3838

39+
void QgsHistoryEntryNode::doubleClicked( const QgsHistoryWidgetContext & )
40+
{
41+
42+
}
43+
3944
#if 0
4045
QList<QAction *> QgsHistoryEntryNode::actions( QWidget * )
4146
{

‎src/gui/history/qgshistoryentrynode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class GUI_EXPORT QgsHistoryEntryNode
8787
*/
8888
virtual QWidget *createWidget( const QgsHistoryWidgetContext &context ) SIP_FACTORY;
8989

90+
/**
91+
* Called when the node is double-clicked. The default implementation does nothing.
92+
*/
93+
virtual void doubleClicked( const QgsHistoryWidgetContext &context );
94+
9095
#if 0 // currently unused
9196

9297
/**

‎src/gui/history/qgshistorywidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ QgsHistoryWidget::QgsHistoryWidget( const QString &providerId, Qgis::HistoryProv
3636
mFilterEdit->setShowSearchIcon( true );
3737
connect( mFilterEdit, &QLineEdit::textChanged, mProxyModel, &QgsHistoryEntryProxyModel::setFilter );
3838
connect( mTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsHistoryWidget::currentItemChanged );
39+
connect( mTreeView, &QTreeView::doubleClicked, this, &QgsHistoryWidget::nodeDoubleClicked );
40+
3941
}
4042

4143
void QgsHistoryWidget::currentItemChanged( const QModelIndex &selected, const QModelIndex & )
@@ -73,6 +75,14 @@ void QgsHistoryWidget::currentItemChanged( const QModelIndex &selected, const QM
7375
}
7476
}
7577

78+
void QgsHistoryWidget::nodeDoubleClicked( const QModelIndex &index )
79+
{
80+
if ( QgsHistoryEntryNode *node = mModel->index2node( mProxyModel->mapToSource( index ) ) )
81+
{
82+
node->doubleClicked( mContext );
83+
}
84+
}
85+
7686
//
7787
// QgsHistoryEntryProxyModel
7888
//

‎src/gui/history/qgshistorywidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class GUI_EXPORT QgsHistoryWidget : public QgsPanelWidget, private Ui::QgsHistor
7979
private slots:
8080

8181
void currentItemChanged( const QModelIndex &selected, const QModelIndex &previous );
82+
void nodeDoubleClicked( const QModelIndex &index );
8283

8384
private:
8485

0 commit comments

Comments
 (0)
Please sign in to comment.