Fixed tmp relink, colored headings in TreeView
authorinsilmaril
Mon, 14 Jun 2010 13:59:17 +0000
changeset 848e265f07f2173
parent 847 43268373032d
child 849 988f1908a7c4
Fixed tmp relink, colored headings in TreeView
branchobj.cpp
mainwindow.cpp
mapeditor.cpp
treeitem.cpp
treeitem.h
treemodel.cpp
version.h
vym.changelog
vymmodel.cpp
vymmodel.h
     1.1 --- a/branchobj.cpp	Wed Jun 09 13:14:08 2010 +0000
     1.2 +++ b/branchobj.cpp	Mon Jun 14 13:59:17 2010 +0000
     1.3 @@ -108,7 +108,13 @@
     1.4  		qreal y;
     1.5  		if (off==0)
     1.6  		{
     1.7 +				// Below is needed e.g. in a freshly loaded map, 
     1.8 +				// bboxTotal seems not to be correct yet
     1.9 +				// relinking positions too far below then
    1.10 +				calcBBoxSizeWithChildren();	
    1.11 +
    1.12  			// new parent is just a branch, link to it
    1.13 +			bodst->calcBBoxSizeWithChildren();
    1.14  			QRectF t=bodst->getBBoxSizeWithChildren();
    1.15  			if (dsti->getLastBranch())
    1.16  				y=t.y() + t.height() ;
     2.1 --- a/mainwindow.cpp	Wed Jun 09 13:14:08 2010 +0000
     2.2 +++ b/mainwindow.cpp	Mon Jun 14 13:59:17 2010 +0000
     2.3 @@ -1984,7 +1984,7 @@
     2.4  	vv->initFocus();
     2.5  
     2.6  	// Create MapCenter for empty map
     2.7 -	vm->addMapCenter();
     2.8 +	vm->addMapCenter(false);
     2.9  	vm->makeDefault();
    2.10  
    2.11  	// For the very first map we do not have flagrows yet...
     3.1 --- a/mapeditor.cpp	Wed Jun 09 13:14:08 2010 +0000
     3.2 +++ b/mapeditor.cpp	Mon Jun 14 13:59:17 2010 +0000
     3.3 @@ -1149,10 +1149,10 @@
     3.4  				if (bi)
     3.5  				{
     3.6  					copyingObj=true;
     3.7 -					//FIXME-2   TreeItem::addBranch (BranchItem still missing) 
     3.8 -					//bi->addBranch (model->getSelectedBranch());
     3.9 -					model->unselect();
    3.10 -					model->select(bi->getLastBranch());
    3.11 +					//model->select(model->createBranch (bi));
    3.12 +					model->copy();
    3.13 +					model->paste();
    3.14 +					model->select (bi->getLastBranch());
    3.15  					model->reposition();
    3.16  				}
    3.17  			} 
    3.18 @@ -1200,10 +1200,11 @@
    3.19  		if (mainWindow->getModMode()!=Main::ModModeCopy)
    3.20  			setCursor (Qt::ArrowCursor);
    3.21  
    3.22 -		// Scroll if needed
    3.23 -		// To avoid jumping of the sceneView, only 
    3.24 -		// show selection, if not tmp linked
    3.25 -		model->emitShowSelection();
    3.26 +		if (!lmosel->hasParObjTmp())
    3.27 +			// Scroll if needed
    3.28 +			// To avoid jumping of the sceneView, only 
    3.29 +			// show selection, if not tmp linked
    3.30 +			model->emitShowSelection();
    3.31  		
    3.32  		// Now move the selection, but add relative position 
    3.33  		// (movingObj_start) where selection was chosen with 
    3.34 @@ -1292,27 +1293,30 @@
    3.35  				} 
    3.36  
    3.37  			} // depth>0
    3.38 -				// Maybe we can relink temporary?
    3.39 -				if (dsti)
    3.40 +
    3.41 +			// Maybe we can relink temporary?
    3.42 +			if (dsti)
    3.43 +			{
    3.44 +				if (e->modifiers()==Qt::ControlModifier)
    3.45  				{
    3.46 -					if (e->modifiers()==Qt::ControlModifier)
    3.47 -					{
    3.48 -						// Special case: CTRL to link below dst
    3.49 -						lmosel->setParObjTmp (dst,p,+1);
    3.50 -					} else if (e->modifiers()==Qt::ShiftModifier)
    3.51 -						lmosel->setParObjTmp (dst,p,-1);
    3.52 -					else
    3.53 -						lmosel->setParObjTmp (dst,p,0);
    3.54 -				} else	
    3.55 -				{
    3.56 -					lmosel->unsetParObjTmp();
    3.57 -				}		
    3.58 -				// reposition subbranch
    3.59 -				lmosel->reposition();	
    3.60 +					// Special case: CTRL to link below dst
    3.61 +					lmosel->setParObjTmp (dst,p,+1);
    3.62 +				} else if (e->modifiers()==Qt::ShiftModifier)
    3.63 +					lmosel->setParObjTmp (dst,p,-1);
    3.64 +				else
    3.65 +					lmosel->setParObjTmp (dst,p,0);
    3.66 +			} else	
    3.67 +			{
    3.68 +				lmosel->unsetParObjTmp();
    3.69 +			}		
    3.70 +			// reposition subbranch
    3.71 +			lmosel->reposition();
    3.72  
    3.73  			QItemSelection sel=model->getSelectionModel()->selection();
    3.74  			updateSelection(sel,sel);	// position has changed
    3.75  
    3.76 +			scrollTo (model->index (seli->parent()));
    3.77 +
    3.78  		} // no FloatImageObj
    3.79  
    3.80  		scene()->update();
    3.81 @@ -1379,13 +1383,11 @@
    3.82  			tmpLink->setEndBranch ( ((BranchItem*)dsti) );
    3.83  			tmpLink->updateLink();
    3.84  			model->createLink (tmpLink);
    3.85 -			/* FIXME-2 Link savestate missing, segfaulting on undo
    3.86 -			model->saveState(
    3.87 -				tmpXLink,QString("delete ()"),
    3.88 -				dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpXLink->getBegin())).arg(model->getSelectString(dsti)),
    3.89 -				QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpXLink->getBegin())).arg(model->getObjectName(dsti)) 
    3.90 +			model->saveState(	//FIXME-2 wrong order of paramters
    3.91 +				dsti,QString("addXLink (\"%1\",\"%2\")").arg(model->getSelectString(tmpLink->getBeginLinkItem())).arg(model->getSelectString(dsti)),
    3.92 +				dsti,QString("Add xLink from %1 to %2").arg(model->getObjectName(tmpLink->getBeginLinkItem())).arg(model->getObjectName(dsti)) ,
    3.93 +				QString("Adding XLink()")
    3.94  			);	
    3.95 -			*/
    3.96  		} else
    3.97  		{
    3.98  			delete (tmpLink);
    3.99 @@ -1576,7 +1578,7 @@
   3.100  
   3.101  void MapEditor::wheelEvent(QWheelEvent* e)
   3.102  {
   3.103 -	//qDebug ()<<"ME::wheelEvent";	//FIXME-2 stop all animations in vymModel here
   3.104 +	//qDebug ()<<"ME::wheelEvent";	//FIXME-3 stop all animations in vymModel here
   3.105  	//model->stopAllAnimation();
   3.106  	QGraphicsView::wheelEvent (e);
   3.107  }
     4.1 --- a/treeitem.cpp	Wed Jun 09 13:14:08 2010 +0000
     4.2 +++ b/treeitem.cpp	Mon Jun 14 13:59:17 2010 +0000
     4.3 @@ -586,6 +586,22 @@
     4.4  		return NULL;
     4.5  }
     4.6  
     4.7 +ImageItem* TreeItem::getFirstImage()
     4.8 +{
     4.9 +	if (imageCounter>0)
    4.10 +		return getImageNum (imageCounter-1);
    4.11 +	else
    4.12 +		return NULL;
    4.13 +}
    4.14 +
    4.15 +ImageItem* TreeItem::getLastImage()
    4.16 +{
    4.17 +	if (imageCounter>0)
    4.18 +		return getImageNum (imageCounter-1);
    4.19 +	else
    4.20 +		return NULL;
    4.21 +}
    4.22 +
    4.23  BranchItem* TreeItem::getNextBranch(BranchItem *currentBranch)
    4.24  {
    4.25  	if (!currentBranch) return NULL;
     5.1 --- a/treeitem.h	Wed Jun 09 13:14:08 2010 +0000
     5.2 +++ b/treeitem.h	Mon Jun 14 13:59:17 2010 +0000
     5.3 @@ -15,6 +15,7 @@
     5.4  class FloatImageObj;
     5.5  class ImageItem;
     5.6  class LinkableMapObj;
     5.7 +class QModelIndex;
     5.8  class VymModel;
     5.9  class XLinkItem;
    5.10  class XLinkObj;
    5.11 @@ -70,7 +71,7 @@
    5.12  	virtual QString getTypeName ();
    5.13  
    5.14  // Accessing data
    5.15 -    virtual QVariant data(int column) const;
    5.16 +    virtual QVariant data (int column) const;
    5.17  
    5.18  
    5.19  protected:
    5.20 @@ -145,6 +146,8 @@
    5.21  	virtual TreeItem* getChildNum(const int &n);
    5.22  	virtual BranchItem* getFirstBranch();
    5.23  	virtual BranchItem* getLastBranch();
    5.24 +	virtual ImageItem* getFirstImage();
    5.25 +	virtual ImageItem* getLastImage();
    5.26  
    5.27  	/*! Get next branch after current branch. Return NULL if there is no
    5.28  	    next branch */
     6.1 --- a/treemodel.cpp	Wed Jun 09 13:14:08 2010 +0000
     6.2 +++ b/treemodel.cpp	Mon Jun 14 13:59:17 2010 +0000
     6.3 @@ -26,10 +26,15 @@
     6.4      if (!index.isValid())
     6.5          return QVariant();
     6.6  
     6.7 +    TreeItem *item = getItem (index);
     6.8 +
     6.9      if (role != Qt::DisplayRole)
    6.10 -        return QVariant();
    6.11 +	{
    6.12 +		if (role == Qt::ForegroundRole ) 
    6.13 +			return item->getHeadingColor();
    6.14 +		return QVariant();
    6.15 +	}	
    6.16  
    6.17 -    TreeItem *item = getItem (index);
    6.18  
    6.19      return item->data(index.column());
    6.20  }
     7.1 --- a/version.h	Wed Jun 09 13:14:08 2010 +0000
     7.2 +++ b/version.h	Mon Jun 14 13:59:17 2010 +0000
     7.3 @@ -4,10 +4,10 @@
     7.4  #include <QString>
     7.5  
     7.6  #define __VYM_NAME "VYM"
     7.7 -#define __VYM_VERSION "1.13.4"
     7.8 +#define __VYM_VERSION "1.13.5"
     7.9  //#define __VYM_CODENAME "Codename: RC-1"
    7.10  #define __VYM_CODENAME "Codename: development version, not for production!"
    7.11 -#define __VYM_BUILD_DATE "2010-06-08"
    7.12 +#define __VYM_BUILD_DATE "2010-06-14"
    7.13  
    7.14  
    7.15  bool checkVersion(const QString &);
     8.1 --- a/vym.changelog	Wed Jun 09 13:14:08 2010 +0000
     8.2 +++ b/vym.changelog	Mon Jun 14 13:59:17 2010 +0000
     8.3 @@ -1,3 +1,15 @@
     8.4 +-------------------------------------------------------------------
     8.5 +Mon Jun 14 15:11:46 CEST 2010 - vym@insilmaril.de
     8.6 +
     8.7 +- Version: 1.13.5   
     8.8 +- Bugfix: Temporary Relinking shows correct position again now
     8.9 +- Featzre: TreeEditor has colored headings
    8.10 +
    8.11 +-------------------------------------------------------------------
    8.12 +Thu Jun 10 11:18:32 CEST 2010 - vym@insilmaril.de
    8.13 +
    8.14 +- Bugfix: Segfault due to undo in new map
    8.15 +
    8.16  -------------------------------------------------------------------
    8.17  Tue Jun  8 17:17:41 CEST 2010 - vym@insilmaril.de
    8.18  
     9.1 --- a/vymmodel.cpp	Wed Jun 09 13:14:08 2010 +0000
     9.2 +++ b/vymmodel.cpp	Mon Jun 14 13:59:17 2010 +0000
     9.3 @@ -85,20 +85,14 @@
     9.4  	// Also no scene yet (should not be needed anyway)  FIXME-3 VM
     9.5  	mapScene=NULL;
     9.6  
     9.7 -	// History 
     9.8 +	// States and IDs
     9.9  	idLast++;
    9.10  	mapID=idLast;
    9.11      mapChanged=false;
    9.12  	mapDefault=true;
    9.13  	mapUnsaved=false;
    9.14  
    9.15 -	curStep=0;
    9.16 -	redosAvail=0;
    9.17 -	undosAvail=0;
    9.18 -
    9.19 - 	stepsTotal=settings.readNumEntry("/history/stepsTotal",100);
    9.20 -	undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
    9.21 -	mainWindow->updateHistory (undoSet);
    9.22 +	resetHistory();
    9.23  
    9.24  	// Create tmp dirs
    9.25  	makeTmpDirectories();
    9.26 @@ -516,6 +510,8 @@
    9.27  
    9.28  				// Reset timestamp to check for later updates of file
    9.29  				fileChangedTime=QFileInfo (destPath).lastModified();
    9.30 +
    9.31 +				resetHistory();
    9.32  			}
    9.33  
    9.34  	
    9.35 @@ -1062,7 +1058,7 @@
    9.36  		return false;
    9.37  }
    9.38  
    9.39 -void VymModel::undo()	//FIXME-1 segfault when trying to undo in a brandnew map
    9.40 +void VymModel::undo()	
    9.41  {
    9.42  	// Can we undo at all?
    9.43  	if (undosAvail<1) return;
    9.44 @@ -1180,6 +1176,17 @@
    9.45  	return (tmpMapDir+"/"+histName);
    9.46  }
    9.47  
    9.48 +void VymModel::resetHistory()
    9.49 +{
    9.50 +	curStep=0;
    9.51 +	redosAvail=0;
    9.52 +	undosAvail=0;
    9.53 +
    9.54 + 	stepsTotal=settings.readNumEntry("/history/stepsTotal",100);
    9.55 +	undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
    9.56 +	mainWindow->updateHistory (undoSet);
    9.57 +}
    9.58 +
    9.59  void VymModel::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, TreeItem *saveSel)
    9.60  {
    9.61  	sendData(redoCom);	//FIXME-3 testing
    9.62 @@ -1732,9 +1739,9 @@
    9.63  			QString ("setURL (\"%1\")").arg(url),
    9.64  			QString ("set URL of %1 to %2").arg(getObjectName(selti)).arg(url)
    9.65  		);
    9.66 +		emitDataHasChanged (selti);
    9.67  		reposition();
    9.68 -		emitDataHasChanged (selti);
    9.69 -		emitShowSelection();
    9.70 +		emitSelectionChanged();
    9.71  	}
    9.72  }	
    9.73  
    9.74 @@ -2274,12 +2281,12 @@
    9.75  	return NULL;
    9.76  }
    9.77  
    9.78 -BranchItem* VymModel::addMapCenter ()
    9.79 +BranchItem* VymModel::addMapCenter (bool saveStateFlag)
    9.80  {
    9.81  	BranchItem *bi=addMapCenter (contextPos);
    9.82  	updateActions();
    9.83  	emitShowSelection();
    9.84 -	saveState (
    9.85 +	if (saveStateFlag) saveState (
    9.86  		bi,
    9.87  		"delete()",
    9.88  		NULL,
    9.89 @@ -3279,9 +3286,8 @@
    9.90  		} else
    9.91  			parser.setError (Aborted,"Wrong number of parameters");
    9.92  	/////////////////////////////////////////////////////////////////////
    9.93 -	} else if (com==QString("addXLink"))  //FIXME-2 not ported yet to Link
    9.94 -	{
    9.95 -	/*
    9.96 +	} else if (com==QString("addXLink")) 
    9.97 +	{
    9.98  		if (parser.parCount()>1)
    9.99  		{
   9.100  			s=parser.parString (ok,0);	// begin
   9.101 @@ -3292,13 +3298,11 @@
   9.102  			{
   9.103  				if (begin->isBranchLikeType() && end->isBranchLikeType())
   9.104  				{
   9.105 -					XLinkItem *xl=createXLink (begin,true);
   9.106 -					if (xl)
   9.107 -					{
   9.108 -						xl->setEnd (end);
   9.109 -						xl->activate();
   9.110 -					} else
   9.111 -						parser.setError (Aborted,"Failed to create xLink");
   9.112 +					Link *li=new Link (this);
   9.113 +					li->setBeginBranch ( (BranchItem*)begin );
   9.114 +					li->setEndBranch ( (BranchItem*)end);
   9.115 +
   9.116 +					createLink (li,true);	// create MO by default
   9.117  				}
   9.118  				else
   9.119  					parser.setError (Aborted,"begin or end of xLink are not branch or mapcenter");
   9.120 @@ -3307,7 +3311,6 @@
   9.121  				parser.setError (Aborted,"Couldn't select begin or end of xLink");
   9.122  		} else
   9.123  			parser.setError (Aborted,"Need at least 2 parameters for begin and end");
   9.124 -	*/		
   9.125  	/////////////////////////////////////////////////////////////////////
   9.126  	} else if (com=="clearFlags")	
   9.127  	{
   9.128 @@ -3319,7 +3322,11 @@
   9.129  			parser.setError (Aborted,"Type of selection is not a branch");
   9.130  		} else if (parser.checkParCount(0))
   9.131  		{
   9.132 -			selbi->deactivateAllStandardFlags();	//FIXME-2 this probably should emitDataChanged and also setChanged. Similar all other direct changes should be done...
   9.133 +			selbi->deactivateAllStandardFlags();
   9.134 +			reposition();
   9.135 +			emitDataHasChanged(selbi);
   9.136 +			emitSelectionChanged();
   9.137 +			setChanged();
   9.138  		}
   9.139  	/////////////////////////////////////////////////////////////////////
   9.140  	} else if (com=="colorBranch")
   9.141 @@ -5156,6 +5163,21 @@
   9.142  	return false;
   9.143  }
   9.144  
   9.145 +bool VymModel::selectLastImage()	
   9.146 +{
   9.147 +	TreeItem *ti=getSelectedBranch();
   9.148 +	if (ti)
   9.149 +	{
   9.150 +		TreeItem *par=ti->parent();
   9.151 +		if (par) 
   9.152 +		{
   9.153 +			TreeItem *ti2=par->getLastImage();
   9.154 +			if (ti2) return select(ti2);
   9.155 +		}
   9.156 +	}		
   9.157 +	return false;
   9.158 +}
   9.159 +
   9.160  bool VymModel::selectParent()
   9.161  {
   9.162  	TreeItem *ti=getSelectedItem();
    10.1 --- a/vymmodel.h	Wed Jun 09 13:14:08 2010 +0000
    10.2 +++ b/vymmodel.h	Mon Jun 14 13:59:17 2010 +0000
    10.3 @@ -179,6 +179,7 @@
    10.4  
    10.5  
    10.6  	QString getHistoryPath();			//!< Path to directory containing the history
    10.7 +	void resetHistory();				//!< Initialize history
    10.8  
    10.9  	/*! \brief Save the current changes in map 
   10.10  
   10.11 @@ -335,7 +336,7 @@
   10.12  
   10.13  	    Disclaimer: Still experimental, not fully supported yet.
   10.14  	*/	
   10.15 -	BranchItem* addMapCenter();
   10.16 +	BranchItem* addMapCenter(bool saveStateFlag=true);
   10.17  private:	
   10.18  	BranchItem* addMapCenter(QPointF absPos);
   10.19  
   10.20 @@ -628,6 +629,7 @@
   10.21      bool selectFirstBranch();
   10.22      bool selectLastBranch();
   10.23  	bool selectLastSelectedBranch();
   10.24 +    bool selectLastImage();
   10.25  	bool selectParent();
   10.26  
   10.27  public: