Skip to content

Commit

Permalink
History entry nodes can be double-clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 23, 2023
1 parent fe4e9b5 commit 8958af7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/gui/auto_generated/history/qgshistoryentrynode.sip.in
Expand Up @@ -65,6 +65,11 @@ create the node's content.
.. seealso:: :py:func:`html`
%End

virtual void doubleClicked( const QgsHistoryWidgetContext &context );
%Docstring
Called when the node is double-clicked. The default implementation does nothing.
%End


virtual bool matchesString( const QString &searchString ) const;
%Docstring
Expand Down
5 changes: 5 additions & 0 deletions src/gui/history/qgshistoryentrynode.cpp
Expand Up @@ -36,6 +36,11 @@ QWidget *QgsHistoryEntryNode::createWidget( const QgsHistoryWidgetContext & )
return nullptr;
}

void QgsHistoryEntryNode::doubleClicked( const QgsHistoryWidgetContext & )
{

}

#if 0
QList<QAction *> QgsHistoryEntryNode::actions( QWidget * )
{
Expand Down
5 changes: 5 additions & 0 deletions src/gui/history/qgshistoryentrynode.h
Expand Up @@ -87,6 +87,11 @@ class GUI_EXPORT QgsHistoryEntryNode
*/
virtual QWidget *createWidget( const QgsHistoryWidgetContext &context ) SIP_FACTORY;

/**
* Called when the node is double-clicked. The default implementation does nothing.
*/
virtual void doubleClicked( const QgsHistoryWidgetContext &context );

#if 0 // currently unused

/**
Expand Down
10 changes: 10 additions & 0 deletions src/gui/history/qgshistorywidget.cpp
Expand Up @@ -36,6 +36,8 @@ QgsHistoryWidget::QgsHistoryWidget( const QString &providerId, Qgis::HistoryProv
mFilterEdit->setShowSearchIcon( true );
connect( mFilterEdit, &QLineEdit::textChanged, mProxyModel, &QgsHistoryEntryProxyModel::setFilter );
connect( mTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsHistoryWidget::currentItemChanged );
connect( mTreeView, &QTreeView::doubleClicked, this, &QgsHistoryWidget::nodeDoubleClicked );

}

void QgsHistoryWidget::currentItemChanged( const QModelIndex &selected, const QModelIndex & )
Expand Down Expand Up @@ -73,6 +75,14 @@ void QgsHistoryWidget::currentItemChanged( const QModelIndex &selected, const QM
}
}

void QgsHistoryWidget::nodeDoubleClicked( const QModelIndex &index )
{
if ( QgsHistoryEntryNode *node = mModel->index2node( mProxyModel->mapToSource( index ) ) )
{
node->doubleClicked( mContext );
}
}

//
// QgsHistoryEntryProxyModel
//
Expand Down
1 change: 1 addition & 0 deletions src/gui/history/qgshistorywidget.h
Expand Up @@ -79,6 +79,7 @@ class GUI_EXPORT QgsHistoryWidget : public QgsPanelWidget, private Ui::QgsHistor
private slots:

void currentItemChanged( const QModelIndex &selected, const QModelIndex &previous );
void nodeDoubleClicked( const QModelIndex &index );

private:

Expand Down

0 comments on commit 8958af7

Please sign in to comment.