mapeditor.cpp
changeset 94 6783e13bb05d
parent 93 31c6ce8efbc7
child 95 f688a9913724
     1.1 --- a/mapeditor.cpp	Thu Mar 24 21:10:38 2005 +0000
     1.2 +++ b/mapeditor.cpp	Sat Apr 09 22:50:08 2005 +0000
     1.3 @@ -29,6 +29,7 @@
     1.4  #include "misc.h"
     1.5  #include "mainwindow.h"
     1.6  #include "extrainfodialog.h"
     1.7 +#include "editlinkdialog.h"
     1.8  #include "settings.h"
     1.9  
    1.10  #include "icons/flag-note.xpm"
    1.11 @@ -87,7 +88,6 @@
    1.12  extern QAction *actionEditSelectLast;
    1.13  extern QAction *actionEditLoadImage;
    1.14  extern QAction *actionEditToggleFloatExport;
    1.15 -extern QAction *actionEditNoLink;
    1.16  
    1.17  extern QAction* actionFormatPickColor;
    1.18  extern QAction* actionFormatColorBranch;
    1.19 @@ -120,6 +120,7 @@
    1.20  
    1.21  extern QPopupMenu *branchContextMenu;
    1.22  extern QPopupMenu *branchLinksContextMenu;
    1.23 +extern QPopupMenu *branchLinksContextMenuDup;
    1.24  extern QPopupMenu *floatimageContextMenu;
    1.25  extern QPopupMenu *saveImageFormatMenu;
    1.26  extern QPopupMenu *exportImageFormatMenu;
    1.27 @@ -521,6 +522,9 @@
    1.28  		if ( undoSelection &&
    1.29  			typeid(*undoSelection) == typeid(BranchObj) )
    1.30  			s+=((BranchObj*)(undoSelection))->saveToDir(tmpdir,prefix,offset);
    1.31 +		else	
    1.32 +			if (selection && typeid(*selection)==typeid(BranchObj))
    1.33 +				s+=((BranchObj*)(selection))->saveToDir(tmpdir,prefix,offset);
    1.34  	}
    1.35  
    1.36  	// Save local settings
    1.37 @@ -550,8 +554,8 @@
    1.38  	// the xml data itself is kept in memory in backupXML
    1.39  	// 
    1.40  	// For faster write/read of data, a part of the map can be
    1.41 -	// written. Then the undoSelection will mark, which part of the
    1.42 -	// map should be replaced if an undo is wanted later.
    1.43 +	// written. Then the undoSelection will mark the part of the
    1.44 +	// map which should be replaced if an undo is wanted later.
    1.45  
    1.46  	if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) ) 
    1.47  	{
    1.48 @@ -773,7 +777,7 @@
    1.49  	if ( !file.open( IO_WriteOnly ) )
    1.50  	{
    1.51  		// This should neverever happen
    1.52 -		QMessageBox::critical(0, tr("Critcal save error"),"MapEditor::save() Couldn't open "+file.name());
    1.53 +		QMessageBox::critical(0, tr("Critcal Save error"),"MapEditor::save() Couldn't open "+file.name());
    1.54  		return 1;
    1.55  	}	
    1.56  
    1.57 @@ -2241,12 +2245,15 @@
    1.58  			{
    1.59  				branchLinksContextMenu->clear();
    1.60  				branchLinksContextMenu->insertItem ("No link available");
    1.61 +				branchLinksContextMenuDup->clear();
    1.62 +				branchLinksContextMenuDup->insertItem ("No link available");
    1.63  				
    1.64  			} else
    1.65  			{
    1.66  				BranchObj *bot;
    1.67  				QString s;
    1.68  				branchLinksContextMenu->clear();
    1.69 +				branchLinksContextMenuDup->clear();
    1.70  				for (int i=0; i<=bo->countLinks();i++)
    1.71  				{
    1.72  					bot=bo->linkTargetAt(i);
    1.73 @@ -2256,6 +2263,7 @@
    1.74  						if (s.length()>25)
    1.75  							s=s.left(25)+"...";
    1.76  						branchLinksContextMenu->insertItem (s);
    1.77 +						branchLinksContextMenuDup->insertItem (s);
    1.78  					}	
    1.79  				}
    1.80  			}
    1.81 @@ -2686,6 +2694,21 @@
    1.82  	}
    1.83  }
    1.84  
    1.85 +void MapEditor::editLink(int i)
    1.86 +{
    1.87 +	BranchObj *bo=((BranchObj*)(selection))->linkTargetAt(i);
    1.88 +	if (bo) 
    1.89 +	{
    1.90 +		EditLinkDialog dia;
    1.91 +		if (dia.exec() == QDialog::Accepted)
    1.92 +		{
    1.93 +			if (dia.deleteLink())
    1.94 +				((BranchObj*)(selection))->deleteLinkAt(i);
    1.95 +			setChanged();
    1.96 +		}
    1.97 +	}	
    1.98 +}
    1.99 +
   1.100  void MapEditor::testFunction()
   1.101  {
   1.102  	cout << "MapEditor::testFunction() called\n";
   1.103 @@ -2719,6 +2742,7 @@
   1.104  				}	
   1.105  			}
   1.106  		}
   1.107 +		popupLinks->move(p);
   1.108  		popupLinks->exec();
   1.109  		
   1.110  	}
   1.111 @@ -3136,6 +3160,7 @@
   1.112  			((LinkableMapObj*)(selection))->unsetParObjTmp();
   1.113  
   1.114  
   1.115 +			copyingObj=false;	
   1.116  			if (!dst ) 
   1.117  			{
   1.118  				if (copyingObj)
   1.119 @@ -3149,7 +3174,6 @@
   1.120  						selectionLast=NULL;
   1.121  						selection->select();
   1.122  					}
   1.123 -					copyingObj=false;	
   1.124  				}
   1.125  			} else
   1.126  			{