Skip to content

Commit

Permalink
Allow showing html results from nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 22, 2023
1 parent 167d4e1 commit 1f5f4a9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/gui/history/qgshistorywidget.cpp
Expand Up @@ -18,6 +18,8 @@
#include "qgshistoryentrymodel.h"
#include "qgshistoryentrynode.h"

#include <QTextBrowser>

QgsHistoryWidget::QgsHistoryWidget( const QString &providerId, Qgis::HistoryProviderBackends backends, QgsHistoryProviderRegistry *registry, QWidget *parent )
: QgsPanelWidget( parent )
{
Expand All @@ -27,7 +29,6 @@ QgsHistoryWidget::QgsHistoryWidget( const QString &providerId, Qgis::HistoryProv
mTreeView->setModel( mModel );

connect( mTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsHistoryWidget::currentItemChanged );

}

void QgsHistoryWidget::currentItemChanged( const QModelIndex &selected, const QModelIndex & )
Expand All @@ -36,6 +37,17 @@ void QgsHistoryWidget::currentItemChanged( const QModelIndex &selected, const QM
if ( QgsHistoryEntryNode *node = mModel->index2node( selected ) )
{
newWidget = node->createWidget();
if ( !newWidget )
{
const QString html = node->html();
if ( !html.isEmpty() )
{
QTextBrowser *htmlBrowser = new QTextBrowser();
htmlBrowser->setOpenExternalLinks( true );
htmlBrowser->setHtml( html );
newWidget = htmlBrowser;
}
}
if ( newWidget )
{
mContainerStackedWidget->addWidget( newWidget );
Expand Down

0 comments on commit 1f5f4a9

Please sign in to comment.