Skip to content

Commit

Permalink
[Backport release-3_40] add an option to define locator tree height (#…
Browse files Browse the repository at this point in the history
…59827)

* add an option to define locator tree height

* add comment that it requires a restart

---------

Co-authored-by: Denis Rouzaud <[email protected]>
  • Loading branch information
qgis-bot and 3nids authored Dec 11, 2024
1 parent e9fff29 commit 18c4c65
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and presenting them to users for selection.
#include "qgslocatorwidget.h"
%End
public:

QgsLocatorWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsLocatorWidget.
Expand Down
1 change: 1 addition & 0 deletions python/gui/auto_generated/locator/qgslocatorwidget.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and presenting them to users for selection.
#include "qgslocatorwidget.h"
%End
public:

QgsLocatorWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsLocatorWidget.
Expand Down
6 changes: 5 additions & 1 deletion src/gui/locator/qgslocatorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include <QTextLayout>
#include <QTextLine>

///@cond PRIVATE
const QgsSettingsEntryInteger *QgsLocatorWidget::settingLocatorTreeHeight = new QgsSettingsEntryInteger( QStringLiteral( "tree-height" ), sTreeGuiLocator, 20, QStringLiteral( "Number of rows to show in the locator tree (requires a restart)" ), Qgis::SettingsOptions(), 5 /*min*/, 100 /*max*/ );
///@endcond PRIVATE

QgsLocatorWidget::QgsLocatorWidget( QWidget *parent )
: QWidget( parent )
, mModelBridge( new QgsLocatorModelBridge( this ) )
Expand Down Expand Up @@ -404,7 +408,7 @@ void QgsLocatorResultsView::recalculateSize()
#endif

// try to show about 20 rows
int rowSize = 20 * itemDelegate()->sizeHint( optView, model()->index( 0, 0 ) ).height();
int rowSize = QgsLocatorWidget::settingLocatorTreeHeight->value() * itemDelegate()->sizeHint( optView, model()->index( 0, 0 ) ).height();

// try to take up a sensible portion of window width (about half)
int width = std::max( 300, window()->size().width() / 2 );
Expand Down
8 changes: 8 additions & 0 deletions src/gui/locator/qgslocatorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "qgslocatorfilter.h"
#include "qgsfloatingwidget.h"
#include "qgsfilterlineedit.h"
#include "qgssettingstree.h"

#include <QWidget>
#include <QTreeView>
Expand All @@ -34,6 +35,7 @@ class QgsLocatorResultsView;
class QgsMapCanvas;
class QgsLocatorModelBridge;
class QgsLocatorLineEdit;
class QgsSettingsEntryInteger;

/**
* \class QgsLocatorWidget
Expand All @@ -47,6 +49,12 @@ class GUI_EXPORT QgsLocatorWidget : public QWidget
Q_OBJECT

public:
#ifndef SIP_RUN

static inline QgsSettingsTreeNode *sTreeGuiLocator = QgsSettingsTree::sTreeGui->createChildNode( QStringLiteral( "locator" ) );
static const QgsSettingsEntryInteger *settingLocatorTreeHeight;
#endif

/**
* Constructor for QgsLocatorWidget.
*/
Expand Down

0 comments on commit 18c4c65

Please sign in to comment.