22#include <QTextBrowser> 
   33  mProxyModel = 
new QgsHistoryEntryProxyModel( 
this );
 
   34  mProxyModel->setSourceModel( mModel );
 
   36  mTreeView->setModel( mProxyModel );
 
   38  mFilterEdit->setShowClearButton( 
true );
 
   39  mFilterEdit->setShowSearchIcon( 
true );
 
   40  connect( mFilterEdit, &QLineEdit::textChanged, mProxyModel, &QgsHistoryEntryProxyModel::setFilter );
 
   41  connect( mTreeView->selectionModel(), &QItemSelectionModel::currentChanged, 
this, &QgsHistoryWidget::currentItemChanged );
 
   42  connect( mTreeView, &QTreeView::doubleClicked, 
this, &QgsHistoryWidget::nodeDoubleClicked );
 
   43  mTreeView->setExpandsOnDoubleClick( 
false );
 
   45  mTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
 
   46  connect( mTreeView, &QWidget::customContextMenuRequested, 
this, &QgsHistoryWidget::showNodeContextMenu );
 
   49  const QModelIndex firstGroup = mProxyModel->index( 0, 0, QModelIndex() );
 
   50  mTreeView->expand( firstGroup );
 
   53  mSplitter->restoreState( settings.
value( QStringLiteral( 
"history/splitterState%1" ).arg( providerId ) ).toByteArray() );
 
   55  connect( mSplitter, &QSplitter::splitterMoved, 
this, [providerId, 
this]
 
   58    settings.
setValue( QStringLiteral( 
"history/splitterState%1" ).arg( providerId ), mSplitter->saveState() );
 
   62void QgsHistoryWidget::currentItemChanged( 
const QModelIndex &selected, 
const QModelIndex & )
 
   64  QWidget *newWidget = 
nullptr;
 
   67    newWidget = node->createWidget( mContext );
 
   70      const QString html = node->html( mContext );
 
   71      if ( !html.isEmpty() )
 
   73        QTextBrowser *htmlBrowser = 
new QTextBrowser();
 
   74        htmlBrowser->setOpenExternalLinks( 
true );
 
   75        htmlBrowser->setHtml( html );
 
   76        newWidget = htmlBrowser;
 
   81      mContainerStackedWidget->addWidget( newWidget );
 
   82      mContainerStackedWidget->setCurrentWidget( newWidget );
 
   89    if ( mContainerStackedWidget->count() > 1 )
 
   91      mContainerStackedWidget->removeWidget( mContainerStackedWidget->widget( 1 ) );
 
   92      mContainerStackedWidget->setCurrentIndex( 0 );
 
   97void QgsHistoryWidget::nodeDoubleClicked( 
const QModelIndex &index )
 
  101    if ( node->doubleClicked( mContext ) )
 
  106  if ( mTreeView->isExpanded( index ) )
 
  107    mTreeView->collapse( index );
 
  109    mTreeView->expand( index );
 
  112void QgsHistoryWidget::showNodeContextMenu( 
const QPoint &pos )
 
  116    QMenu *menu = 
new QMenu();
 
  118    node->populateContextMenu( menu, mContext );
 
  119    if ( !menu->isEmpty() )
 
  121      menu->exec( mTreeView->mapToGlobal( pos ) );
 
  132QgsHistoryEntryProxyModel::QgsHistoryEntryProxyModel( QObject *parent )
 
  133  : QSortFilterProxyModel( parent )
 
  135  setDynamicSortFilter( 
true );
 
  136  setRecursiveFilteringEnabled( 
true );
 
  139void QgsHistoryEntryProxyModel::setFilter( 
const QString &filter )
 
  141  if ( filter == mFilter )
 
  148bool QgsHistoryEntryProxyModel::filterAcceptsRow( 
int source_row, 
const QModelIndex &source_parent )
 const 
  150  if ( mFilter.isEmpty() )
 
  153  const QModelIndex sourceIndex = sourceModel()->index( source_row, 0, source_parent );
 
  154  if ( 
QgsHistoryEntryNode *node = qobject_cast< QgsHistoryEntryModel * >( sourceModel() )->index2node( sourceIndex ) )
 
  156    if ( !node->matchesString( mFilter ) )
 
An item model representing history entries in a hierarchical tree structure.
 
QgsHistoryEntryNode * index2node(const QModelIndex &index) const
Returns node for given index.
 
Base class for nodes representing a QgsHistoryEntry.
 
The QgsHistoryProviderRegistry is a registry for objects which track user history (i....
 
Contains settings which reflect the context in which a history widget is shown, e....
 
QgsHistoryWidget(const QString &providerId=QString(), Qgis::HistoryProviderBackends backends=Qgis::HistoryProviderBackend::LocalProfile, QgsHistoryProviderRegistry *registry=nullptr, const QgsHistoryWidgetContext &context=QgsHistoryWidgetContext(), QWidget *parent=nullptr)
Constructor for QgsHistoryWidget, with the specified parent widget.
 
This class is a composition of two QSettings instances:
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.