Skip to content
Permalink
Browse files
stop editing if the current layer changes
git-svn-id: http://svn.osgeo.org/qgis/trunk@5426 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 8, 2006
1 parent 9fea53c commit 6a771b3d3ebdd98c6cd26636e97e569d24fbad6e
Showing with 61 additions and 15 deletions.
  1. +1 −1 src/gui/qgisapp.cpp
  2. +1 −0 src/gui/qgsmaplayer.cpp
  3. +18 −7 src/legend/qgslegend.cpp
  4. +3 −0 src/legend/qgslegend.h
  5. +38 −7 src/providers/ogr/qgsogrprovider.cpp
@@ -4818,6 +4818,7 @@ bool QgisApp::addRasterLayer(QgsRasterLayer * theRasterLayer, bool theForceRedra
{
// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer(theRasterLayer);
theRasterLayer->refreshLegend();
// XXX doesn't the mMapCanvas->addLayer() do this?
// XXX now it does
// QObject::connect(theRasterLayer,
@@ -5070,7 +5071,6 @@ bool QgisApp::addRasterLayer(QStringList const &theFileNameQStringList, bool gui
layer->setVisible(mAddedLayersVisible);

addRasterLayer(layer);
layer->refreshLegend();

//only allow one copy of a ai grid file to be loaded at a
//time to prevent the user selecting all adfs in 1 dir which
@@ -66,6 +66,7 @@ QgsMapLayer::QgsMapLayer(int type,

// Set the display name = internal name
layerName = internalName;

QgsDebugMsg("QgsMapLayer::QgsMapLayer - layerName is '" + layerName);

// Generate the unique ID of this layer
@@ -54,7 +54,7 @@ const int AUTOSCROLL_MARGIN = 16;
set mItemBeingMoved pointer to 0 to prevent SuSE 9.0 crash
*/
QgsLegend::QgsLegend(QgisApp* app, QWidget * parent, const char *name)
: QTreeWidget(parent), mApp(app), mMousePressedFlag(false), mItemBeingMoved(0), mMapCanvas(0), mShowLegendLayerFiles(false), mMinimumIconSize(20, 20)
: QTreeWidget(parent), mApp(app), mMousePressedFlag(false), mItemBeingMoved(0), mMapCanvas(0), mShowLegendLayerFiles(false), mMinimumIconSize(20, 20), mCurrentLayer(0)
{
connect( this, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
this, SLOT(handleItemChange(QTreeWidgetItem*, int)));
@@ -87,13 +87,23 @@ QgsLegend::~QgsLegend()
void QgsLegend::handleCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous)
{
QgsMapLayer *layer = currentLayer();
if(mApp)
if(layer != mCurrentLayer)
{
mApp->activateDeactivateLayerRelatedActions( layer );
}
if(mMapCanvas)
{
mMapCanvas->setCurrentLayer( layer );
if(mApp)
{
mApp->activateDeactivateLayerRelatedActions( layer );
}
if(mMapCanvas)
{
mMapCanvas->setCurrentLayer( layer );
}
//stop editing for the old layer
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(mCurrentLayer);
if(vlayer && vlayer->isEditable())
{
vlayer->stopEditing();
}
mCurrentLayer = layer;
}
emit currentLayerChanged ( layer );
}
@@ -1368,6 +1378,7 @@ void QgsLegend::changeSymbologySettings(const QString& key, const std::list< std
//restore the current item again
setCurrentItem(theCurrentItem);
adjustIconSize();
setExpanded(indexFromItem(theLegendLayer), true);//make sure the symbology items are visible
}

void QgsLegend::addPixmapWidthValue(int width)
@@ -365,6 +365,9 @@ this item may be moved back to the original position with resetToInitialPosition
/**QgsLegend does not set the icon with/height to values lower than the minimum icon size*/
QSize mMinimumIconSize;

/**Stores a pointer to the current map layer. This is used to check when the current layer changes*/
QgsMapLayer* mCurrentLayer;

signals:
void zOrderChanged(QgsLegend * lv);

@@ -817,14 +817,20 @@ bool QgsOgrProvider::addFeature(QgsFeature* f)
OGRFeatureDefn* fdef=ogrLayer->GetLayerDefn();
OGRFeature* feature=new OGRFeature(fdef);
QGis::WKBTYPE ftype;
OGRErr err;
memcpy(&ftype, (f->getGeometry()+1), sizeof(int));
switch(ftype)
{
case QGis::WKBPoint:
{
OGRPoint* p=new OGRPoint();
p->importFromWkb(f->getGeometry(),1+sizeof(int)+2*sizeof(double));
OGRErr err = feature->SetGeometry(p);
err = feature->SetGeometry(p);
if(err != OGRERR_NONE)
{
delete p;
return false;
}
break;
}
case QGis::WKBLineString:
@@ -833,7 +839,12 @@ bool QgsOgrProvider::addFeature(QgsFeature* f)
int length;
memcpy(&length,f->getGeometry()+1+sizeof(int),sizeof(int));
l->importFromWkb(f->getGeometry(),1+2*sizeof(int)+2*length*sizeof(double));
feature->SetGeometry(l);
err = feature->SetGeometry(l);
if(err != OGRERR_NONE)
{
delete l;
return false;
}
break;
}
case QGis::WKBPolygon:
@@ -853,7 +864,12 @@ bool QgsOgrProvider::addFeature(QgsFeature* f)
ptr+=(2*sizeof(double));
}
pol->importFromWkb(f->getGeometry(),1+2*sizeof(int)+numrings*sizeof(int)+totalnumpoints*2*sizeof(double));
feature->SetGeometry(pol);
err = feature->SetGeometry(pol);
if(err != OGRERR_NONE)
{
delete pol;
return false;
}
break;
}
case QGis::WKBMultiPoint:
@@ -863,7 +879,12 @@ bool QgsOgrProvider::addFeature(QgsFeature* f)
//determine how many points
memcpy(&count,f->getGeometry()+1+sizeof(int),sizeof(int));
multip->importFromWkb(f->getGeometry(),1+2*sizeof(int)+count*2*sizeof(double));
feature->SetGeometry(multip);
err = feature->SetGeometry(multip);
if(err != OGRERR_NONE)
{
delete multip;
return false;
}
break;
}
case QGis::WKBMultiLineString:
@@ -886,7 +907,12 @@ bool QgsOgrProvider::addFeature(QgsFeature* f)
}
int size=1+2*sizeof(int)+numlines*sizeof(int)+totalpoints*2*sizeof(double);
multil->importFromWkb(f->getGeometry(),size);
feature->SetGeometry(multil);
err = feature->SetGeometry(multil);
if(err != OGRERR_NONE)
{
delete multil;
return false;
}
break;
}
case QGis::WKBMultiPolygon:
@@ -917,7 +943,12 @@ bool QgsOgrProvider::addFeature(QgsFeature* f)
}
int size=1+2*sizeof(int)+numpolys*sizeof(int)+totalrings*sizeof(int)+totalpoints*2*sizeof(double);
multipol->importFromWkb(f->getGeometry(),size);
feature->SetGeometry(multipol);
err = feature->SetGeometry(multipol);
if(err != OGRERR_NONE)
{
delete multipol;
return false;
}
break;
}
}
@@ -953,7 +984,7 @@ bool QgsOgrProvider::addFeature(QgsFeature* f)
returnValue = false;
}
++numberFeatures;
delete feature;
//delete feature;
ogrLayer->SyncToDisk();
return returnValue;
}

0 comments on commit 6a771b3

Please sign in to comment.