Skip to content

Commit 03fbf87

Browse files
author
telwertowski
committedJun 9, 2008
Additional conversion from Q3ListView to QTreeWidget. This is an addition to r8406 and fixes #1074.
For Q3ListView, each item is already set to the new selection state when on_lstLayers_selectionChanged is called. For QTreeWidget, each item still has the old selection state and selectedItems() must be used to get the new selection state. git-svn-id: http://svn.osgeo.org/qgis/trunk@8628 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent da6d132 commit 03fbf87

File tree

1 file changed

+22
-35
lines changed

1 file changed

+22
-35
lines changed
 

‎src/app/qgsserversourceselect.cpp

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -517,60 +517,47 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
517517
*/
518518
void QgsServerSourceSelect::on_lstLayers_itemSelectionChanged()
519519
{
520-
QString layerName = "";
521-
522520
QStringList newSelectedLayers;
523521
QStringList newSelectedStylesForSelectedLayers;
524522

525523
std::map<QString, QString> newSelectedStyleIdForLayer;
526524

527525
// Iterate through the layers
528-
QTreeWidgetItemIterator it( lstLayers );
529-
while ( *it )
526+
QList<QTreeWidgetItem *> selected( lstLayers->selectedItems() );
527+
QList<QTreeWidgetItem *>::iterator it;
528+
for (it = selected.begin(); it != selected.end(); ++it)
530529
{
531530
QTreeWidgetItem *item = *it;
531+
QString layerName;
532532

533-
// save the name of the layer (in case only one of its styles was
534-
// selected)
535-
if (item->parent() == 0)
533+
if (item->parent() != 0)
536534
{
537-
layerName = item->text(1);
535+
layerName = item->parent()->text(1);
536+
newSelectedStylesForSelectedLayers += item->text(1);
538537
}
539-
540-
if ( item->isSelected() )
538+
else
541539
{
542-
newSelectedLayers += layerName;
543-
544-
// save the name of the style selected for the layer, if appropriate
545-
546-
if (item->parent() != 0)
547-
{
548-
newSelectedStylesForSelectedLayers += item->text(1);
549-
}
550-
else
551-
{
552-
newSelectedStylesForSelectedLayers += "";
553-
}
540+
layerName = item->text(1);
541+
newSelectedStylesForSelectedLayers += "";
542+
}
554543

555-
newSelectedStyleIdForLayer[layerName] = item->text(0);
544+
newSelectedLayers += layerName;
545+
newSelectedStyleIdForLayer[layerName] = item->text(0);
556546

557-
// Check if multiple styles have now been selected
558-
if (
559-
(!(m_selectedStyleIdForLayer[layerName].isNull())) && // not just isEmpty()
560-
(newSelectedStyleIdForLayer[layerName] != m_selectedStyleIdForLayer[layerName])
561-
)
562-
{
563-
// Remove old style selection
564-
lstLayers->findItems(m_selectedStyleIdForLayer[layerName], 0).first()->setSelected(FALSE);
565-
}
547+
// Check if multiple styles have now been selected
548+
if (
549+
(!(m_selectedStyleIdForLayer[layerName].isNull())) && // not just isEmpty()
550+
(newSelectedStyleIdForLayer[layerName] != m_selectedStyleIdForLayer[layerName])
551+
)
552+
{
553+
// Remove old style selection
554+
lstLayers->findItems(m_selectedStyleIdForLayer[layerName], Qt::MatchRecursive).first()->setSelected(false);
555+
}
566556

567557
#ifdef QGISDEBUG
568558
std::cout << "QgsServerSourceSelect::addLayers: Added " << item->text(0).toLocal8Bit().data() << std::endl;
569559
#endif
570-
571-
}
572560

573-
++it;
574561
}
575562

576563
// If we got some selected items, let the user play with projections

0 commit comments

Comments
 (0)
Please sign in to comment.