41
41
#include " qgswebview.h"
42
42
#include " qgswebframe.h"
43
43
#include " qgsstringutils.h"
44
+ #include " qgstreewidgetitem.h"
44
45
45
46
#include < QCloseEvent>
46
47
#include < QLabel>
@@ -412,8 +413,9 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
412
413
413
414
if ( derivedAttributes.size () >= 0 )
414
415
{
415
- QTreeWidgetItem *derivedItem = new QTreeWidgetItem ( QStringList () << tr ( " (Derived)" ) );
416
+ QgsTreeWidgetItem *derivedItem = new QgsTreeWidgetItem ( QStringList () << tr ( " (Derived)" ) );
416
417
derivedItem->setData ( 0 , Qt::UserRole, " derived" );
418
+ derivedItem->setAlwaysOnTopPriority ( 0 );
417
419
featItem->addChild ( derivedItem );
418
420
419
421
for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin (); it != derivedAttributes.end (); ++it )
@@ -427,8 +429,9 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
427
429
428
430
if ( !vlayer->fields ().isEmpty () || vlayer->actions ()->size () || !registeredActions.isEmpty () )
429
431
{
430
- QTreeWidgetItem *actionItem = new QTreeWidgetItem ( QStringList () << tr ( " (Actions)" ) );
432
+ QgsTreeWidgetItem *actionItem = new QgsTreeWidgetItem ( QStringList () << tr ( " (Actions)" ) );
431
433
actionItem->setData ( 0 , Qt::UserRole, " actions" );
434
+ actionItem->setAlwaysOnTopPriority ( 1 );
432
435
featItem->addChild ( actionItem );
433
436
434
437
if ( vlayer->fields ().size () > 0 )
@@ -485,7 +488,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
485
488
defVal = vlayer->dataProvider ()->defaultValue ( fields.fieldOriginIndex ( i ) ).toString ();
486
489
487
490
QString value = defVal == attrs.at ( i ) ? defVal : fields.at ( i ).displayString ( attrs.at ( i ) );
488
- QTreeWidgetItem *attrItem = new QTreeWidgetItem ( QStringList () << QString::number ( i ) << value );
491
+ QgsTreeWidgetItem *attrItem = new QgsTreeWidgetItem ( QStringList () << QString::number ( i ) << value );
489
492
featItem->addChild ( attrItem );
490
493
491
494
attrItem->setData ( 0 , Qt::DisplayRole, vlayer->attributeDisplayName ( i ) );
@@ -495,14 +498,15 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
495
498
attrItem->setData ( 1 , Qt::UserRole, value );
496
499
497
500
value = representValue ( vlayer, fields.at ( i ).name (), attrs.at ( i ) );
501
+ attrItem->setSortData ( 1 , value );
498
502
bool foundLinks = false ;
499
503
QString links = QgsStringUtils::insertLinks ( value, &foundLinks );
500
504
if ( foundLinks )
501
505
{
502
506
QLabel* valueLabel = new QLabel ( links );
503
507
valueLabel->setOpenExternalLinks ( true );
504
- attrItem->treeWidget ()->setItemWidget ( attrItem, 1 , valueLabel );
505
508
attrItem->setData ( 1 , Qt::DisplayRole, QString () );
509
+ attrItem->treeWidget ()->setItemWidget ( attrItem, 1 , valueLabel );
506
510
}
507
511
else
508
512
{
@@ -785,8 +789,9 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
785
789
786
790
if ( derivedAttributes.size () >= 0 )
787
791
{
788
- QTreeWidgetItem *derivedItem = new QTreeWidgetItem ( QStringList () << tr ( " (Derived)" ) );
792
+ QgsTreeWidgetItem *derivedItem = new QgsTreeWidgetItem ( QStringList () << tr ( " (Derived)" ) );
789
793
derivedItem->setData ( 0 , Qt::UserRole, " derived" );
794
+ derivedItem->setAlwaysOnTopPriority ( 0 );
790
795
featItem->addChild ( derivedItem );
791
796
792
797
for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin (); it != derivedAttributes.end (); ++it )
@@ -1495,19 +1500,22 @@ void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx,
1495
1500
{
1496
1501
value = representValue ( vlayer, fld.name (), val );
1497
1502
1503
+ QgsTreeWidgetItem* treeItem = static_cast < QgsTreeWidgetItem* >( item );
1504
+ treeItem->setSortData ( 1 , value );
1505
+
1498
1506
bool foundLinks = false ;
1499
1507
QString links = QgsStringUtils::insertLinks ( value, &foundLinks );
1500
1508
if ( foundLinks )
1501
1509
{
1502
1510
QLabel* valueLabel = new QLabel ( links );
1503
1511
valueLabel->setOpenExternalLinks ( true );
1504
- item-> treeWidget ()-> setItemWidget ( item, 1 , valueLabel );
1505
- item-> setData ( 1 , Qt::DisplayRole, QString () );
1512
+ treeItem-> setData ( 1 , Qt::DisplayRole, QString () );
1513
+ treeItem-> treeWidget ()-> setItemWidget ( item, 1 , valueLabel );
1506
1514
}
1507
1515
else
1508
1516
{
1509
- item-> treeWidget ()-> setItemWidget ( item, 1 , nullptr );
1510
- item-> setData ( 1 , Qt::DisplayRole, value );
1517
+ treeItem-> setData ( 1 , Qt::DisplayRole, value );
1518
+ treeItem-> treeWidget ()-> setItemWidget ( item, 1 , nullptr );
1511
1519
}
1512
1520
return ;
1513
1521
}
0 commit comments