vymmodel.cpp
changeset 748 edb78a44240b
parent 746 ee6b0f3a4c2f
child 749 9ff332964015
     1.1 --- a/vymmodel.cpp	Thu Mar 26 07:50:32 2009 +0000
     1.2 +++ b/vymmodel.cpp	Tue Mar 31 15:36:10 2009 +0000
     1.3 @@ -2227,31 +2227,43 @@
     1.4  	if (!ix.isValid() ) return;
     1.5  
     1.6  	QModelIndex parentIndex=parent(ix);
     1.7 -	if (!parentIndex.isValid()) return;
     1.8 +/*
     1.9 +	if (!parentIndex.isValid()) 
    1.10 +	{
    1.11 +	cout << "VM::delete no valid parent ix\n";
    1.12 +	return;
    1.13 +	}
    1.14 +*/	
    1.15  	TreeItem *ti=bo->getTreeItem();
    1.16  	
    1.17 -	if (selectionType()==TreeItem::MapCenter)		//FIXME-1 VM still missing
    1.18 +	if (selectionType()==TreeItem::MapCenter)	
    1.19  	{
    1.20  	//	BranchObj* par=(BranchObj*)(bo->getParObj());
    1.21  		//selection.unselect();
    1.22  		/* FIXME-1 VM Note:  does saveStateRemovingPart work for MCO? (No parent!)
    1.23  		saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
    1.24 -		*/
    1.25 -		/*
    1.26 +		*/	
    1.27 +		emit (layoutAboutToBeChanged() );
    1.28 +
    1.29 +		parentIndex=parent(index(ti));
    1.30 +		cout << "VM::delete  ti="<<ti<<"  row="<<ix.row()<<"  parIndex.valid="<<parentIndex.isValid()<<endl;
    1.31 +		int n=ix.row();
    1.32 +		beginRemoveRows (parentIndex,n,n);
    1.33 +		removeRows (n,1,parentIndex);
    1.34  		bo=removeMapCenter ((MapCenterObj*)bo);
    1.35 +		endRemoveRows();
    1.36  		if (bo) 
    1.37  		{
    1.38 -			selection.select (bo);
    1.39 +			select (bo);
    1.40  			ensureSelectionVisible();
    1.41 -			selection.update();
    1.42 +			ensureSelectionVisible();
    1.43 +			reposition();
    1.44  		}	
    1.45 -		reposition();
    1.46 -		return;
    1.47 -		*/
    1.48 +
    1.49 +		emit (layoutChanged() );
    1.50  	}
    1.51  	if (selectionType()==TreeItem::Branch)
    1.52  	{
    1.53 -		int n=ti->branchCount();
    1.54  
    1.55  		BranchObj* par=(BranchObj*)bo->getParObj();
    1.56  		unselect();
    1.57 @@ -2261,11 +2273,11 @@
    1.58  
    1.59  		cout << "VM::delete  ti="<<ti<<"  row="<<ix.row()<<endl;
    1.60  		parentIndex=parent(index(ti));
    1.61 -		cout << "            valid parentIndex="<<parentIndex.isValid()<<endl;
    1.62 +		int n=ix.row();
    1.63  		beginRemoveRows (parentIndex,n,n);
    1.64 -		removeRows (ix.row(),1,parentIndex);
    1.65 +		removeRows (n,1,parentIndex);
    1.66 +		par->removeBranch(bo);	// remove from BranchObj lists...
    1.67  		endRemoveRows();
    1.68 -		par->removeBranch(bo);
    1.69  		select (par);
    1.70  		ensureSelectionVisible();
    1.71  		reposition();
    1.72 @@ -2275,6 +2287,7 @@
    1.73  	}
    1.74  	FloatImageObj *fio=selection.getFloatImage(); 	//FIXME-1 VM still missing
    1.75  
    1.76 +/*
    1.77  	if (fio)
    1.78  	{
    1.79  		BranchObj* par=(BranchObj*)fio->getParObj();
    1.80 @@ -2291,6 +2304,7 @@
    1.81  		ensureSelectionVisible();
    1.82  		return;
    1.83  	}
    1.84 +	*/
    1.85  }
    1.86  
    1.87  void VymModel::deleteKeepChildren()		//FIXME-1 VM still missing