Skip to content

Add "Show Full Text" option to Identify Settings #62946

Open
lanckmann wants to merge 24 commits intoqgis:masterfrom
lanckmann:feature-identify-show-full-text-56167
Open

Add "Show Full Text" option to Identify Settings #62946
lanckmann wants to merge 24 commits intoqgis:masterfrom
lanckmann:feature-identify-show-full-text-56167

Conversation

@lanckmann
Copy link
Contributor

Add 'Show full text' option to Identify Settings

Adds a new configurable option in the Identify Results dialog settings menu that allows to toggle between truncated text display (with "...") and full text display on multiple lines.
Added settingShowFullText boolean setting entry.
added "Show Full Text" checkbox to Identify Settings menu.
Implemented text display switching using QLabel widgets with word wrap.
Fixes #56167

@github-actions github-actions bot added this to the 4.0.0 milestone Aug 24, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 24, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 2a52a26)

🍎 MacOS Qt6 builds

Download MacOS Qt6 builds of this PR for testing.
This app is not notarized, run sudo xattr -d com.apple.quarantine /Applications/QGIS*.app to avoid the warning
(Built from commit 2a52a26)

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 070349e)

Comment on lines +831 to +849
if ( showFullText )
{
// Create a multi-line label widget to show full text
QLabel *valueLabel = new QLabel( representedValue );
valueLabel->setWordWrap( true );
valueLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
valueLabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
valueLabel->setStyleSheet( QStringLiteral( "QLabel { background: transparent; }" ) );

attrItem->setData( 1, Qt::DisplayRole, QString() );
QTreeWidget *tw = attrItem->treeWidget();
tw->setItemWidget( attrItem, 1, valueLabel );
}
else
{
attrItem->setData( 1, Qt::DisplayRole, representedValue );
QTreeWidget *tw = attrItem->treeWidget();
tw->setItemWidget( attrItem, 1, nullptr );
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( showFullText )
{
// Create a multi-line label widget to show full text
QLabel *valueLabel = new QLabel( representedValue );
valueLabel->setWordWrap( true );
valueLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
valueLabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
valueLabel->setStyleSheet( QStringLiteral( "QLabel { background: transparent; }" ) );
attrItem->setData( 1, Qt::DisplayRole, QString() );
QTreeWidget *tw = attrItem->treeWidget();
tw->setItemWidget( attrItem, 1, valueLabel );
}
else
{
attrItem->setData( 1, Qt::DisplayRole, representedValue );
QTreeWidget *tw = attrItem->treeWidget();
tw->setItemWidget( attrItem, 1, nullptr );
}
// Create a multi-line label widget to show full text
QLabel *valueLabel = new QLabel( representedValue );
valueLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
valueLabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
valueLabel->setStyleSheet( QStringLiteral( "QLabel { background: transparent; }" ) );
if ( showFullText )
{
valueLabel->setWordWrap( true );
}
attrItem->setData( 1, Qt::DisplayRole, QString() );
QTreeWidget *tw = attrItem->treeWidget();
tw->setItemWidget( attrItem, 1, valueLabel );

Would it work like this as well? Or would it not set the ellipsis in the right way?

Comment on lines +2908 to +2915
QLabel *valueLabel = new QLabel( fullText );
valueLabel->setWordWrap( true );
valueLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
valueLabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
valueLabel->setStyleSheet( QStringLiteral( "QLabel { background: transparent; }" ) );


item->setData( 1, Qt::DisplayRole, QString() );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little bit duplicated code. If someone changes something in the styling (like background) it has to be done here and on QgsIdentifyResultsDialog. Maybe this can be improved. What do you think?

// Always create a label widget for consistent styling and text selection
QLabel *valueLabel = createStyledLabel( representedValue, showFullText );
attrItem->setText( 1, representedValue );
attrItem->setData( 1, Qt::DisplayRole, representedValue );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the foundLinks == true branch we set the DisplayRole to QString() -- I believe that should also be done here, otherwise the transparent background for the label will result in overlapping text

layItem->setText( 0, QStringLiteral( "%1 %2" ).arg( vlayer->name(), countSuffix ) );


updateTextDisplay();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be called here -- this method will be called many times if multiple features are identified, and it's iterating through everything in the list for every feature added. That'll add up quickly.

@lanckmann lanckmann requested a review from nyalldawson October 10, 2025 13:43
@lanckmann lanckmann force-pushed the feature-identify-show-full-text-56167 branch from c92b6f9 to adae752 Compare November 3, 2025 14:23
@lanckmann lanckmann force-pushed the feature-identify-show-full-text-56167 branch from 14e969b to d38177e Compare November 17, 2025 15:59
@lanckmann lanckmann requested a review from signedav November 17, 2025 16:01
Copy link
Collaborator

@signedav signedav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lanckmann

It's a nice option, but there are some parts I don't get why it's done like it's done (see comments).

The label works not like expected btw. on my system (I don't have the resources to evaluate the reason atm):

image

}
}

