speedup
authorinsilmaril
Wed, 29 Apr 2009 21:40:37 +0000
changeset 7610301e6109702
parent 760 59614eaf5fbb
child 762 ffb95cd03156
speedup
mapcenteritem.cpp
mapeditor.cpp
version.h
vymmodel.cpp
vymmodel.h
vymview.cpp
vymview.h
xml-vym.cpp
     1.1 --- a/mapcenteritem.cpp	Wed Apr 29 18:46:31 2009 +0000
     1.2 +++ b/mapcenteritem.cpp	Wed Apr 29 21:40:37 2009 +0000
     1.3 @@ -122,7 +122,6 @@
     1.4  
     1.5  BranchObj* MapCenterItem::createMapObj(QGraphicsScene *scene)	
     1.6  {
     1.7 -	cout <<"MCI  parent->model="<<parent()->getModel()<<endl;
     1.8  	// Initialize MapCenterObj, order of things is important...
     1.9      MapCenterObj* mco=new MapCenterObj(scene);
    1.10  	lmo=mco;
     2.1 --- a/mapeditor.cpp	Wed Apr 29 18:46:31 2009 +0000
     2.2 +++ b/mapeditor.cpp	Wed Apr 29 21:40:37 2009 +0000
     2.3 @@ -910,7 +910,6 @@
     2.4  				// We have a destination, relink to that
     2.5  
     2.6  				BranchObj* bsel=model->getSelectedBranchObj();
     2.7 -				BranchObj* bdst=(BranchObj*)dst;
     2.8  
     2.9  				QString preParStr=model->getSelectString (bsel->getParObj());
    2.10  				QString preNum=QString::number (seli->num(),10);
     3.1 --- a/version.h	Wed Apr 29 18:46:31 2009 +0000
     3.2 +++ b/version.h	Wed Apr 29 21:40:37 2009 +0000
     3.3 @@ -7,7 +7,7 @@
     3.4  #define __VYM_VERSION "1.13.0"
     3.5  //#define __VYM_CODENAME "Codename: RC-1"
     3.6  #define __VYM_CODENAME "Codename: development version, not for production!"
     3.7 -#define __VYM_BUILD_DATE "2009-04-27"
     3.8 +#define __VYM_BUILD_DATE "2009-04-29"
     3.9  
    3.10  
    3.11  bool checkVersion(const QString &);
     4.1 --- a/vymmodel.cpp	Wed Apr 29 18:46:31 2009 +0000
     4.2 +++ b/vymmodel.cpp	Wed Apr 29 21:40:37 2009 +0000
     4.3 @@ -992,6 +992,7 @@
     4.4  	mapChanged=true;
     4.5  	mapDefault=false;
     4.6  	mapUnsaved=true;
     4.7 +	latestAddedItem=NULL;
     4.8  	findReset();
     4.9  }
    4.10  
    4.11 @@ -1401,28 +1402,33 @@
    4.12  	return mapScene;
    4.13  }
    4.14  
    4.15 -TreeItem* VymModel::findBySelectString(const QString &s)	//FIXME-0
    4.16 -{
    4.17 -	return NULL;
    4.18 -	if (!s.isEmpty() )
    4.19 +TreeItem* VymModel::findBySelectString(QString s)
    4.20 +{
    4.21 +	if (s.isEmpty() ) return NULL;
    4.22 +
    4.23 +	// Old maps don't have multiple mapcenters and don't save full path
    4.24 +	if (s.left(2) !="mc")
    4.25 +		s="mc:0,"+s;
    4.26 +
    4.27 +	QStringList parts=s.split (",");
    4.28 +	QString typ;
    4.29 +	int n;
    4.30 +	TreeItem *ti=rootItem;
    4.31 +
    4.32 +	while (!parts.isEmpty() )
    4.33  	{
    4.34 -		QString part;
    4.35 -		QString typ;
    4.36 -		QString num;
    4.37 -		part=s.section(",",0,0);
    4.38 -		typ=part.left (2);
    4.39 -		num=part.right(part.length() - 3);
    4.40 -		if (typ=="mc" && num.toInt()>=0 && num.toInt() <rootItem->branchCount() )
    4.41 -			return rootItem->getBranchNum (num.toInt() );
    4.42 -	}		
    4.43 -
    4.44 -	TreeItem *ti;
    4.45 -	for (int i=0; i<rootItem->branchCount(); i++)
    4.46 -	{
    4.47 -		// ti=rootItem->getBranchNum(i)->findBySelectString(s);
    4.48 -		if (ti) return ti;
    4.49 -	}	
    4.50 -	return NULL;
    4.51 +		typ=parts.first().left(2);
    4.52 +		n=parts.first().right(parts.first().length() - 3).toInt();
    4.53 +		parts.removeFirst();
    4.54 +		if (typ=="mc" || typ=="bo")
    4.55 +			ti=ti->getBranchNum (n);
    4.56 +			/* FIXME-2
    4.57 +		else
    4.58 +			if (typ="fi")
    4.59 +				ti=ti->getImageNum (n);
    4.60 +				*/
    4.61 +	}
    4.62 +	return  ti;
    4.63  }
    4.64  
    4.65  TreeItem* VymModel::findID (const QString &s)
    4.66 @@ -2044,7 +2050,7 @@
    4.67  
    4.68  MapCenterItem* VymModel::addMapCenter ()
    4.69  {
    4.70 -	MapCenterItem *mci=addMapCenter (contextPos);	//FIXME-2 get rid of MCO here
    4.71 +	MapCenterItem *mci=addMapCenter (contextPos);
    4.72  	//FIXME-3 selection.select (mco);
    4.73  	updateActions();
    4.74  	ensureSelectionVisible();
    4.75 @@ -2186,7 +2192,7 @@
    4.76  
    4.77  			reposition();
    4.78  			// selection.update(); FIXME-3
    4.79 -			latestSelectionString=getSelectString(newbi);
    4.80 +			latestAddedItem=newbi;
    4.81  			// In Network mode, the client needs to know where the new branch is,
    4.82  			// so we have to pass on this information via saveState.
    4.83  			// TODO: Get rid of this positioning workaround
    4.84 @@ -2268,7 +2274,6 @@
    4.85  
    4.86  void VymModel::deleteSelection()
    4.87  {
    4.88 -	BranchObj *bo = getSelectedBranchObj();	// FIXME-2 VM should not be necessary
    4.89  	BranchItem *selbi=getSelectedBranchItem();
    4.90  
    4.91  	if (!selbi) return;
    4.92 @@ -3351,13 +3356,13 @@
    4.93  	/////////////////////////////////////////////////////////////////////
    4.94  	} else */ if (com=="selectLatestAdded")
    4.95  	{
    4.96 -		if (latestSelectionString.isEmpty() )
    4.97 +		if (!latestAddedItem)
    4.98  		{
    4.99  			parser.setError (Aborted,"No latest added object");
   4.100  		} else
   4.101  		{	
   4.102 -			if (!select (latestSelectionString))
   4.103 -				parser.setError (Aborted,"Could not select latest added object "+latestSelectionString);
   4.104 +			if (!select (latestAddedItem))
   4.105 +				parser.setError (Aborted,"Could not select latest added object ");
   4.106  		}	
   4.107  	/////////////////////////////////////////////////////////////////////
   4.108  	} else if (com=="setFrameType")
   4.109 @@ -3882,10 +3887,6 @@
   4.110  void VymModel::registerEditor(QWidget *me)
   4.111  {
   4.112  	mapEditor=(MapEditor*)me;
   4.113 -	/* FIXME-3
   4.114 -	for (int i=0; i<rootItem->branchCount(); i++)
   4.115 -		rootItem->getBranchNum(i)->setMapEditor(mapEditor);
   4.116 -	*/
   4.117  }
   4.118  
   4.119  void VymModel::unregisterEditor(QWidget *)
   4.120 @@ -3924,9 +3925,11 @@
   4.121  		((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions();
   4.122  }
   4.123  
   4.124 -void VymModel::reposition()	//FIXME-2 VM should have no need to reposition, this is done in views???
   4.125 -{
   4.126 -	//cout << "VM::reposition ...\n";
   4.127 +void VymModel::reposition()	//FIXME-3 VM should have no need to reposition, this is done in views???
   4.128 +{
   4.129 +	//cout << "VM::reposition blocked="<<blockReposition<<endl;
   4.130 +	if (blockReposition) return;
   4.131 +
   4.132  	for (int i=0;i<rootItem->branchCount(); i++)
   4.133  		rootItem->getBranchObjNum(i)->reposition();	//	for positioning heading
   4.134  }
   4.135 @@ -4998,19 +5001,6 @@
   4.136  	return NULL;
   4.137  }
   4.138  
   4.139 -MapCenterItem* VymModel::getSelectedMapCenterItem()
   4.140 -{
   4.141 -	QModelIndexList list=selModel->selectedIndexes();
   4.142 -	if (!list.isEmpty() )
   4.143 -	{
   4.144 -		TreeItem *ti = getItem (list.first() );
   4.145 -		TreeItem::Type type=ti->getType();
   4.146 -		if (ti->getType()==TreeItem::MapCenter)
   4.147 -			return (MapCenterItem*)ti;
   4.148 -	}
   4.149 -	return NULL;
   4.150 -}
   4.151 -
   4.152  TreeItem* VymModel::getSelectedItem()
   4.153  {
   4.154  	QModelIndexList list=selModel->selectedIndexes();
     5.1 --- a/vymmodel.h	Wed Apr 29 18:46:31 2009 +0000
     5.2 +++ b/vymmodel.h	Wed Apr 29 21:40:37 2009 +0000
     5.3 @@ -220,7 +220,7 @@
     5.4  	void setScene(QGraphicsScene *s);
     5.5  	QGraphicsScene *getScene();
     5.6  
     5.7 -    TreeItem* findBySelectString (const QString &s);		
     5.8 +    TreeItem* findBySelectString (QString s);		
     5.9      TreeItem* findID (const QString &s);				// find MapObj by previously set ID
    5.10  
    5.11  
    5.12 @@ -531,7 +531,7 @@
    5.13  ////////////////////////////////////////////
    5.14  private:
    5.15  	Selection selection;
    5.16 -	QString latestSelectionString;	// select string of latest added object
    5.17 +	TreeItem *latestAddedItem;				// latest added object, reset on setChanged()
    5.18  
    5.19  signals:
    5.20  	void selectionChanged(const QItemSelection &, const QItemSelection &);
    5.21 @@ -574,7 +574,6 @@
    5.22  	LinkableMapObj* getSelectedLMO();
    5.23  	BranchObj* getSelectedBranchObj();	// FIXME-2 replace by item...
    5.24  	BranchItem* getSelectedBranchItem();
    5.25 -	MapCenterItem* getSelectedMapCenterItem();
    5.26  	TreeItem* getSelectedItem();
    5.27  	QModelIndex getSelectedIndex();
    5.28  	FloatImageObj* getSelectedFloatImage();
     6.1 --- a/vymview.cpp	Wed Apr 29 18:46:31 2009 +0000
     6.2 +++ b/vymview.cpp	Wed Apr 29 21:40:37 2009 +0000
     6.3 @@ -17,10 +17,7 @@
     6.4  	treeview=new QTreeView;
     6.5  	treeview->setModel ((QAbstractItemModel*)model);
     6.6  	//treeview->setMinimumWidth (50);
     6.7 -	QList <int> widths;
     6.8 -	widths<<30;
     6.9 -	widths<<150;
    6.10 -	setSizes(widths);
    6.11 +
    6.12  	treeview->setColumnWidth (0,350);
    6.13  
    6.14  	selModel=treeview->selectionModel();
    6.15 @@ -30,11 +27,11 @@
    6.16  		this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
    6.17  
    6.18  	// Create good old MapEditor
    6.19 -	MapEditor* me=model->getMapEditor();
    6.20 -	if (!me) me=new MapEditor (model);
    6.21 +	mapEditor=model->getMapEditor();
    6.22 +	if (!mapEditor) mapEditor=new MapEditor (model);
    6.23  	connect (
    6.24  		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    6.25 -		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    6.26 +		mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    6.27  		/*
    6.28  	connect (
    6.29  		selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)), 
    6.30 @@ -44,32 +41,36 @@
    6.31  */
    6.32  	connect (
    6.33  		model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)), 
    6.34 -		me,SLOT (updateData(const QModelIndex &) ) );
    6.35 +		mapEditor,SLOT (updateData(const QModelIndex &) ) );
    6.36  
    6.37  	// VymModel may want to update selection or other data, e.g. during animation
    6.38  	connect (
    6.39  		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    6.40 -		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    6.41 +		mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    6.42 +
    6.43 +		/*
    6.44  	connect (
    6.45  		model, SIGNAL (newChildObject(QModelIndex) ),
    6.46  		this,SLOT (updateChilds (QModelIndex) ) );
    6.47 +*/
    6.48 +
    6.49  	connect (
    6.50  		model, SIGNAL (noteHasChanged(QModelIndex) ),
    6.51  		mainWindow, SLOT (updateNoteEditor (QModelIndex) ) );
    6.52  		
    6.53  
    6.54 -	//me->viewport()->setFocus();	//FIXME-3 needed?
    6.55 -	me->setAntiAlias (mainWindow->isAliased());
    6.56 -	me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
    6.57 +	//mapEditor->viewport()->setFocus();	//FIXmapEditor-3 needed?
    6.58 +	mapEditor->setAntiAlias (mainWindow->isAliased());
    6.59 +	mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
    6.60  
    6.61  	addWidget (treeview);
    6.62 -	addWidget (me);
    6.63 +	addWidget (mapEditor);
    6.64  
    6.65  	// Set geometry
    6.66 -	QList <int> sizes;
    6.67 -	sizes.append (120);
    6.68 -	sizes.append (600);
    6.69 -	setSizes (sizes);
    6.70 +	QList <int> widths;
    6.71 +	widths<<120;
    6.72 +	widths<<600;
    6.73 +	setSizes(widths);
    6.74  }
    6.75  
    6.76  QItemSelectionModel* VymView::selectionModel() 
    6.77 @@ -82,9 +83,10 @@
    6.78  }
    6.79  
    6.80  
    6.81 -void VymView::updateChilds (QModelIndex ix)
    6.82 +void VymView::updateChilds (QModelIndex ix)		//FIXME-4 not needed?
    6.83  {
    6.84 -	treeview->setExpanded (ix,true);
    6.85 +	cout << "VV::updateChilds \n";
    6.86 +	//treeview->setExpanded (ix,true);	// This is expensive...
    6.87  }
    6.88  
    6.89  void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel)
     7.1 --- a/vymview.h	Wed Apr 29 18:46:31 2009 +0000
     7.2 +++ b/vymview.h	Wed Apr 29 21:40:37 2009 +0000
     7.3 @@ -6,6 +6,7 @@
     7.4  #include <QTreeView>
     7.5  
     7.6  class VymModel;
     7.7 +class MapEditor;
     7.8  
     7.9  
    7.10  class VymView : public QSplitter 
    7.11 @@ -23,6 +24,7 @@
    7.12  	VymModel *model;
    7.13  	QTreeView *treeview;
    7.14  	QItemSelectionModel *selModel;
    7.15 +	MapEditor *mapEditor;
    7.16  };
    7.17  
    7.18  
     8.1 --- a/xml-vym.cpp	Wed Apr 29 18:46:31 2009 +0000
     8.2 +++ b/xml-vym.cpp	Wed Apr 29 21:40:37 2009 +0000
     8.3 @@ -308,7 +308,7 @@
     8.4  
     8.5  bool parseVYMHandler::characters   ( const QString& ch)
     8.6  {
     8.7 -	//cout << "characters \""<<ch<<"\"  state="<<state <<"  laststate="<<laststate<<endl;
     8.8 +	//cout << "characters \""<<ch.toStdString()<<"\"  state="<<state <<"  laststate="<<laststate<<endl;
     8.9  
    8.10  	QString ch_org=quotemeta (ch);
    8.11      QString ch_simplified=ch.simplifyWhiteSpace();