More work on removing Selection class
authorinsilmaril
Thu, 22 Jan 2009 15:40:08 +0000
changeset 73753e51e8d47e7
parent 736 21f115d48daf
child 738 716a777c1c98
More work on removing Selection class
mapeditor.cpp
vymmodel.cpp
vymmodel.h
     1.1 --- a/mapeditor.cpp	Thu Jan 22 11:39:53 2009 +0000
     1.2 +++ b/mapeditor.cpp	Thu Jan 22 15:40:08 2009 +0000
     1.3 @@ -1081,7 +1081,6 @@
     1.4  		index=newsel.indexes().at(i);
     1.5  		ti= static_cast<TreeItem*>(index.internalPointer());
     1.6  		lmo=ti->getLMO();
     1.7 -	cout << "  ME::updateSelection of "<<((BranchObj*)lmo)->getHeading().toStdString()<<"\n";
     1.8  		bbox=lmo->getBBox();
     1.9  		sb->setRect (
    1.10  			bbox.x(),bbox.y(), 
     2.1 --- a/vymmodel.cpp	Thu Jan 22 11:39:53 2009 +0000
     2.2 +++ b/vymmodel.cpp	Thu Jan 22 15:40:08 2009 +0000
     2.3 @@ -1523,18 +1523,6 @@
     2.4  	}
     2.5  }
     2.6  
     2.7 -void VymModel::setHeadingInt(const QString &s)
     2.8 -{
     2.9 -	BranchObj *bo=getSelectedBranch();
    2.10 -	if (bo)
    2.11 -	{
    2.12 -		bo->setHeading(s);
    2.13 -		reposition();
    2.14 -		selection.update();
    2.15 -		ensureSelectionVisible();
    2.16 -	}
    2.17 -}
    2.18 -
    2.19  BranchObj* VymModel::findText (QString s, bool cs)
    2.20  {
    2.21  	QTextDocument::FindFlags flags=0;
    2.22 @@ -4451,7 +4439,7 @@
    2.23  		TreeItem *ti=lmo->getTreeItem();
    2.24  		QModelIndex ix=index(ti);
    2.25  		selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
    2.26 -		//updateSelection(oldsel);
    2.27 +		//updateSelection(oldsel);	//FIXME needed?
    2.28  		return true;
    2.29  	}
    2.30  	return false;
    2.31 @@ -4728,33 +4716,28 @@
    2.32  
    2.33  	QItemSelection oldsel=selModel->selection();
    2.34  
    2.35 -	BranchObj* bo;
    2.36  	BranchObj* par;
    2.37  	LinkableMapObj *sel=getSelectedBranch();
    2.38  	if (sel)
    2.39  	{
    2.40 -		if (selectionType()==TreeItem::MapCenter) 
    2.41 +		if (selectionType()== TreeItem::MapCenter)
    2.42  		{
    2.43 -			par=getSelectedBranch();
    2.44 -			bo=par->getLastSelectedBranch();
    2.45 -			if (bo)
    2.46 -			{
    2.47 -				// Workaround for reselecting on left and right side
    2.48 -				if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
    2.49 -					bo=par->getFirstBranch();
    2.50 -				if (bo)
    2.51 -				{
    2.52 -					selection.select(bo);
    2.53 -					//selection.update();
    2.54 -					//ensureSelectionVisible();
    2.55 -					//sendSelection();
    2.56 -				}
    2.57 -			}
    2.58 +			QModelIndex ix=getSelectedIndex();
    2.59 +			selModel->select (index (0,0,ix),QItemSelectionModel::ClearAndSelect  );
    2.60  		} else
    2.61  		{
    2.62 -			par=(BranchObj*)(getSelectedLMO()->getParObj());
    2.63 -			if (getSelectedLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
    2.64 +			par=(BranchObj*)(sel->getParObj());
    2.65 +			if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
    2.66  			{
    2.67 +				// right of center
    2.68 +				if (selectionType() == TreeItem::Branch )
    2.69 +				{
    2.70 +					selectLastSelectedBranch();
    2.71 +					return;
    2.72 +				}
    2.73 +			} else
    2.74 +			{
    2.75 +				// left of center
    2.76  				if (selectionType() == TreeItem::Branch ||
    2.77  					selectionType() == TreeItem::Image)
    2.78  				{
    2.79 @@ -4762,25 +4745,9 @@
    2.80  					ix=parent(ix);
    2.81  					selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
    2.82  				}
    2.83 -			} else
    2.84 -			{
    2.85 -				if (selectionType()  == TreeItem::Branch) 
    2.86 -				{
    2.87 -					bo=getSelectedBranch()->getLastSelectedBranch();
    2.88 -					if (bo) 
    2.89 -					{
    2.90 -						selection.select(bo);
    2.91 -						//selection.update();
    2.92 -						//ensureSelectionVisible();
    2.93 -						//sendSelection();
    2.94 -					}
    2.95 -				}
    2.96  			}
    2.97 -		}
    2.98 -		QItemSelection newsel=selModel->selection();
    2.99 -		emit (selectionChanged(newsel,oldsel));
   2.100 -		ensureSelectionVisible();
   2.101 -		sendSelection();
   2.102 +		}	
   2.103 +		updateSelection (oldsel);
   2.104  	}
   2.105  }
   2.106  
     3.1 --- a/vymmodel.h	Thu Jan 22 11:39:53 2009 +0000
     3.2 +++ b/vymmodel.h	Thu Jan 22 15:40:08 2009 +0000
     3.3 @@ -236,8 +236,6 @@
     3.4  public:	
     3.5  	void setHeading(const QString &);		//!< Set heading of branch	
     3.6  //	QString getHeading (bool &ok,QPoint &p); //!< Get heading, ok if selection is branch
     3.7 -private:
     3.8 -	void setHeadingInt(const QString &);
     3.9  
    3.10  private:
    3.11  	BranchObj* itFind;			// next object in find process