# HG changeset patch
# User insilmaril
# Date 1113087008 0
# Node ID 6783e13bb05d622b02ab17b1b0388d16c1cba3e8
# Parent  31c6ce8efbc77ebb81db2fd4032b2ceb8ac1cc92
links are now partially visible, if one end is scrolled

diff -r 31c6ce8efbc7 -r 6783e13bb05d branchobj.cpp
--- a/branchobj.cpp	Thu Mar 24 21:10:38 2005 +0000
+++ b/branchobj.cpp	Sat Apr 09 22:50:08 2005 +0000
@@ -380,9 +380,11 @@
 			FloatImageObj *fio;
 			for (fio=floatimage.first(); fio; fio=floatimage.next())
 				fio->setVisibility (v);
+			LinkObj* lo;
+			for (lo=link.first(); lo;lo=link.next() ) 
+				lo->setVisibility ();	
 		}
     } // depth <= toDepth	
-	//FIXME move (absPos.x(), absPos.y() );
 	requestReposition();
 }	
 
@@ -798,7 +800,7 @@
 	
 }
 
-void BranchObj::removeLink (LinkObj *lo)
+void BranchObj::removeLinkRef (LinkObj *lo)
 {
 	link.remove (lo);
 }
@@ -809,6 +811,16 @@
 	if (!lo->isUsed()) delete (lo);
 }
 