QLabel *QgsIdentifyResultsDialog::createStyledLabel( const QString &text, bool wordWrap )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a case where createStyledLabel should not wordWrap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I might need two different label styles like the first with word wrap for long text and the second without word wrap for short text or other use cases. So i added the "wordWrap" parameter thinking it would make the function more flexible.

: item->text( 1 );

QTreeWidget *treeWidget = item->treeWidget();
const int lengthThreshold = 100; // Characters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing. Why 100? 100 is usually truncated...
It should be the width of the panel. Means if it's truncated, then it makes sense to wrap, no?

Or why not wrap it always when this setting is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to avoid creating QLabel widgets for short text like "abc" or "123", thinking it would be overhead. So I added a 100 char threshold (width calcul) .

const QFontMetrics fm( valueLabel->font() );
const int avgCharWidth = fm.averageCharWidth();
const int maxCharsPerLine = 100; // Reasonable column width estimate
const int maxLines = 20;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens, when it's more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried about performance issues with very long text values. In some datasets, attribute fields can contain huge amounts of text

@lanckmann lanckmann requested a review from signedav November 20, 2025 17:00
@signedav
Copy link
Collaborator

Ok, but I'm quite busy at the moment. I'll need some time for another review.

- Ensure setText() is called before setItemWidget() to preserve item text
- Fix TestQgsIdentify::closestPoint() expecting col1Item->text(1) to return value
- Maintain backward compatibility with existing test expectations
- Ensure setText() is called before setItemWidget() to preserve item text
- Fix TestQgsIdentify::closestPoint() expecting col1Item->text(1) to return value
- Maintain backward compatibility with existing test expectations
…isplayRole to QString() to prevent text overlap with transparent label backgrounds- Move updateTextDisplay() call from addFeature() to updateViewModes() to avoid repeated iterations when multiple features are identified. reviewer feedback
@lanckmann lanckmann force-pushed the feature-identify-show-full-text-56167 branch from 93949b9 to eb90a50 Compare November 27, 2025 15:20
@github-actions
Copy link
Contributor

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Dec 12, 2025
@signedav
Copy link
Collaborator

No stale. But not sure if I find time to review before Christmas. Sorry, about that. There are quite some pieces I need to reproduce to fully be able to confirm.

@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Dec 12, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 2, 2026
@jfbourdon
Copy link
Contributor

Not stale

@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 7, 2026
@github-actions
Copy link
Contributor

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 22, 2026
@lanckmann
Copy link
Contributor Author

No stale

@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 22, 2026
@nyalldawson nyalldawson added the Freeze Exempt Feature Freeze exemption granted label Jan 27, 2026
@github-actions github-actions bot added the GUI/UX Related to QGIS application GUI or User Experience label Feb 8, 2026
@nyalldawson nyalldawson added Frozen Feature freeze - Do not merge! and removed Freeze Exempt Feature Freeze exemption granted labels Feb 20, 2026
@nyalldawson nyalldawson removed the Frozen Feature freeze - Do not merge! label Mar 10, 2026
@lanckmann lanckmann requested a review from signedav March 10, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GUI/UX Related to QGIS application GUI or User Experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Identify Settings: new option "Show full text"

4 participants