When you have loaded some OSM data in a single layer and then open some
geo-tagged photos, Merkaartor is going to ask you to which of that
single layer you would like to add the photos. Same if you have loaded
some OSM data, or not, and a GPX track in a single layer. Then open some
photos and you can select between the OSM or the track layer. Since it
is so easy to open the photos directly from the camera (with no
geo-tagging post-processing) because Merkaartor already does that for
you (only if you select the track layer here!), I always select the
track layer. And if there's only one, I'll take it.

This patch avoids those "dumb questions" and decides on itself what
layer to select. If there's only one, that's it. If not, but there's
only one track layer, that's it. And only if there's still no decision,
the user is bothered with it.

Some more intelligence into the application, please. ;)

Should this patch conflict with any use case, please tell me.

-- 
Yves Goergen "LonelyPixel" <[email protected]>
Visit my web laboratory at http://beta.unclassified.de
--- merkaartor\GeoImageDock.cpp.orig    Fri Jan 02 23:21:14 2009
+++ merkaartor\GeoImageDock.cpp Mon Jan 05 21:44:30 2009
@@ -107,9 +107,25 @@
                QList<int> layerId;
                unsigned int i;
                MapLayer *layer;
+               MapLayer *singleLayer = NULL;
+               MapLayer *singleTrackLayer = NULL;
+               int trackLayersCount = 0;
                for (i=0;i<theDocument->layerSize();i++) {
                        layer = theDocument->getLayer(i);
-                       if (layer->className() == "TrackMapLayer" || 
layer->className() == "DrawingMapLayer") {
+                       if (layer->className() == "TrackMapLayer")
+                       {
+                               trackLayersCount++;
+                               if (!singleTrackLayer)
+                               {
+                                       singleTrackLayer = layer;
+                               }
+                       }
+                       if (layer->className() == "TrackMapLayer" || 
layer->className() == "DrawingMapLayer")
+                       {
+                               if (!singleLayer)
+                               {
+                                       singleLayer = layer;
+                               }
                                layers.append(theDocument->getLayer(i)->name());
                                layerId.append(i);
                        }
@@ -120,13 +136,27 @@
                        return;
                }
 
-               bool ok;
-               QString name = QInputDialog::getItem(NULL, tr("Load geotagged 
Images"),
-                tr("Select the layer to which the images belong:"), layers, 0, 
false, &ok);
-               if (ok && !name.isEmpty())
-                       theLayer = 
theDocument->getLayer(layerId.at(layers.indexOf(name)));
+               // Select single layer if there is only one
+               if (layers.size() == 1)
+               {
+                       theLayer = singleLayer;
+               }
+               // Select single track layer if there is only one
+               else if (trackLayersCount == 1)
+               {
+                       theLayer = singleTrackLayer;
+               }
+               // Now ask the user what layer to add the photos to
                else
-                       return;
+               {
+                       bool ok;
+                       QString name = QInputDialog::getItem(NULL, tr("Load 
geotagged Images"),
+                        tr("Select the layer to which the images belong:"), 
layers, 0, false, &ok);
+                       if (ok && !name.isEmpty())
+                               theLayer = 
theDocument->getLayer(layerId.at(layers.indexOf(name)));
+                       else
+                               return;
+               }
        }
 
        activeLayers.append(theLayer);
_______________________________________________
Merkaartor mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/merkaartor

Reply via email to