+void BranchObj::deleteLinkAt (int i)
+{
+	LinkObj *lo=link.at(i);
+	lo->deactivate();
+	if (!lo->isUsed()) 
+	{
+		delete(lo);
+	}	
+}
+
 int BranchObj::countLink()
 {
 	return link.count();
@@ -1044,13 +1056,16 @@
 {
 	// Find current parent and 
 	// remove pointer to myself there
+
+	if (!dst) return NULL;
+
 	BranchObj *par=(BranchObj*)(parObj);
 	if (par)
 		par->removeBranchPtr (this);
 	else
 		return NULL;
 
-	if (pos<0)
+	if (pos<0  || dst->getDepth()==1)
 	{	
 		// links adds myself as last branch at dst
 		dst->addBranchPtr (this);
diff -r 31c6ce8efbc7 -r 6783e13bb05d branchobj.h
--- a/branchobj.h	Thu Mar 24 21:10:38 2005 +0000
+++ b/branchobj.h	Sat Apr 09 22:50:08 2005 +0000
@@ -64,8 +64,9 @@
     virtual QString getVymLink ();
 	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
 	virtual void addLink (LinkObj*);
-	virtual void removeLink (LinkObj*);
-	virtual void deleteLink (LinkObj*);
+	virtual void removeLinkRef (LinkObj*);	// Remove ref in list
+	virtual void deleteLink (LinkObj*);		// remove references and delete LinkObj 
+	virtual void deleteLinkAt (int);		// remove references and delete LinkObj 
 	virtual int countLink ();
 	virtual BranchObj* linkTargetAt (int);
 	virtual LinkableMapObj* addFloatImage();
diff -r 31c6ce8efbc7 -r 6783e13bb05d demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 31c6ce8efbc7 -r 6783e13bb05d lang/vym_de.ts
--- a/lang/vym_de.ts	Thu Mar 24 21:10:38 2005 +0000
+++ b/lang/vym_de.ts	Sat Apr 09 22:50:08 2005 +0000
@@ -273,7 +273,7 @@
     </message>
     <message>
         <source>&amp;Save...</source>
-        <translation>Speichern &amp;unter...</translation>
+        <translation>&amp;Speichern...</translation>
     </message>
     <message>
         <source>Save &amp;As...</source>
diff -r 31c6ce8efbc7 -r 6783e13bb05d linkobj.cpp
--- a/linkobj.cpp	Thu Mar 24 21:10:38 2005 +0000
+++ b/linkobj.cpp	Sat Apr 09 22:50:08 2005 +0000
@@ -8,20 +8,20 @@
 
 LinkObj::LinkObj ():MapObj() 
 {
-//	cout << "Const LinkObj ()\n";
-    init();
+	//	cout << "Const LinkObj ()\n";
+	init();
 }
 
 LinkObj::LinkObj (QCanvas* c):MapObj(c)
 {
-//	cout << "Const LinkObj (c)  called from MapCenterObj (c)\n";
-    init();
+	//	cout << "Const LinkObj (c)  called from MapCenterObj (c)\n";
+	init();
 }
 
 
 LinkObj::~LinkObj ()
 {
-//	cout << "Destr LinkObj\n";
+	//	cout << "Destr LinkObj\n";
 	if (linkState!=undefinedLink)
 		deactivate();
 	delete (line);
@@ -31,6 +31,7 @@
 {
 	beginBranch=NULL;
 	endBranch=NULL;
+	visBranch=NULL;
 	linkState=undefinedLink;
 
 	line=new QCanvasLine (canvas);
@@ -91,11 +92,12 @@
 void LinkObj::deactivate ()
 {
 	if (beginBranch)
-		beginBranch->removeLink (this);
+		beginBranch->removeLinkRef (this);
 	beginBranch=NULL;	
 	if (endBranch)
-		endBranch->removeLink (this);
+		endBranch->removeLinkRef (this);
 	endBranch=NULL;	
+	visBranch=NULL;
 	linkState=undefinedLink;
 
 	line->hide();
@@ -112,22 +114,38 @@
 void LinkObj::updateLink()
 {
 	QPoint a,b;
-	if (beginBranch)
-		// If a link is just drawed in the editor,
-		// we have already a beginBranch
-		a=beginBranch->getChildPos();
-	else
-		// This shouldn't be reached normally...
-		a=beginPos;
-	if (linkState==activeLink && endBranch)
-		b=endBranch->getChildPos();
-	else
-		b=endPos;
-	
-	if (line->startPoint()==a && line->endPoint()==b)
+	if (visBranch)
+	{
+		// Only one of the linked branches is visible
+		a=b=visBranch->getChildPos();
+		if (visBranch->getOrientation()==OrientRightOfCenter)
+			b.setX (b.x()+25);
+		else
+			b.setX (b.x()-25);
+	} else
+	{
+		// Both linked branches are visible
+		if (beginBranch)
+			// If a link is just drawn in the editor,
+			// we have already a beginBranch
+			a=beginBranch->getChildPos();
+		else
+			// This shouldn't be reached normally...
+			a=beginPos;
+		if (linkState==activeLink && endBranch)
+			b=endBranch->getChildPos();
+		else
+			b=endPos;
+	}
+
+
+	if (line->startPoint()==a && line->endPoint()==b && !visBranch)
+	{
 		// update is called from both branches, so only
 		// update if needed
+		cout <<"LO__updateL  returnung...\n";
 		return;
+	}	
 	else
 	{
 		beginPos=a;
@@ -167,3 +185,31 @@
 	}	
 }
 
+void LinkObj::setVisibility ()
+{
+	if (beginBranch && endBranch)
+	{
+		if(beginBranch->isVisibleObj() && endBranch->isVisibleObj())
+		{	// Both ends are visible
+			setVisibility (true);
+			visBranch=NULL;
+		} else
+		{
+			if(!beginBranch->isVisibleObj() && !endBranch->isVisibleObj())
+			{	//None of the ends is visible
+				setVisibility (false);
+				visBranch=NULL;
+			} else
+			{	// Just one end is visible, draw a symbol that shows
+				// that there is a link to a scrolled branch
+				setVisibility (true);
+				if (beginBranch->isVisibleObj())
+					visBranch=beginBranch;
+				else
+					visBranch=endBranch;
+					
+			}
+		}
+	}
+}
+
diff -r 31c6ce8efbc7 -r 6783e13bb05d linkobj.h
--- a/linkobj.h	Thu Mar 24 21:10:38 2005 +0000
+++ b/linkobj.h	Sat Apr 09 22:50:08 2005 +0000
@@ -24,11 +24,13 @@
 	void positionBBox();
 	void calcBBoxSize();
 	void setVisibility (bool);
+	void setVisibility ();
 
 private:
 	QCanvasLine *line;
 	BranchObj *beginBranch;
 	BranchObj *endBranch;
+	BranchObj *visBranch;	// the "visible" part of a partially scrolled link
 	LinkState linkState;	// init during drawing or active
 	QPoint beginPos;
 	QPoint   endPos;
diff -r 31c6ce8efbc7 -r 6783e13bb05d main.cpp
--- a/main.cpp	Thu Mar 24 21:10:38 2005 +0000
+++ b/main.cpp	Sat Apr 09 22:50:08 2005 +0000
@@ -52,7 +52,6 @@
 QAction *actionEditSelectLast;
 QAction *actionEditLoadImage;
 QAction *actionEditToggleFloatExport;
-QAction *actionEditNoLink;
 
 QAction *actionFormatColor;		
 QAction *actionFormatPickColor;		
@@ -87,6 +86,7 @@
 
 QPopupMenu *branchContextMenu;
 QPopupMenu *branchLinksContextMenu;
+QPopupMenu *branchLinksContextMenuDup;
 QPopupMenu *floatimageContextMenu;
 QPopupMenu *saveImageFormatMenu;
 QPopupMenu *canvasContextMenu;
diff -r 31c6ce8efbc7 -r 6783e13bb05d mainwindow.cpp
--- a/mainwindow.cpp	Thu Mar 24 21:10:38 2005 +0000
+++ b/mainwindow.cpp	Sat Apr 09 22:50:08 2005 +0000
@@ -92,7 +92,6 @@
 extern QAction *actionEditSelectLast;
 extern QAction *actionEditLoadImage;
 extern QAction *actionEditToggleFloatExport;
-extern QAction *actionEditNoLink;
 
 extern QAction* actionFormatColor;
 extern QAction* actionFormatPickColor;
@@ -128,6 +127,7 @@
 
 extern QPopupMenu* branchContextMenu;
 extern QPopupMenu* branchLinksContextMenu;
+extern QPopupMenu* branchLinksContextMenuDup;
 extern QPopupMenu* floatimageContextMenu;
 extern QPopupMenu* saveImageFormatMenu;
 extern QPopupMenu* canvasContextMenu;
@@ -572,10 +572,6 @@
     connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
 	actionEditLoadImage=a;
 
-	// inserted into branchLinksContextMenu, if no link is available.
-    a = new QAction( tr( "No link available" ),tr( "No link available" ), 0, this, "noLink" );
-	a->setEnabled (false);
-	actionEditNoLink=a;
 }
 
 // Format Actions
@@ -856,8 +852,12 @@
 	// This will be populated "on demand" in MapEditor::updateActions
 	branchContextMenu->insertSeparator();	
 	branchLinksContextMenu =new QPopupMenu (this);
-	branchContextMenu->insertItem ("Goto Link",branchLinksContextMenu);
+	branchContextMenu->insertItem (tr("Goto Link"),branchLinksContextMenu);
 	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowLink(int ) ) );
+	
+	branchLinksContextMenuDup =new QPopupMenu (this);
+	branchContextMenu->insertItem (tr("Edit Link"),branchLinksContextMenuDup);
+	connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditLink(int ) ) );
 
 	// Context menu for floatimage
 	floatimageContextMenu =new QPopupMenu (this);
@@ -1537,8 +1537,9 @@
 			fileSave(savemode);
 
 			// Set name of tab
-			tabWidget->setTabLabel (currentMapEditor(),
-				currentMapEditor()->getFileName() );
+			if (savemode==CompleteMap)
+				tabWidget->setTabLabel (currentMapEditor(),
+					currentMapEditor()->getFileName() );
 			return;
 		} 
 	}
