1.6.1 optimized moving of branches, basic linking functions
authorinsilmaril
Sun Jan 30 23:25:47 2005 +0000 (2005-01-30)
changeset 83e90f5bef70c8
parent 82 920e6ed5889b
child 84 0f2271678dea
1.6.1 optimized moving of branches, basic linking functions
Makefile
branchobj.cpp
branchobj.h
demos/todo.vym
linkablemapobj.cpp
mapcenterobj.cpp
mapcenterobj.h
mapeditor.cpp
mapeditor.h
version.h
vym.pro
xml.cpp
     1.1 --- a/Makefile	Sun Jan 30 12:59:10 2005 +0000
     1.2 +++ b/Makefile	Sun Jan 30 23:25:47 2005 +0000
     1.3 @@ -1,6 +1,6 @@
     1.4  #############################################################################
     1.5  # Makefile for building: vym
     1.6 -# Generated by qmake (1.07a) (Qt 3.3.1) on: Tue Jan  4 10:40:21 2005
     1.7 +# Generated by qmake (1.07a) (Qt 3.3.1) on: Mon Jan 31 00:05:28 2005
     1.8  # Project:  vym.pro
     1.9  # Template: app
    1.10  # Command: $(QMAKE) -o Makefile vym.pro
    1.11 @@ -12,14 +12,14 @@
    1.12  CXX      = g++
    1.13  LEX      = flex
    1.14  YACC     = yacc
    1.15 -CFLAGS   = -pipe -O2 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -fmessage-length=0 -Wall -fPIC  -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT
    1.16 -CXXFLAGS = -pipe -O2 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -fmessage-length=0 -Wall -fPIC  -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT
    1.17 +CFLAGS   = -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC  -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT
    1.18 +CXXFLAGS = -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC -Wall -W -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC  -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT
    1.19  LEXFLAGS = 
    1.20  YACCFLAGS= -d
    1.21  INCPATH  = -I/usr/lib/qt3/mkspecs/linux-g++ -I. -I/usr/include -I$(QTDIR)/include
    1.22  LINK     = g++
    1.23  LFLAGS   = 
    1.24 -LIBS     = $(SUBLIBS) -L/usr/lib64/ -L$(QTDIR)/lib64/ -L/usr/X11R6/lib64/ -lqt-mt -lXext -lX11 -lm
    1.25 +LIBS     = $(SUBLIBS) -L/usr/lib/ -L$(QTDIR)/lib/ -L/usr/X11R6/lib/ -lqt-mt -lXext -lX11 -lm
    1.26  AR       = ar cqs
    1.27  RANLIB   = 
    1.28  MOC      = $(QTDIR)/bin/moc
    1.29 @@ -56,6 +56,7 @@
    1.30  		headingobj.h \
    1.31  		imageobj.h \
    1.32  		linkablemapobj.h \
    1.33 +		linkobj.h \
    1.34  		mainwindow.h \
    1.35  		mapcenterobj.h \
    1.36  		mapeditor.h \
    1.37 @@ -81,6 +82,7 @@
    1.38  		headingobj.cpp \
    1.39  		imageobj.cpp \
    1.40  		linkablemapobj.cpp \
    1.41 +		linkobj.cpp \
    1.42  		main.cpp \
    1.43  		mainwindow.cpp \
    1.44  		mapcenterobj.cpp \
    1.45 @@ -106,6 +108,7 @@
    1.46  		headingobj.o \
    1.47  		imageobj.o \
    1.48  		linkablemapobj.o \
    1.49 +		linkobj.o \
    1.50  		main.o \
    1.51  		mainwindow.o \
    1.52  		mapcenterobj.o \
    1.53 @@ -196,7 +199,7 @@
    1.54  $(MOC): 
    1.55  	( cd $(QTDIR)/src/moc && $(MAKE) )
    1.56  
    1.57 -Makefile: vym.pro  /usr/lib/qt3/mkspecs/linux-g++/qmake.conf /usr/lib/qt3/lib64/libqt-mt.prl
    1.58 +Makefile: vym.pro  /usr/lib/qt3/mkspecs/linux-g++/qmake.conf /usr/lib/qt3/lib/libqt-mt.prl
    1.59  	$(QMAKE) -o Makefile vym.pro
    1.60  qmake: 
    1.61  	@$(QMAKE) -o Makefile vym.pro
    1.62 @@ -235,6 +238,7 @@
    1.63  		floatimageobj.h \
    1.64  		linkablemapobj.h \
    1.65  		ornamentedobj.h \
    1.66 +		linkobj.h \
    1.67  		floatobj.h \
    1.68  		frameobj.h \
    1.69  		noteobj.h \
    1.70 @@ -253,6 +257,7 @@
    1.71  		linkablemapobj.h \
    1.72  		mapcenterobj.h \
    1.73  		branchobj.h \
    1.74 +		linkobj.h \
    1.75  		version.h \
    1.76  		floatimageobj.h \
    1.77  		ornamentedobj.h \
    1.78 @@ -291,7 +296,8 @@
    1.79  		misc.h \
    1.80  		flagobj.h \
    1.81  		imageobj.h \
    1.82 -		ornamentedobj.h
    1.83 +		ornamentedobj.h \
    1.84 +		linkobj.h
    1.85  
    1.86  floatobj.o: floatobj.cpp floatobj.h \
    1.87  		linkablemapobj.h \
    1.88 @@ -330,9 +336,25 @@
    1.89  		imageobj.h \
    1.90  		floatimageobj.h \
    1.91  		ornamentedobj.h \
    1.92 +		linkobj.h \
    1.93  		floatobj.h \
    1.94  		mapcenterobj.h
    1.95  
    1.96 +linkobj.o: linkobj.cpp linkobj.h \
    1.97 +		branchobj.h \
    1.98 +		linkablemapobj.h \
    1.99 +		frameobj.h \
   1.100 +		noteobj.h \
   1.101 +		headingobj.h \
   1.102 +		flagrowobj.h \
   1.103 +		mapobj.h \
   1.104 +		misc.h \
   1.105 +		flagobj.h \
   1.106 +		imageobj.h \
   1.107 +		floatimageobj.h \
   1.108 +		ornamentedobj.h \
   1.109 +		floatobj.h
   1.110 +
   1.111  main.o: main.cpp settings.h \
   1.112  		options.h \
   1.113  		mainwindow.h \
   1.114 @@ -346,6 +368,7 @@
   1.115  		findwindow.h \
   1.116  		mapcenterobj.h \
   1.117  		branchobj.h \
   1.118 +		linkobj.h \
   1.119  		version.h \
   1.120  		floatimageobj.h \
   1.121  		linkablemapobj.h \
   1.122 @@ -394,6 +417,7 @@
   1.123  		findwindow.h \
   1.124  		mapcenterobj.h \
   1.125  		branchobj.h \
   1.126 +		linkobj.h \
   1.127  		floatimageobj.h \
   1.128  		linkablemapobj.h \
   1.129  		ornamentedobj.h \
   1.130 @@ -410,6 +434,7 @@
   1.131  		floatimageobj.h \
   1.132  		mapeditor.h \
   1.133  		branchobj.h \
   1.134 +		linkobj.h \
   1.135  		version.h \
   1.136  		linkablemapobj.h \
   1.137  		ornamentedobj.h \
   1.138 @@ -456,6 +481,7 @@
   1.139  		icons/flag-lifebelt.xpm \
   1.140  		mapcenterobj.h \
   1.141  		branchobj.h \
   1.142 +		linkobj.h \
   1.143  		floatimageobj.h \
   1.144  		ornamentedobj.h \
   1.145  		floatobj.h \
   1.146 @@ -490,6 +516,7 @@
   1.147  		imageobj.h \
   1.148  		mapcenterobj.h \
   1.149  		branchobj.h \
   1.150 +		linkobj.h \
   1.151  		version.h \
   1.152  		floatimageobj.h \
   1.153  		floatobj.h
   1.154 @@ -533,6 +560,7 @@
   1.155  		mapcenterobj.h \
   1.156  		mapeditor.h \
   1.157  		branchobj.h \
   1.158 +		linkobj.h \
   1.159  		floatimageobj.h \
   1.160  		linkablemapobj.h \
   1.161  		ornamentedobj.h \
   1.162 @@ -610,6 +638,7 @@
   1.163  		findwindow.h \
   1.164  		mapcenterobj.h \
   1.165  		branchobj.h \
   1.166 +		linkobj.h \
   1.167  		version.h \
   1.168  		floatimageobj.h \
   1.169  		linkablemapobj.h \
   1.170 @@ -627,6 +656,7 @@
   1.171  moc_mapeditor.o: moc_mapeditor.cpp  mapeditor.h mapcenterobj.h \
   1.172  		misc.h \
   1.173  		branchobj.h \
   1.174 +		linkobj.h \
   1.175  		version.h \
   1.176  		floatimageobj.h \
   1.177  		linkablemapobj.h \
   1.178 @@ -654,10 +684,9 @@
   1.179  
   1.180  moc_texteditor.o: moc_texteditor.cpp  texteditor.h 
   1.181  
   1.182 -moc_exporthtmldialog.o: moc_exporthtmldialog.cpp  exporthtmldialog.h showtextdialog.h
   1.183 +moc_exporthtmldialog.o: moc_exporthtmldialog.cpp  exporthtmldialog.h 
   1.184  
   1.185 -moc_exportxhtmldialog.o: moc_exportxhtmldialog.cpp  exportxhtmldialog.h process.h \
   1.186 -		showtextdialog.h
   1.187 +moc_exportxhtmldialog.o: moc_exportxhtmldialog.cpp  exportxhtmldialog.h 
   1.188  
   1.189  moc_showtextdialog.o: moc_showtextdialog.cpp  showtextdialog.h 
   1.190  
   1.191 @@ -721,6 +750,18 @@
   1.192  	-$(DEL_DIR) "$(INSTALL_ROOT)/usr/share/vym/"
   1.193  
   1.194  
   1.195 +install_doc: all 
   1.196 +	@$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/share/doc/packages/vym/" || $(MKDIR) "$(INSTALL_ROOT)/usr/share/doc/packages/vym/"
   1.197 +	-$(INSTALL_DIR) "doc/CVS" "$(INSTALL_ROOT)/usr/share/doc/packages/vym"
   1.198 +	-$(INSTALL_FILE) "doc/vym.pdf" "$(INSTALL_ROOT)/usr/share/doc/packages/vym"
   1.199 +
   1.200 +
   1.201 +uninstall_doc: 
   1.202 +	-$(DEL_FILE) -r "$(INSTALL_ROOT)/usr/share/doc/packages/vym/CVS"
   1.203 +	-$(DEL_FILE) -r "$(INSTALL_ROOT)/usr/share/doc/packages/vym/vym.pdf"
   1.204 +	-$(DEL_DIR) "$(INSTALL_ROOT)/usr/share/doc/packages/vym/"
   1.205 +
   1.206 +
   1.207  install_demo: all 
   1.208  	@$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/share/vym/" || $(MKDIR) "$(INSTALL_ROOT)/usr/share/vym/"
   1.209  	-$(INSTALL_DIR) "demos" "$(INSTALL_ROOT)/usr/share/vym/"
   1.210 @@ -731,7 +772,7 @@
   1.211  	-$(DEL_DIR) "$(INSTALL_ROOT)/usr/share/vym/"
   1.212  
   1.213  
   1.214 -install: install_target install_support install_demo  
   1.215 +install: install_target install_support install_doc install_demo  
   1.216  
   1.217 -uninstall: uninstall_target uninstall_support uninstall_demo  
   1.218 +uninstall: uninstall_target uninstall_support uninstall_doc uninstall_demo  
   1.219  
     2.1 --- a/branchobj.cpp	Sun Jan 30 12:59:10 2005 +0000
     2.2 +++ b/branchobj.cpp	Sun Jan 30 23:25:47 2005 +0000
     2.3 @@ -27,6 +27,7 @@
     2.4  BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c)
     2.5  {
     2.6  //    cout << "Const BranchObj (c)  called from MapCenterObj (c)\n";
     2.7 +	parObj=NULL;
     2.8      canvas=c;
     2.9  }
    2.10  
    2.11 @@ -47,16 +48,18 @@
    2.12  
    2.13  BranchObj::~BranchObj ()
    2.14  {
    2.15 -    //cout << "Destr BranchObj\n";
    2.16 +//	cout << "Destr BranchObj of "<<this<<endl;
    2.17  	// Check, if this branch was the last child to be deleted
    2.18  	// If so, unset the scrolled flags
    2.19  
    2.20  	BranchObj *po=(BranchObj*)(parObj);
    2.21 +	BranchObj *bo;
    2.22  	if (po)
    2.23  	{
    2.24 -		BranchObj *bo=((BranchObj*)(parObj))->getLastBranch();
    2.25 +		bo=((BranchObj*)(parObj))->getLastBranch();
    2.26  		if (!bo) po->unScroll();
    2.27  	}
    2.28 +	clear();
    2.29  }
    2.30  
    2.31  bool BranchObj::operator< ( const BranchObj & other )
    2.32 @@ -82,17 +85,19 @@
    2.33  
    2.34  void BranchObj::init () 
    2.35  {
    2.36 -    branch.setAutoDelete (true);
    2.37 +    branch.setAutoDelete (false);
    2.38      floatimage.setAutoDelete (true);
    2.39 +    link.setAutoDelete (false);
    2.40  
    2.41 -	absPos=getRandPos();
    2.42 -	absPos+=parObj->getChildPos();
    2.43 +	if (parObj)
    2.44 +	{
    2.45 +		absPos=getRandPos();
    2.46 +		absPos+=parObj->getChildPos();
    2.47 +	}
    2.48  
    2.49      // TODO This should be done in TextObj later
    2.50      QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
    2.51 -//    font.setPointSize(12);
    2.52 -   heading->setFont(font );
    2.53 -//    heading->setText(QObject::tr("new branch"));
    2.54 +    heading->setFont(font );
    2.55  
    2.56      lastSelectedBranch=-1;
    2.57  
    2.58 @@ -135,8 +140,17 @@
    2.59  
    2.60  void BranchObj::clear() 
    2.61  {
    2.62 -	branch.clear();
    2.63  	floatimage.clear();
    2.64 +	while (!link.isEmpty())
    2.65 +		deleteLink (link.first() );
    2.66 +
    2.67 +	BranchObj *bo;
    2.68 +	while (!branch.isEmpty())
    2.69 +	{
    2.70 +		bo=branch.first();
    2.71 +		branch.removeFirst();
    2.72 +		delete (bo);
    2.73 +	}
    2.74  }
    2.75  
    2.76  int BranchObj::getNum()
    2.77 @@ -541,7 +555,7 @@
    2.78      for (b=branch.first(); b;b=branch.next() ) 
    2.79  		b->moveBy (x,y);
    2.80  }
    2.81 -
    2.82 +	
    2.83  void BranchObj::moveBy (QPoint p)
    2.84  {
    2.85  	moveBy (p.x(), p.y());
    2.86 @@ -550,6 +564,14 @@
    2.87  
    2.88  void BranchObj::positionBBox()
    2.89  {
    2.90 +	// FIXME testing
    2.91 +	/*
    2.92 +	QString h=getHeading();
    2.93 +	if (!h.isEmpty())
    2.94 +		cout << "BO::positionBBox("<<h<<")\n";
    2.95 +	else	
    2.96 +		cout << "BO::positionBBox (noHeading)\n";
    2.97 +	*/	
    2.98  
    2.99      heading->positionBBox();
   2.100  	systemFlags->positionBBox();
   2.101 @@ -561,12 +583,16 @@
   2.102  	bbox.setY (absPos.y() );
   2.103  	bbox.setWidth(w_old);
   2.104  	bbox.setHeight(h_old);
   2.105 -
   2.106 -
   2.107 +	
   2.108  	setSelBox();
   2.109  
   2.110  	// set the frame
   2.111  	frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
   2.112 +
   2.113 +	// Update links to other branches
   2.114 +	LinkObj *l;
   2.115 +    for (l=link.first(); l; l=link.next() )
   2.116 +		l->updateLink();
   2.117  }
   2.118  
   2.119  void BranchObj::calcBBoxSize()
   2.120 @@ -759,6 +785,28 @@
   2.121      return s;
   2.122  }
   2.123  
   2.124 +void BranchObj::addLink (LinkObj *lo)
   2.125 +{
   2.126 +	link.append (lo);
   2.127 +	
   2.128 +}
   2.129 +
   2.130 +void BranchObj::removeLink (LinkObj *lo)
   2.131 +{
   2.132 +	link.remove (lo);
   2.133 +}
   2.134 +
   2.135 +void BranchObj::deleteLink(LinkObj *lo)
   2.136 +{
   2.137 +	lo->deactivate();
   2.138 +	if (!lo->isUsed()) delete (lo);
   2.139 +}
   2.140 +
   2.141 +int BranchObj::countLink()
   2.142 +{
   2.143 +	return link.count();
   2.144 +}
   2.145 +
   2.146  LinkableMapObj* BranchObj::addFloatImage ()
   2.147  {
   2.148  	FloatImageObj *newfi=new FloatImageObj (canvas,this);
   2.149 @@ -850,6 +898,17 @@
   2.150  	return newbo;
   2.151  }
   2.152  
   2.153 +BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
   2.154 +{
   2.155 +	branch.append (bo);
   2.156 +	bo->setParObj (this);
   2.157 +	bo->depth=depth+1;
   2.158 +	bo->setLinkStyle (bo->getDefLinkStyle() );
   2.159 +	if (scrolled) tmpUnscroll();
   2.160 +	setLastSelectedBranch (bo);
   2.161 +	return bo;
   2.162 +}
   2.163 +
   2.164  BranchObj* BranchObj::insertBranch(int pos)
   2.165  {
   2.166  	savePosInAngle();
   2.167 @@ -870,11 +929,36 @@
   2.168  	return newbo;
   2.169  }
   2.170  
   2.171 +BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
   2.172 +{
   2.173 +	savePosInAngle();
   2.174 +	// Add new bo and resort branches
   2.175 +	bo->angle=pos-0.5;
   2.176 +	branch.append (bo);
   2.177 +	bo->setParObj (this);
   2.178 +	bo->depth=depth+1;
   2.179 +	bo->setLinkStyle (bo->getDefLinkStyle() );
   2.180 +	if (scrolled) tmpUnscroll();
   2.181 +	setLastSelectedBranch (bo);
   2.182 +	branch.sort();
   2.183 +	return bo;
   2.184 +}
   2.185 +
   2.186  void BranchObj::removeBranch(BranchObj* bo)
   2.187  {
   2.188      // if bo is not in branch remove returns false, we
   2.189      // don't care...
   2.190 -    branch.remove (bo);
   2.191 +	
   2.192 +    if (branch.remove (bo))
   2.193 +		delete (bo);
   2.194 +	else
   2.195 +		qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
   2.196 +	requestReposition();
   2.197 +}
   2.198 +
   2.199 +void BranchObj::removeBranchPtr(BranchObj* bo)
   2.200 +{
   2.201 +	branch.remove (bo);
   2.202  	requestReposition();
   2.203  }
   2.204  
   2.205 @@ -939,6 +1023,32 @@
   2.206  		return branch.at(i);
   2.207  }
   2.208  
   2.209 +BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
   2.210 +{
   2.211 +	// Find current parent and 
   2.212 +	// remove pointer to myself there
   2.213 +	BranchObj *par=(BranchObj*)(parObj);
   2.214 +	if (par)
   2.215 +		par->removeBranchPtr (this);
   2.216 +	else
   2.217 +		return NULL;
   2.218 +
   2.219 +	if (pos<0)
   2.220 +	{	
   2.221 +		// links adds myself as last branch at dst
   2.222 +		dst->addBranchPtr (this);
   2.223 +		return this;
   2.224 +	} else
   2.225 +	{
   2.226 +		// inserts me at pos in parent of dst
   2.227 +		par=(BranchObj*)(dst->getParObj());
   2.228 +		if (par)
   2.229 +			return par->insertBranchPtr (this,pos);
   2.230 +		else
   2.231 +			return NULL;
   2.232 +	}	
   2.233 +}
   2.234 +
   2.235  void BranchObj::alignRelativeTo (QPoint ref)
   2.236  {
   2.237  /* FIXME testing
     3.1 --- a/branchobj.h	Sun Jan 30 12:59:10 2005 +0000
     3.2 +++ b/branchobj.h	Sun Jan 30 23:25:47 2005 +0000
     3.3 @@ -4,6 +4,7 @@
     3.4  #include "floatimageobj.h"
     3.5  #include "linkablemapobj.h"
     3.6  #include "ornamentedobj.h"
     3.7 +#include "linkobj.h"
     3.8  
     3.9  class BranchObjPtrList : public QPtrList<BranchObj>
    3.10  {
    3.11 @@ -61,6 +62,10 @@
    3.12      virtual void setVymLink (QString);
    3.13      virtual QString getVymLink ();
    3.14  	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
    3.15 +	virtual void addLink (LinkObj*);
    3.16 +	virtual void removeLink (LinkObj*);
    3.17 +	virtual void deleteLink (LinkObj*);
    3.18 +	virtual int countLink ();
    3.19  	virtual LinkableMapObj* addFloatImage();
    3.20  	virtual LinkableMapObj* addFloatImage(FloatImageObj*);
    3.21  	virtual void removeFloatImage(FloatImageObj*);
    3.22 @@ -72,9 +77,12 @@
    3.23  public:	
    3.24      virtual BranchObj* addBranch();
    3.25      virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
    3.26 +    virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
    3.27      virtual BranchObj* insertBranch(int);
    3.28      virtual BranchObj* insertBranch(BranchObj*,int);
    3.29 +    virtual BranchObj* insertBranchPtr (BranchObj*,int);
    3.30      virtual void removeBranch(BranchObj*);  
    3.31 +    virtual void removeBranchPtr (BranchObj*);  
    3.32      virtual void setLastSelectedBranch(BranchObj*);
    3.33      virtual BranchObj* getLastSelectedBranch();
    3.34      virtual BranchObj* getFirstBranch();
    3.35 @@ -82,7 +90,7 @@
    3.36  	virtual BranchObj* getBranchNum(const uint &);
    3.37      virtual BranchObj* moveBranchUp(BranchObj*);
    3.38      virtual BranchObj* moveBranchDown(BranchObj*);
    3.39 -
    3.40 +    virtual BranchObj* moveBranchTo (BranchObj*, int);
    3.41      virtual void alignRelativeTo(const QPoint );
    3.42  	virtual void reposition();
    3.43  
    3.44 @@ -98,6 +106,7 @@
    3.45  	static BranchObj* itLast;		// iterator for first(), next()
    3.46      BranchObjPtrList branch;		// all child branches
    3.47  	QPtrList<FloatImageObj> floatimage;	// child images
    3.48 +	QPtrList<LinkObj> link;			// links to other branches
    3.49  public:	
    3.50  	float angle;					// used in mainbranch to reorder mainbranches
    3.51  protected:	
     4.1 Binary file demos/todo.vym has changed
     5.1 --- a/linkablemapobj.cpp	Sun Jan 30 12:59:10 2005 +0000
     5.2 +++ b/linkablemapobj.cpp	Sun Jan 30 23:25:47 2005 +0000
     5.3 @@ -157,6 +157,7 @@
     5.4  
     5.5  void LinkableMapObj::setLinkStyle(LinkStyle newstyle)
     5.6  {
     5.7 +	//if (newstyle=style) return;
     5.8  	delLink();
     5.9  		
    5.10  	style=newstyle;
    5.11 @@ -246,9 +247,10 @@
    5.12  			default: 
    5.13  				break;	
    5.14  		}	
    5.15 +		updateLink();
    5.16  	} else
    5.17  	{
    5.18 -		cout << "Error: ChildObj or parObj == NULL in LinkableMapObj::setLinkStyle\n";
    5.19 +		qWarning ("Error: ChildObj or parObj == NULL in LinkableMapObj::setLinkStyle\n");
    5.20  	}
    5.21  }
    5.22  
    5.23 @@ -587,7 +589,6 @@
    5.24  
    5.25  void LinkableMapObj::reposition()
    5.26  {
    5.27 -cout << "LMO::reposition  ???"<<endl;
    5.28  	if (depth==0)
    5.29  	{
    5.30  		// only calculate the sizes once. If the deepest LMO changes its height,
    5.31 @@ -633,7 +634,8 @@
    5.32  	if (parObj) 
    5.33  		parObj->forceReposition(); 
    5.34  	else 
    5.35 -		reposition(); }
    5.36 +		reposition(); 
    5.37 +}
    5.38  
    5.39  bool LinkableMapObj::repositionRequested()
    5.40  {
     6.1 --- a/mapcenterobj.cpp	Sun Jan 30 12:59:10 2005 +0000
     6.2 +++ b/mapcenterobj.cpp	Sun Jan 30 23:25:47 2005 +0000
     6.3 @@ -32,6 +32,7 @@
     6.4  
     6.5  void MapCenterObj::init () 
     6.6  {
     6.7 +	BranchObj::init();
     6.8      orientation=OrientUndef;
     6.9      absPos=QPoint (canvas->width()/2, canvas->height()/2);
    6.10  
    6.11 @@ -39,15 +40,9 @@
    6.12  	QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    6.13  	heading->setFont(font);
    6.14  
    6.15 -	branch.setAutoDelete (TRUE);
    6.16 -	floatimage.setAutoDelete (TRUE);
    6.17 -
    6.18  	move (absPos.x(), absPos.y() );
    6.19  	depth=0;
    6.20  
    6.21 -	scrolled=false;
    6.22 -	tmpUnscrolled=false;
    6.23 -
    6.24  	frame->setFrameType (Rectangle);
    6.25  }
    6.26  
    6.27 @@ -233,3 +228,4 @@
    6.28  {
    6.29  	return QDate::currentDate().toString ("yyyy-MM-dd");
    6.30  }
    6.31 +
     7.1 --- a/mapcenterobj.h	Sun Jan 30 12:59:10 2005 +0000
     7.2 +++ b/mapcenterobj.h	Sun Jan 30 23:25:47 2005 +0000
     7.3 @@ -2,6 +2,7 @@
     7.4  #define MAPCENTEROBJ_H
     7.5  
     7.6  #include "branchobj.h"
     7.7 +#include "linkobj.h"
     7.8  #include "version.h"
     7.9  
    7.10  /////////////////////////////////////////////////////////////////////////////
     8.1 --- a/mapeditor.cpp	Sun Jan 30 12:59:10 2005 +0000
     8.2 +++ b/mapeditor.cpp	Sun Jan 30 23:25:47 2005 +0000
     8.3 @@ -300,6 +300,8 @@
     8.4  		pickColorCursor=QCursor ( cursorcolorpicker_xpm, 5,27 ); 
     8.5  	#endif
     8.6  
     8.7 +	modifierMode=pickColorMode;
     8.8 +	modifierMode=linkObjectsMode;	// FIXME testing
     8.9  
    8.10  	pickingColor=false;
    8.11  
    8.12 @@ -1179,11 +1181,6 @@
    8.13  
    8.14  LinkableMapObj* MapEditor::pasteNoSave()
    8.15  {
    8.16 -	return pasteAtNoSave (-1);
    8.17 -}
    8.18 -
    8.19 -LinkableMapObj* MapEditor::pasteAtNoSave(int pos)
    8.20 -{
    8.21  	// Finish open lineEdits
    8.22  	if (lineedit) finishedLineEditNoSave();
    8.23  
    8.24 @@ -1201,13 +1198,7 @@
    8.25  				((BranchObj*)(returnLMO))->move2RelPos(normalise(fromLMO->getRelPos() ) );
    8.26  			}     
    8.27  			if (typeid(*selection) == typeid(BranchObj)) 
    8.28 -				if (pos<0)
    8.29  					returnLMO=((BranchObj*)(selection))->addBranch((BranchObj*)(fromLMO) );
    8.30 -				else
    8.31 -				{
    8.32 -					BranchObj *par=(BranchObj*)(selection->getParObj());
    8.33 -					if (par) returnLMO=par->insertBranch((BranchObj*)(fromLMO),pos );
    8.34 -				}	
    8.35  		}
    8.36  		
    8.37  		if (typeid(*fromLMO) == typeid(FloatImageObj) &&
    8.38 @@ -1449,7 +1440,7 @@
    8.39  	return selection;
    8.40  }
    8.41  
    8.42 -bool MapEditor::select (QString s)
    8.43 +LinkableMapObj* MapEditor::findObj (QString s)
    8.44  {
    8.45  	LinkableMapObj *lmo=mapCenter;
    8.46  	QString part;
    8.47 @@ -1473,9 +1464,6 @@
    8.48  			else
    8.49  				if (typ=="fi:")
    8.50  					lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());
    8.51 -				
    8.52 -		
    8.53 -		
    8.54  		if (!lmo) break;
    8.55  		
    8.56  		if (s.contains(","))
    8.57 @@ -1483,6 +1471,12 @@
    8.58  		else	
    8.59  			break;
    8.60  	}
    8.61 +	return lmo;
    8.62 +}
    8.63 +
    8.64 +bool MapEditor::select (const QString &s)
    8.65 +{
    8.66 +	LinkableMapObj *lmo=findObj(s);
    8.67  
    8.68  	// Finally select the found object
    8.69  	if (lmo)
    8.70 @@ -1495,8 +1489,6 @@
    8.71  		return true;
    8.72  	} else
    8.73  		return false;
    8.74 -	
    8.75 -	
    8.76  }
    8.77  
    8.78  void MapEditor::unselect()
    8.79 @@ -2654,6 +2646,10 @@
    8.80  void MapEditor::testFunction()
    8.81  {
    8.82  	cout << "MapEditor::testFunction() called\n";
    8.83 +	if (modifierMode==pickColorMode)
    8.84 +		modifierMode=linkObjectsMode;
    8.85 +	else	
    8.86 +		modifierMode=pickColorMode;
    8.87  }
    8.88  
    8.89  void MapEditor::ensureSelectionVisible()
    8.90 @@ -2729,12 +2725,34 @@
    8.91      QPoint p = inverseWorldMatrix().map(e->pos());
    8.92      LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
    8.93  	
    8.94 -	// Special case: CTRL is pressed, don't select anything
    8.95 +	// Special case: CTRL is pressed
    8.96  	if (e->state() & QMouseEvent::ControlButton)
    8.97  	{
    8.98 -		pickingColor=true;
    8.99 -		setCursor (pickColorCursor);
   8.100 -		return;
   8.101 +		if (modifierMode==pickColorMode)
   8.102 +		{
   8.103 +			if (e->state() & QMouseEvent::ControlButton)
   8.104 +			{
   8.105 +				pickingColor=true;
   8.106 +				setCursor (pickColorCursor);
   8.107 +				return;
   8.108 +			}
   8.109 +		} 
   8.110 +		if (modifierMode==linkObjectsMode)
   8.111 +		{	
   8.112 +			if (lmo && 
   8.113 +				(typeid(*lmo) == typeid(BranchObj)) || 
   8.114 +				(typeid(*lmo) == typeid(MapCenterObj))  )
   8.115 +			{
   8.116 +				drawingLink=true;
   8.117 +				linkingObj_src=selection;
   8.118 +				tmpLink=new LinkObj (mapCanvas);
   8.119 +				tmpLink->setBegin ( ((BranchObj*)(lmo)) );
   8.120 +				tmpLink->setEnd   (p);
   8.121 +				tmpLink->updateLink();
   8.122 +				tmpLink->setVisibility (true);
   8.123 +				return;
   8.124 +			}	
   8.125 +		}	
   8.126  	}
   8.127  
   8.128      if (lmo) 
   8.129 @@ -2803,14 +2821,15 @@
   8.130  
   8.131  void MapEditor::contentsMouseMoveEvent(QMouseEvent* e)
   8.132  {
   8.133 +	QPoint p = inverseWorldMatrix().map(e->pos());
   8.134 +
   8.135      // Move the selected MapObj
   8.136      if ( selection && movingObj) 
   8.137      {	
   8.138 -		QPoint p = inverseWorldMatrix().map(e->pos());
   8.139  		
   8.140 -		// Now move the selection, but add relative position (movingObj_start) 
   8.141 -		// where selection 
   8.142 -		// was chosen with mousepointer. (This avoids flickering resp. jumping 
   8.143 +		// Now move the selection, but add relative position 
   8.144 +		// (movingObj_start) where selection was chosen with 
   8.145 +		// mousepointer. (This avoids flickering resp. jumping 
   8.146  		// of selection back to absPos)
   8.147  		
   8.148  		LinkableMapObj *lmosel;
   8.149 @@ -2923,8 +2942,15 @@
   8.150  		return;
   8.151  	} // selection && moving_obj
   8.152  		
   8.153 +	// Draw a link from one branch to another
   8.154 +	if (drawingLink)
   8.155 +	{
   8.156 +		 tmpLink->setEnd (p);
   8.157 +		 tmpLink->updateLink();
   8.158 +	}	 
   8.159 +	
   8.160      // Move CanvasView 
   8.161 -    if (!movingObj && !pickingColor) 
   8.162 +    if (!movingObj && !pickingColor &&!drawingLink) 
   8.163  	{
   8.164  		QPoint p=e->globalPos();
   8.165  		movingVec.setX(-p.x() + movingObj_start.x() );
   8.166 @@ -2962,6 +2988,27 @@
   8.167  		} 
   8.168  		return;
   8.169  	}
   8.170 +
   8.171 +	// Have we been drawing a link?
   8.172 +	if (drawingLink)
   8.173 +	{
   8.174 +		drawingLink=false;
   8.175 +		// Check if we are over another branch
   8.176 +		dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL);
   8.177 +		if (dst && selection) 
   8.178 +		{	
   8.179 +			tmpLink->setEnd ( ((BranchObj*)(dst)) );
   8.180 +			tmpLink->updateLink();
   8.181 +			tmpLink->activate();
   8.182 +			
   8.183 +		} else
   8.184 +		{
   8.185 +			delete(tmpLink);
   8.186 +			tmpLink=NULL;
   8.187 +		}
   8.188 +		return;
   8.189 +	}
   8.190 +	
   8.191      // Have we been moving something?
   8.192      if ( selection && movingObj ) 
   8.193      {	
   8.194 @@ -2992,30 +3039,30 @@
   8.195  				// TODO we also could check, if dest and src are on same branch,
   8.196  				// then it would be sufficient to saveState of this branch
   8.197  
   8.198 -				// FIXME better introduce BO::move  to speed up and keep IDs
   8.199 -				copy();			// copy selection to clipboard
   8.200 -				cutNoSave();	// remove selection here
   8.201 -
   8.202 -				selection->unselect();	
   8.203 -				selection=dst;
   8.204  				// Modifiers allow to insert above/below dst
   8.205  				if (e->state() & QMouseEvent::ShiftButton)
   8.206  				{
   8.207 -					selection=pasteAtNoSave (((BranchObj*)(dst))->getNum());
   8.208 -					if (selection) selection->select();
   8.209 -				}	
   8.210 -				else if (e->state() & QMouseEvent::ControlButton)
   8.211 -				{
   8.212 -					selection=pasteAtNoSave (((BranchObj*)(dst))->getNum()+1);
   8.213 -					if (selection) selection->select();
   8.214 -				}	
   8.215 -				else	
   8.216 -				{
   8.217 -					selection=pasteNoSave();
   8.218 -					selection->select();
   8.219 -					if (dst->getDepth()==0) 
   8.220 -						((BranchObj*)(selection))->move (savePos);
   8.221 -				}	
   8.222 +						((BranchObj*)(selection))->moveBranchTo 
   8.223 +						(
   8.224 +							(BranchObj*)(dst),
   8.225 +							((BranchObj*)(dst))->getNum()
   8.226 +						);
   8.227 +					//if (selection) selection->select();
   8.228 +				} else 
   8.229 +					if (e->state() & QMouseEvent::ControlButton)
   8.230 +					{
   8.231 +						((BranchObj*)(selection))->moveBranchTo 
   8.232 +						(
   8.233 +							(BranchObj*)(dst),
   8.234 +							((BranchObj*)(dst))->getNum()+1
   8.235 +						);
   8.236 +						//if (selection) selection->select();
   8.237 +					} else	
   8.238 +					{
   8.239 +						((BranchObj*)(selection))->moveBranchTo ((BranchObj*)(dst),-1);
   8.240 +						if (dst->getDepth()==0) 
   8.241 +							((BranchObj*)(selection))->move (savePos);
   8.242 +					}	
   8.243  			} 
   8.244  			// Draw the original link, before selection was moved around
   8.245  			mapCenter->reposition();
   8.246 @@ -3025,9 +3072,9 @@
   8.247  		canvas()->update();
   8.248  		movingObj=NULL;		
   8.249  	} else 
   8.250 -	{	// maybe we moved View: set old cursor
   8.251 +		// maybe we moved View: set old cursor
   8.252  		setCursor (ArrowCursor);
   8.253 -    }
   8.254 +    
   8.255  }
   8.256  
   8.257  void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e)
     9.1 --- a/mapeditor.h	Sun Jan 30 12:59:10 2005 +0000
     9.2 +++ b/mapeditor.h	Sun Jan 30 23:25:47 2005 +0000
     9.3 @@ -11,6 +11,8 @@
     9.4  #include "mapcenterobj.h"
     9.5  #include "misc.h"
     9.6  
     9.7 +enum ModifierMode {pickColorMode,linkObjectsMode};
     9.8 +
     9.9  class MapEditor : public QCanvasView , public xmlObj {
    9.10      Q_OBJECT
    9.11  
    9.12 @@ -66,7 +68,6 @@
    9.13      void copy();		// copy branch to clipboard
    9.14  private:	
    9.15      LinkableMapObj* pasteNoSave();		// paste clipboard to branch
    9.16 -    LinkableMapObj* pasteAtNoSave(int);	// paste clipboard to branch at position i
    9.17      void cutNoSave();	// cut to clipboard
    9.18  public:	
    9.19      void paste();		// paste clipboard to branch and backup
    9.20 @@ -77,7 +78,8 @@
    9.21      void addNewBranch(int);			// pos allows to add above/below selection
    9.22      void deleteSelection();
    9.23  	LinkableMapObj* getSelection();	// returns selection
    9.24 -	bool select(QString );			// Select 
    9.25 +	LinkableMapObj* findObj (QString);
    9.26 +	bool select(const QString &);	// Select 
    9.27  	void unselect();				// before changing current noteedit
    9.28  	void reselect();				// after  changing current noteedit
    9.29  private:	
    9.30 @@ -152,13 +154,18 @@
    9.31  	LinkColorHint linkcolorhint;// use heading color or own color
    9.32  	LinkStyle linkstyle;		// default style for links
    9.33  
    9.34 +	ModifierMode modifierMode;	// pick color or link objects?
    9.35 +
    9.36      QCursor handOpenCursor;		// cursor while moving canvas view
    9.37  	QCursor pickColorCursor;	// cursor while picking color 
    9.38 -	bool pickingColor;			// true while picking Color CTRL-LeftButton
    9.39 +	bool pickingColor;
    9.40 +	bool drawingLink;			// true while creating a link
    9.41 +	LinkObj* tmpLink;
    9.42  	
    9.43      LinkableMapObj* selection;		// select a LinkableMapObj
    9.44      LinkableMapObj* selectionLast;	// last selection 
    9.45      MapObj* movingObj;				// moving a MapObj
    9.46 +	MapObj* linkingObj_src;			// part of a link
    9.47      QPoint movingObj_start;			// rel. pos of mouse to absPos 
    9.48      QPoint movingCont_start;		// inital pos of moving Content or
    9.49      QPoint movingVec;				// how far has Content moved
    10.1 --- a/version.h	Sun Jan 30 12:59:10 2005 +0000
    10.2 +++ b/version.h	Sun Jan 30 23:25:47 2005 +0000
    10.3 @@ -1,7 +1,7 @@
    10.4  #ifndef VERSION_H 
    10.5  #define VERSION_H
    10.6  
    10.7 -#define __VYM_VERSION__ "1.6.0"
    10.8 -#define __BUILD_DATE__ "January 4, 2005"
    10.9 +#define __VYM_VERSION__ "1.6.1"
   10.10 +#define __BUILD_DATE__ "January 30, 2005"
   10.11  
   10.12  #endif
    11.1 --- a/vym.pro	Sun Jan 30 12:59:10 2005 +0000
    11.2 +++ b/vym.pro	Sun Jan 30 23:25:47 2005 +0000
    11.3 @@ -35,6 +35,7 @@
    11.4  	headingobj.h \
    11.5  	imageobj.h \
    11.6  	linkablemapobj.h \
    11.7 +	linkobj.h \
    11.8  	mainwindow.h \
    11.9  	mapcenterobj.h \
   11.10  	mapeditor.h \
   11.11 @@ -60,6 +61,7 @@
   11.12  	headingobj.cpp \
   11.13  	imageobj.cpp \
   11.14  	linkablemapobj.cpp \
   11.15 +	linkobj.cpp \
   11.16  	main.cpp \
   11.17  	mainwindow.cpp \
   11.18  	mapcenterobj.cpp \
    12.1 --- a/xml.cpp	Sun Jan 30 12:59:10 2005 +0000
    12.2 +++ b/xml.cpp	Sun Jan 30 23:25:47 2005 +0000
    12.3 @@ -47,7 +47,7 @@
    12.4                      const QString& eName, const QXmlAttributes& atts ) 
    12.5  {
    12.6      QColor col;
    12.7 -//	cout << "startElement <"<<eName<<">  state="<<state <<"  laststate="<<laststate<<endl;
    12.8 +	//cout << "startElement <"<<eName<<">  state="<<state <<"  laststate="<<laststate<<"   loadMode="<<loadMode<<endl;
    12.9      if ( state == StateInit && (eName == "vymmap")  ) 
   12.10  	{
   12.11          state = StateMap;
   12.12 @@ -171,6 +171,14 @@
   12.13  		isVymPart=true;
   12.14  		state=StateBranch;
   12.15  		LinkableMapObj* lmo=me->getSelection();
   12.16 +		if (!lmo)
   12.17 +		{
   12.18 +			// If a vym part is _loaded_ (not imported), 
   12.19 +			// selection==lmo==NULL
   12.20 +			// Treat it like ImportAdd then...
   12.21 +			loadMode=ImportAdd;
   12.22 +			lmo=mc;
   12.23 +		}	
   12.24  		if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
   12.25  				|| (typeid(*lmo) == typeid(MapCenterObj) ) )
   12.26  		{