mainwindow.cpp
changeset 491 c58b3973337c
parent 487 8fca3a710dc4
child 494 eea7fa702968
     1.1 --- a/mainwindow.cpp	Thu May 17 20:19:03 2007 +0000
     1.2 +++ b/mainwindow.cpp	Thu May 17 20:19:03 2007 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4  extern Main *mainWindow;
     1.5  extern QString tmpVymDir;
     1.6  extern QString clipboardDir;
     1.7 +extern QString clipboardFile;
     1.8  extern bool clipboardEmpty;
     1.9  extern int statusbarTime;
    1.10  extern FlagRowObj* standardFlagsDefault;
    1.11 @@ -85,6 +86,7 @@
    1.12  
    1.13  	// Create direcctory for clipboard
    1.14  	clipboardDir=tmpVymDir+"/clipboard";
    1.15 +	clipboardFile="part";
    1.16  	QDir d(clipboardDir);
    1.17  	d.mkdir (clipboardDir,true);
    1.18  	makeSubDirs (clipboardDir);
    1.19 @@ -197,6 +199,7 @@
    1.20  	settings.setValue( "/version/version", vymVersion );
    1.21  	settings.setValue( "/version/builddate", vymBuildDate );
    1.22  
    1.23 +	settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
    1.24  	settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
    1.25  	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
    1.26  	settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
    1.27 @@ -252,13 +255,19 @@
    1.28  	tb->setObjectName ("mapTB");
    1.29  
    1.30      QAction *a;
    1.31 -    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
    1.32 +    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
    1.33  	a->setStatusTip ( tr( "New map","Status tip File menu" ) );
    1.34  	a->setShortcut ( Qt::CTRL + Qt::Key_N );		//New map
    1.35      a->addTo( tb );
    1.36  	fileMenu->addAction (a);
    1.37      connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
    1.38  	
    1.39 +    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&Copy to new map","File menu" ),this);
    1.40 +	a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
    1.41 +	a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N );		//New map
    1.42 +	fileMenu->addAction (a);
    1.43 +    connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
    1.44 +	
    1.45      a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
    1.46  	a->setStatusTip (tr( "Open","Status tip File menu" ) );
    1.47  	a->setShortcut ( Qt::CTRL + Qt::Key_O );		//Open map
    1.48 @@ -1629,7 +1638,7 @@
    1.49  
    1.50  void Main::showEvent (QShowEvent * )
    1.51  {
    1.52 -	//FIXME if (textEditor->showWithMain()) textEditor->showNormal();
    1.53 +	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
    1.54  }
    1.55  
    1.56  bool Main::reallyWriteDirectory(const QString &dir)
    1.57 @@ -1715,6 +1724,29 @@
    1.58  	me->select("mc:");
    1.59  }
    1.60  
    1.61 +void Main::fileNewCopy()
    1.62 +{
    1.63 +	QString fn="unnamed";
    1.64 +	MapEditor* oldME =currentMapEditor();
    1.65 +	if (oldME)
    1.66 +	{
    1.67 +		oldME->copy();
    1.68 +		MapEditor* newME = new MapEditor ( NULL);
    1.69 +		if (newME)
    1.70 +		{
    1.71 +			tabWidget->addTab (newME,fn);
    1.72 +			tabWidget->showPage(newME);
    1.73 +			newME->viewport()->setFocus();
    1.74 +			newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
    1.75 +			newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
    1.76 +			// For the very first map we do not have flagrows yet...
    1.77 +			newME->select("mc:");
    1.78 +			newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
    1.79 +		}
    1.80 +
    1.81 +	}
    1.82 +}
    1.83 +
    1.84  ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
    1.85  {
    1.86  	ErrorCode err=success;
    1.87 @@ -2698,6 +2730,7 @@
    1.88  	MapEditor *me=currentMapEditor();
    1.89  	if (me)
    1.90  	{
    1.91 +		me->setStateEditHeading (false);
    1.92  		QPoint p;	//Not used here, only to find out pos of branch
    1.93  		bool ok;
    1.94  		QString s=me->getHeading(ok,p);
    1.95 @@ -2733,6 +2766,7 @@
    1.96  
    1.97  			if (ok)
    1.98  			{
    1.99 +				me->setStateEditHeading (true);
   1.100  #if defined(Q_OS_MACX)
   1.101  				p=currentMapEditor()->mapTo (this,p);
   1.102  				QDialog *d =new QDialog(NULL);
   1.103 @@ -3346,7 +3380,7 @@
   1.104  	MapEditor *me=currentMapEditor();
   1.105  	if (!me) return;
   1.106  
   1.107 -	historyWindow->setCaption (vymName + " - " +tr("History for %1").arg(currentMapEditor()->getFileName(),"Window Caption"));
   1.108 +	historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
   1.109  
   1.110  	// updateActions is also called when NoteEditor is closed
   1.111  	actionViewToggleNoteEditor->setOn (textEditor->isVisible());