@@ -1999,6 +2000,12 @@
 		currentMapEditor()->followLink(branchLinksContextMenu->indexOf(item));
 }
 
+void Main::editEditLink(int item)
+{
+	if (currentMapEditor())
+		currentMapEditor()->editLink(branchLinksContextMenuDup->indexOf(item));
+}
+
 void Main::formatSelectColor()
 {
 	if (currentMapEditor())
diff -r 31c6ce8efbc7 -r 6783e13bb05d mainwindow.h
--- a/mainwindow.h	Thu Mar 24 21:10:38 2005 +0000
+++ b/mainwindow.h	Sat Apr 09 22:50:08 2005 +0000
@@ -116,6 +116,7 @@
     void editSaveImage(int);
     void editToggleFloatExport();
     void editFollowLink (int);
+    void editEditLink (int);
 
     void formatSelectColor();
     void formatPickColor();
diff -r 31c6ce8efbc7 -r 6783e13bb05d mapeditor.cpp
--- a/mapeditor.cpp	Thu Mar 24 21:10:38 2005 +0000
+++ b/mapeditor.cpp	Sat Apr 09 22:50:08 2005 +0000
@@ -29,6 +29,7 @@
 #include "misc.h"
 #include "mainwindow.h"
 #include "extrainfodialog.h"
+#include "editlinkdialog.h"
 #include "settings.h"
 
 #include "icons/flag-note.xpm"
@@ -87,7 +88,6 @@
 extern QAction *actionEditSelectLast;
 extern QAction *actionEditLoadImage;
 extern QAction *actionEditToggleFloatExport;
-extern QAction *actionEditNoLink;
 
 extern QAction* actionFormatPickColor;
 extern QAction* actionFormatColorBranch;
@@ -120,6 +120,7 @@
 
 extern QPopupMenu *branchContextMenu;
 extern QPopupMenu *branchLinksContextMenu;
+extern QPopupMenu *branchLinksContextMenuDup;
 extern QPopupMenu *floatimageContextMenu;
 extern QPopupMenu *saveImageFormatMenu;
 extern QPopupMenu *exportImageFormatMenu;
@@ -521,6 +522,9 @@
 		if ( undoSelection &&
 			typeid(*undoSelection) == typeid(BranchObj) )
 			s+=((BranchObj*)(undoSelection))->saveToDir(tmpdir,prefix,offset);
+		else	
+			if (selection && typeid(*selection)==typeid(BranchObj))
+				s+=((BranchObj*)(selection))->saveToDir(tmpdir,prefix,offset);
 	}
 
 	// Save local settings
