mapeditor.cpp
changeset 404 53efc2562a7d
parent 401 f364b13047ba
child 406 1c8ff1928b97
     1.1 --- a/mapeditor.cpp	Mon Nov 20 12:12:00 2006 +0000
     1.2 +++ b/mapeditor.cpp	Mon Nov 20 12:12:02 2006 +0000
     1.3 @@ -46,6 +46,9 @@
     1.4  extern Settings settings;
     1.5  extern ImageIO imageIO;
     1.6  
     1.7 +extern QString vymName;
     1.8 +extern QString vymVersion;
     1.9 +
    1.10  extern QString iconPath;
    1.11  extern QDir vymBaseDir;
    1.12  extern QDir lastImageDir;
    1.13 @@ -87,16 +90,10 @@
    1.14  	linkstyle=StylePolyParabel;
    1.15  
    1.16  	// Create bitmap cursors, platform dependant
    1.17 -	// FIXME should now work also on Mac...
    1.18 -	//#if defined(Q_OS_MACX)
    1.19 -	//	HandOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png"),1,1 );		
    1.20 -	//	PickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 ); 
    1.21 -	//#else
    1.22 -		HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);		
    1.23 -		PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); 
    1.24 -		CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 5,5 ); 
    1.25 -		XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 5,27 ); 
    1.26 -	//#endif
    1.27 +	HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);		
    1.28 +	PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); 
    1.29 +	CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 1,1 ); 
    1.30 +	XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 1,7 ); 
    1.31  
    1.32  	setFocusPolicy (Qt::StrongFocus);
    1.33  
    1.34 @@ -146,10 +143,6 @@
    1.35  
    1.36  	mapCenter->reposition();	//	for positioning heading
    1.37  
    1.38 -	// Initialize history window;
    1.39 -	historyWindow.setME(this);
    1.40 -	historyWindow.setStepsTotal(stepsTotal);
    1.41 -	historyWindow.update (undoSet);
    1.42  }
    1.43  
    1.44  MapEditor::~MapEditor()
    1.45 @@ -299,7 +292,7 @@
    1.46  	if (linkcolorhint==HeadingColor) 
    1.47  		colhint=attribut("linkColorHint","HeadingColor");
    1.48  
    1.49 -	QString mapAttr=attribut("version",__VYM_VERSION);
    1.50 +	QString mapAttr=attribut("version",vymVersion);
    1.51  	if (!saveSel || saveSel==mapCenter)
    1.52  		mapAttr+= attribut("author",mapCenter->getAuthor()) +
    1.53  				  attribut("comment",mapCenter->getComment()) +
    1.54 @@ -487,7 +480,7 @@
    1.55  	undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom);
    1.56  	undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection);
    1.57  	undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment);
    1.58 -	undoSet.setEntry (QString("/history/version"),__VYM_VERSION);
    1.59 +	undoSet.setEntry (QString("/history/version"),vymVersion);
    1.60  	undoSet.writeSettings(histPath);
    1.61  
    1.62  	/* TODO remove after testing
    1.63 @@ -506,7 +499,7 @@
    1.64  	if (saveSel) cout << "    saveSel="<<saveSel->getSelectString().ascii()<<endl;
    1.65  	cout << "    ---------------------------"<<endl;
    1.66  
    1.67 -	historyWindow.update (undoSet);
    1.68 +	mainWindow->updateHistory (undoSet);
    1.69  	setChanged();
    1.70  	updateActions();
    1.71  }
    1.72 @@ -962,14 +955,6 @@
    1.73  	} 
    1.74  }
    1.75  
    1.76 -void MapEditor::toggleHistoryWindow()
    1.77 -{
    1.78 -	if (historyWindow.isVisible())
    1.79 -		historyWindow.hide();
    1.80 -	else	
    1.81 -		historyWindow.show();
    1.82 -}
    1.83 -
    1.84  
    1.85  bool MapEditor::isDefault()
    1.86  {
    1.87 @@ -1033,9 +1018,6 @@
    1.88  
    1.89  		// Forget the .vym (or .xml) for name of map
    1.90  		mapName=fileName.left(fileName.findRev(".",-1,true) );
    1.91 -
    1.92 -		// Adjust history window
    1.93 -		historyWindow.setCaption (__VYM " - " +tr("History for ")+fileName);
    1.94  	}
    1.95  }
    1.96  
    1.97 @@ -1493,7 +1475,7 @@
    1.98  
    1.99  	if (!checkVersion(version))
   1.100  		QMessageBox::warning(0,tr("Warning"),
   1.101 -			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(__VYM_VERSION));
   1.102 +			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
   1.103  
   1.104  
   1.105  	// Find out current undo directory
   1.106 @@ -1514,7 +1496,6 @@
   1.107  	cout << "    ---------------------------"<<endl<<endl;
   1.108  
   1.109  	// select  object before redo
   1.110 -	// FIXME better give up if no selection there...
   1.111  	if (!redoSelection.isEmpty())
   1.112  		select (redoSelection);
   1.113  
   1.114 @@ -1529,16 +1510,16 @@
   1.115  	undoSet.setEntry ("/history/curStep",QString::number(curStep));
   1.116  	undoSet.writeSettings(histPath);
   1.117  
   1.118 -	historyWindow.update (undoSet);
   1.119 +	mainWindow->updateHistory (undoSet);
   1.120  	updateActions();
   1.121  
   1.122  	/* TODO remove testing
   1.123 -*/
   1.124  	cout << "ME::redo() end\n";
   1.125  	cout << "    undosAvail="<<undosAvail<<endl;
   1.126  	cout << "    redosAvail="<<redosAvail<<endl;
   1.127  	cout << "       curStep="<<curStep<<endl;
   1.128  	cout << "    ---------------------------"<<endl<<endl;
   1.129 +	*/
   1.130  
   1.131  
   1.132  }
   1.133 @@ -1572,7 +1553,7 @@
   1.134  
   1.135  	if (!checkVersion(version))
   1.136  		QMessageBox::warning(0,tr("Warning"),
   1.137 -			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(__VYM_VERSION));
   1.138 +			tr("Version %1 of saved undo/redo data\ndoes not match current vym version %2.").arg(version).arg(vymVersion));
   1.139  
   1.140  	// Find out current undo directory
   1.141  	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep));
   1.142 @@ -1605,19 +1586,19 @@
   1.143  
   1.144  	blockSaveState=false;
   1.145  /* TODO remove testing
   1.146 -*/
   1.147  	cout << "ME::undo() end\n";
   1.148  	cout << "    undosAvail="<<undosAvail<<endl;
   1.149  	cout << "    redosAvail="<<redosAvail<<endl;
   1.150  	cout << "       curStep="<<curStep<<endl;
   1.151  	cout << "    ---------------------------"<<endl<<endl;
   1.152 +*/
   1.153  
   1.154  	undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail));
   1.155  	undoSet.setEntry ("/history/redosAvail",QString::number(redosAvail));
   1.156  	undoSet.setEntry ("/history/curStep",QString::number(curStep));
   1.157  	undoSet.writeSettings(histPath);
   1.158  
   1.159 -	historyWindow.update (undoSet);
   1.160 +	mainWindow->updateHistory (undoSet);
   1.161  	updateActions();
   1.162  }
   1.163  
   1.164 @@ -1629,14 +1610,12 @@
   1.165  		return false;
   1.166  }
   1.167  
   1.168 -void MapEditor::gotoStep (int i)
   1.169 +void MapEditor::gotoHistoryStep (int i)
   1.170  {
   1.171  	// Restore variables
   1.172  	int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail"));
   1.173  	int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
   1.174  
   1.175 -	cout << "ME::goto "<<i<<endl;
   1.176 -	
   1.177  	if (i<0) i=undosAvail+redosAvail;
   1.178  
   1.179  	// Clicking above current step makes us undo things
   1.180 @@ -2759,11 +2738,13 @@
   1.181  			typeid(*selection) == typeid(MapCenterObj)) )
   1.182  	{		
   1.183  		BranchObj *bo=(BranchObj*)selection;
   1.184 -		Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Link to another map"));
   1.185 -		fd->addFilter (QString (tr("vym map") + " (*.vym)"));
   1.186 -		fd->setCaption(__VYM " - " +tr("Link to another map"));
   1.187 +		QStringList filters;
   1.188 +		filters <<"VYM map (*.vym)";
   1.189 +		QFileDialog *fd=new QFileDialog( this,vymName+" - " +tr("Link to another map"));
   1.190 +		fd->setFilters (filters);
   1.191 +		fd->setCaption(vymName+" - " +tr("Link to another map"));
   1.192  		if (! bo->getVymLink().isEmpty() )
   1.193 -			fd->setSelection( bo->getVymLink() );
   1.194 +			fd->selectFile( bo->getVymLink() );
   1.195  		fd->show();
   1.196  
   1.197  		QString fn;
   1.198 @@ -3163,7 +3144,7 @@
   1.199  		fd->setContentsPreviewEnabled( TRUE );
   1.200  		fd->setContentsPreview( p, p );
   1.201  		fd->setPreviewMode( Q3FileDialog::Contents );
   1.202 -		fd->setCaption(__VYM " - " +tr("Load image"));
   1.203 +		fd->setCaption(vymName+" - " +tr("Load image"));
   1.204  		fd->setDir (lastImageDir);
   1.205  		fd->show();
   1.206  
   1.207 @@ -3210,7 +3191,7 @@
   1.208  		FloatImageObj *fio=((FloatImageObj*)selection);
   1.209  		QFileDialog *fd=new QFileDialog( this);
   1.210  		fd->setFilters (imageIO.getFilters());
   1.211 -		fd->setCaption(__VYM " - " +tr("Save image"));
   1.212 +		fd->setCaption(vymName+" - " +tr("Save image"));
   1.213  		fd->setFileMode( QFileDialog::AnyFile );
   1.214  		fd->setDirectory (lastImageDir);
   1.215  //		fd->setSelection (fio->getOriginalFilename());
   1.216 @@ -3221,7 +3202,7 @@
   1.217  		{
   1.218  			if (QFile (fd->selectedFile()).exists() )
   1.219  			{
   1.220 -				QMessageBox mb( __VYM,
   1.221 +				QMessageBox mb( vymName,
   1.222  					tr("The file %1 exists already.\n"
   1.223  					"Do you want to overwrite it?").arg(fd->selectedFile()),
   1.224  				QMessageBox::Warning,
   1.225 @@ -3344,10 +3325,12 @@
   1.226  		(typeid(*selection) == typeid(BranchObj)) || 
   1.227  		(typeid(*selection) == typeid(MapCenterObj))  )
   1.228  	{
   1.229 -		Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Choose directory structure to import"));
   1.230 -		fd->setMode (Q3FileDialog::DirectoryOnly);
   1.231 -		fd->addFilter (QString (tr("vym map") + " (*.vym)"));
   1.232 -		fd->setCaption(__VYM " - " +tr("Choose directory structure to import"));
   1.233 +		QStringList filters;
   1.234 +		filters <<"VYM map (*.vym)";
   1.235 +		QFileDialog *fd=new QFileDialog( this,vymName+ " - " +tr("Choose directory structure to import"));
   1.236 +		fd->setMode (QFileDialog::DirectoryOnly);
   1.237 +		fd->setFilters (filters);
   1.238 +		fd->setCaption(vymName+" - " +tr("Choose directory structure to import"));
   1.239  		fd->show();
   1.240  
   1.241  		QString fn;