[QGIS Commit] r8628 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jun 8 21:35:47 EDT 2008


Author: telwertowski
Date: 2008-06-08 21:35:46 -0400 (Sun, 08 Jun 2008)
New Revision: 8628

Modified:
   trunk/qgis/src/app/qgsserversourceselect.cpp
Log:
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.


Modified: trunk/qgis/src/app/qgsserversourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsserversourceselect.cpp	2008-06-08 18:10:57 UTC (rev 8627)
+++ trunk/qgis/src/app/qgsserversourceselect.cpp	2008-06-09 01:35:46 UTC (rev 8628)
@@ -517,60 +517,47 @@
  */
 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->parent()->text(1);
+      newSelectedStylesForSelectedLayers += item->text(1);
+    }
+    else
+    {
       layerName = item->text(1);
+      newSelectedStylesForSelectedLayers += "";
     }
 
-    if ( item->isSelected() )
+    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])
+        )
     {
-      newSelectedLayers += layerName;
+      // Remove old style selection
+      lstLayers->findItems(m_selectedStyleIdForLayer[layerName], Qt::MatchRecursive).first()->setSelected(false);
+    }
 
-      // save the name of the style selected for the layer, if appropriate
-
-      if (item->parent() != 0)
-      {
-        newSelectedStylesForSelectedLayers += item->text(1);
-      }
-      else
-      {
-        newSelectedStylesForSelectedLayers += "";
-      }
-
-      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);
-      }
-
 #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



More information about the QGIS-commit mailing list