@@ -550,8 +554,8 @@
 	// the xml data itself is kept in memory in backupXML
 	// 
 	// For faster write/read of data, a part of the map can be
-	// written. Then the undoSelection will mark, which part of the
-	// map should be replaced if an undo is wanted later.
+	// written. Then the undoSelection will mark the part of the
+	// map which should be replaced if an undo is wanted later.
 
 	if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) ) 
 	{
@@ -773,7 +777,7 @@
 	if ( !file.open( IO_WriteOnly ) )
 	{
 		// This should neverever happen
-		QMessageBox::critical(0, tr("Critcal save error"),"MapEditor::save() Couldn't open "+file.name());
+		QMessageBox::critical(0, tr("Critcal Save error"),"MapEditor::save() Couldn't open "+file.name());
 		return 1;
 	}	
 
@@ -2241,12 +2245,15 @@
 			{
 				branchLinksContextMenu->clear();
 				branchLinksContextMenu->insertItem ("No link available");
+				branchLinksContextMenuDup->clear();
+				branchLinksContextMenuDup->insertItem ("No link available");
 				
 			} else
 			{
 				BranchObj *bot;
 				QString s;
 				branchLinksContextMenu->clear();
+				branchLinksContextMenuDup->clear();
 				for (int i=0; i<=bo->countLinks();i++)
 				{
 					bot=bo->linkTargetAt(i);
@@ -2256,6 +2263,7 @@
 						if (s.length()>25)
 							s=s.left(25)+"...";
 						branchLinksContextMenu->insertItem (s);
+						branchLinksContextMenuDup->insertItem (s);
 					}	
 				}
 			}
@@ -2686,6 +2694,21 @@
 	}
 }
 
+void MapEditor::editLink(int i)
+{
+	BranchObj *bo=((BranchObj*)(selection))->linkTargetAt(i);
+	if (bo) 
+	{
+		EditLinkDialog dia;
+		if (dia.exec() == QDialog::Accepted)
+		{
+			if (dia.deleteLink())
+				((BranchObj*)(selection))->deleteLinkAt(i);
+			setChanged();
+		}
+	}	
+}
+
 void MapEditor::testFunction()
 {
 	cout << "MapEditor::testFunction() called\n";
@@ -2719,6 +2742,7 @@
 				}	
 			}
 		}
+		popupLinks->move(p);
 		popupLinks->exec();
 		
 	}
@@ -3136,6 +3160,7 @@
 			((LinkableMapObj*)(selection))->unsetParObjTmp();
 
 
+			copyingObj=false;	
 			if (!dst ) 
 			{
 				if (copyingObj)
@@ -3149,7 +3174,6 @@
 						selectionLast=NULL;
 						selection->select();
 					}
-					copyingObj=false;	
 				}
 			} else
 			{
diff -r 31c6ce8efbc7 -r 6783e13bb05d mapeditor.h
--- a/mapeditor.h	Thu Mar 24 21:10:38 2005 +0000
+++ b/mapeditor.h	Sat Apr 09 22:50:08 2005 +0000
@@ -129,6 +129,7 @@
 public:	
     void importDir();
 	void followLink (int);
+	void editLink (int);
     void testFunction();				// FIXME just testing
 
 protected:
diff -r 31c6ce8efbc7 -r 6783e13bb05d tex/vym.tex
--- a/tex/vym.tex	Thu Mar 24 21:10:38 2005 +0000
+++ b/tex/vym.tex	Sat Apr 09 22:50:08 2005 +0000
@@ -713,6 +713,9 @@
 \begin{longtable}{|lcp{8cm}l|} \hline
 Version	&	&	Comment								& Date	\\ \hline \hline \endhead
 	\hline \endfoot
+1.6.3	& -	&	Bugfix: Saving of selection to a vym part (.vyp)	&2005-03-30\\
+		& - &	Bugfix: Closing the noteeditor by closing its window now
+				also toggles the responding toolbar button. &\\
 1.6.2	& -	&	Introduced Modifier modes: color, link, copy &2005-03-24\\
       & -	&	Linking branches is basically possible, though it can't
 				be edited/saved yet &\\
diff -r 31c6ce8efbc7 -r 6783e13bb05d texteditor.cpp
--- a/texteditor.cpp	Thu Mar 24 21:10:38 2005 +0000
+++ b/texteditor.cpp	Sat Apr 09 22:50:08 2005 +0000
@@ -50,6 +50,8 @@
 extern int statusbarTime;
 extern QSettings settings;
 
+extern QAction *actionViewToggleNoteEditor;
+
 using namespace std;
 
 
@@ -468,6 +470,8 @@
     if ( !e->isModified() ) 
 	{
 		ce->accept();	// TextEditor can be reopened with show()
+		actionViewToggleNoteEditor->setOn (false);
+		showwithmain=false;
 		return;
     }
 }
diff -r 31c6ce8efbc7 -r 6783e13bb05d version.h
--- a/version.h	Thu Mar 24 21:10:38 2005 +0000
+++ b/version.h	Sat Apr 09 22:50:08 2005 +0000
@@ -1,7 +1,7 @@
 #ifndef VERSION_H 
 #define VERSION_H
 
-#define __VYM_VERSION__ "1.6.2"
-#define __BUILD_DATE__ "March 24, 2005"
+#define __VYM_VERSION__ "1.6.3"
+#define __BUILD_DATE__ "April 11, 2005"
 
 #endif
diff -r 31c6ce8efbc7 -r 6783e13bb05d vym.pro
--- a/vym.pro	Thu Mar 24 21:10:38 2005 +0000
+++ b/vym.pro	Sat Apr 09 22:50:08 2005 +0000
@@ -2,10 +2,7 @@
 TRANSLATIONS += lang/vym_de.ts
 TRANSLATIONS += lang/vym_en.ts
 
-TEMPLATE	= app
-LANGUAGE	= C++
 
-CONFIG	+= qt warn_on release
 
 DESTROOT = /usr
 
@@ -25,6 +22,29 @@
 INSTALLS += demo
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+TEMPLATE	= app
+LANGUAGE	= C++
+
+CONFIG	+= qt warn_on release
+
+
 HEADERS	+= branchobj.h \
 	exports.h \
 	findwindow.h \
@@ -80,5 +100,6 @@
 FORMS	= exporthtmldialog.ui \
 	exportxhtmldialog.ui \
 	showtextdialog.ui \
-	extrainfodialog.ui
+	extrainfodialog.ui \
+	editlinkdialog.ui