Skip to content

Commit

Permalink
Additional conversion from Q3ListView to QTreeWidget. This is an addi…
Browse files Browse the repository at this point in the history
…tion 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/qgis@8628 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Jun 9, 2008
1 parent f553a68 commit 92c7328
Showing 1 changed file with 22 additions and 35 deletions.
57 changes: 22 additions & 35 deletions src/app/qgsserversourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,60 +517,47 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
*/
void QgsServerSourceSelect::on_lstLayers_itemSelectionChanged()
{
QString layerName = "";

QStringList newSelectedLayers;
QStringList newSelectedStylesForSelectedLayers;

std::map<QString, QString> newSelectedStyleIdForLayer;

// Iterate through the layers
QTreeWidgetItemIterator it( lstLayers );
while ( *it )
QList<QTreeWidgetItem *> selected( lstLayers->selectedItems() );
QList<QTreeWidgetItem *>::iterator it;
for (it = selected.begin(); it != selected.end(); ++it)
{
QTreeWidgetItem *item = *it;
QString layerName;

// save the name of the layer (in case only one of its styles was
// selected)
if (item->parent() == 0)
if (item->parent() != 0)
{
layerName = item->text(1);
layerName = item->parent()->text(1);
newSelectedStylesForSelectedLayers += item->text(1);
}

if ( item->isSelected() )
else
{
newSelectedLayers += layerName;

// save the name of the style selected for the layer, if appropriate

if (item->parent() != 0)
{
newSelectedStylesForSelectedLayers += item->text(1);
}
else
{
newSelectedStylesForSelectedLayers += "";
}
layerName = item->text(1);
newSelectedStylesForSelectedLayers += "";
}

newSelectedStyleIdForLayer[layerName] = item->text(0);
newSelectedLayers += layerName;
newSelectedStyleIdForLayer[layerName] = item->text(0);

// Check if multiple styles have now been selected
if (
(!(m_selectedStyleIdForLayer[layerName].isNull())) && // not just isEmpty()
(newSelectedStyleIdForLayer[layerName] != m_selectedStyleIdForLayer[layerName])
)
{
// Remove old style selection
lstLayers->findItems(m_selectedStyleIdForLayer[layerName], 0).first()->setSelected(FALSE);
}
// Check if multiple styles have now been selected
if (
(!(m_selectedStyleIdForLayer[layerName].isNull())) && // not just isEmpty()
(newSelectedStyleIdForLayer[layerName] != m_selectedStyleIdForLayer[layerName])
)
{
// Remove old style selection
lstLayers->findItems(m_selectedStyleIdForLayer[layerName], Qt::MatchRecursive).first()->setSelected(false);
}

#ifdef QGISDEBUG
std::cout << "QgsServerSourceSelect::addLayers: Added " << item->text(0).toLocal8Bit().data() << std::endl;
#endif

}

++it;
}

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

0 comments on commit 92c7328

Please sign in to comment.