Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-3_40] add an option to define locator tree height #59827

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading