Adding/moving MCO works again
authorinsilmaril
Mon, 04 Aug 2008 13:35:54 +0000
changeset 724cf14046909cd
parent 723 11f9124c1cca
child 725 7ea31701156e
Adding/moving MCO works again
demos/vym-projectplan.vym
linkablemapobj.cpp
mainwindow.cpp
     1.1 Binary file demos/vym-projectplan.vym has changed
     2.1 --- a/linkablemapobj.cpp	Mon Aug 04 10:43:06 2008 +0000
     2.2 +++ b/linkablemapobj.cpp	Mon Aug 04 13:35:54 2008 +0000
     2.3 @@ -3,7 +3,6 @@
     2.4  
     2.5  #include "linkablemapobj.h"
     2.6  #include "branchobj.h"
     2.7 -#include "mapeditor.h"		// FIXME needed?
     2.8  #include "vymmodel.h"
     2.9  
    2.10  using namespace std;
    2.11 @@ -669,10 +668,9 @@
    2.12  	// we want to block expensive repositioning, but just do it once at
    2.13  	// the end, thus check first:
    2.14  
    2.15 -	if (model->isRepositionBlocked()) return;	// FIXME better go to model directly, maybe via a signal
    2.16 +	if (model->isRepositionBlocked()) return;	
    2.17  	
    2.18 -	// Pass on the request to parental objects, if this hasn't been done yet
    2.19 -	
    2.20 +	// Pass on the request to parent objects, if this hasn't been done yet
    2.21  	if (parObj) 
    2.22  		parObj->forceReposition(); 
    2.23  	else 
     3.1 --- a/mainwindow.cpp	Mon Aug 04 10:43:06 2008 +0000
     3.2 +++ b/mainwindow.cpp	Mon Aug 04 13:35:54 2008 +0000
     3.3 @@ -1721,7 +1721,8 @@
     3.4  		me=(MapEditor*)tabWidget->page(i);
     3.5  		me->getModel()->unselect();
     3.6  	}	
     3.7 -	currentModel()->reselect();
     3.8 +	VymModel *m=currentModel();
     3.9 +	if (m) m->reselect();
    3.10  
    3.11  	// Update actions to in menus and toolbars according to editor
    3.12  	updateActions();
    3.13 @@ -1732,6 +1733,7 @@
    3.14  	VymModel *m=new VymModel;
    3.15  	models.append (m);
    3.16  	MapEditor* me = new MapEditor (m);
    3.17 +	me->setObjectName ("MapEditor");
    3.18  	QString fn="unnamed";
    3.19  	tabWidget->addTab (me,fn);
    3.20  	tabWidget->showPage(me);
    3.21 @@ -1740,7 +1742,7 @@
    3.22  	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
    3.23  	
    3.24  	// For the very first map we do not have flagrows yet...
    3.25 -	currentModel()->select("mc:");
    3.26 +	m->select("mc:");
    3.27  }
    3.28  
    3.29  void Main::fileNewCopy()
    3.30 @@ -2339,12 +2341,10 @@
    3.31  				return;
    3.32  			}
    3.33  		} 
    3.34 -		//me->closeMap(); FIXME should not be necessary any longer
    3.35  		me->close();
    3.36 -		tabWidget->removePage(m->getMapEditor());
    3.37 -		if (tabWidget->count()==0)
    3.38 -			actionFilePrint->setEnabled (false);
    3.39 -        delete me;
    3.40 +		tabWidget->removePage(me);
    3.41 +        delete me;	// FIXME if event was triggered _in_ ME this causes warning message
    3.42 +		updateActions();
    3.43  	}
    3.44  }
    3.45  
    3.46 @@ -2630,85 +2630,8 @@
    3.47  			m->select(prevSelection);
    3.48  		prevSelection="";
    3.49  	}
    3.50 -
    3.51 -/* FIXME old code, remove now
    3.52 -	// only called from editHeading(), so there is a currentME
    3.53 -	VymModel *m=currentModel();
    3.54 -	if (m)
    3.55 -	{
    3.56 -		m->setSelectionBlocked (false);
    3.57 -		QPoint p;	//Not used here, only to find out pos of branch
    3.58 -		bool ok;
    3.59 -		QString s=m->getHeading(ok,p);
    3.60 -
    3.61 -#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
    3.62 -#else
    3.63 -		if (ok && s!=lineedit->text())
    3.64 -			m->setHeading(lineedit->text());
    3.65 -			
    3.66 -		lineedit->releaseKeyboard();
    3.67 -		lineedit->hide();
    3.68 -		setFocus();
    3.69 -#endif	
    3.70 -		if (!actionSettingsAutoSelectNewBranch->isOn() && 
    3.71 -			!prevSelection.isEmpty()) 
    3.72 -			m->select(prevSelection);
    3.73 -		prevSelection="";
    3.74 -	}
    3.75 -*/
    3.76  }
    3.77  
    3.78 -/*
    3.79 -void Main::editHeading()
    3.80 -{
    3.81 -	MapEditor *me=currentMapEditor();
    3.82 -	VymModel *m=currentModel();
    3.83 -	if (me && m)
    3.84 -	{
    3.85 -		QString oldSel=m->getSelectString();
    3.86 -
    3.87 -		if (lineedit->isVisible())
    3.88 -			editHeadingFinished();
    3.89 -		else
    3.90 -		{
    3.91 -			bool ok;
    3.92 -			QPoint p;
    3.93 -			QString s=m->getHeading(ok,p);
    3.94 -
    3.95 -			if (ok)
    3.96 -			{
    3.97 -				m->setSelectionBlocked(true);
    3.98 -#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
    3.99 -				p=me->mapToGlobal (p);
   3.100 -				QDialog *d =new QDialog(NULL);
   3.101 -				QLineEdit *le=new QLineEdit (d);
   3.102 -				d->setWindowFlags (Qt::FramelessWindowHint);
   3.103 -				d->setGeometry(p.x(),p.y(),230,25);
   3.104 -				le->resize (d->width()-10,d->height());
   3.105 -				le->setText (s);
   3.106 -				le->selectAll();
   3.107 -				connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
   3.108 -				d->activateWindow();
   3.109 -				d->exec();
   3.110 -				m->setHeading (le->text());
   3.111 -				delete (le);
   3.112 -				delete (d);
   3.113 -				editHeadingFinished();
   3.114 -#else
   3.115 -				p=me->mapTo (this,p);
   3.116 -				lineedit->setGeometry(p.x(),p.y(),230,25);
   3.117 -				lineedit->setText(s);
   3.118 -				lineedit->setCursorPosition(1);
   3.119 -				lineedit->selectAll();
   3.120 -				lineedit->show();
   3.121 -				lineedit->grabKeyboard();
   3.122 -				lineedit->setFocus();
   3.123 -#endif
   3.124 -			}
   3.125 -		}
   3.126 -	}
   3.127 -}
   3.128 -*/	
   3.129  
   3.130  void Main::editAttributeFinished()
   3.131  {
   3.132 @@ -3490,60 +3413,80 @@
   3.133  void Main::updateActions()
   3.134  {
   3.135  	VymModel  *m =currentModel();
   3.136 -	if (!m) return;
   3.137 -
   3.138 -	historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
   3.139 +	LinkableMapObj *selection;
   3.140 +	if (m) 
   3.141 +	{
   3.142 +		// Printing
   3.143 +		actionFilePrint->setEnabled (true);
   3.144 +
   3.145 +		// Selection
   3.146 +		selection=m->getSelection();
   3.147 +
   3.148 +		// Link style in context menu
   3.149 +		switch (m->getMapLinkStyle())
   3.150 +		{
   3.151 +			case LinkableMapObj::Line: 
   3.152 +				actionFormatLinkStyleLine->setOn(true);
   3.153 +				break;
   3.154 +			case LinkableMapObj::Parabel:
   3.155 +				actionFormatLinkStyleParabel->setOn(true);
   3.156 +				break;
   3.157 +			case LinkableMapObj::PolyLine:	
   3.158 +				actionFormatLinkStylePolyLine->setOn(true);
   3.159 +				break;
   3.160 +			case LinkableMapObj::PolyParabel:	
   3.161 +				actionFormatLinkStylePolyParabel->setOn(true);
   3.162 +				break;
   3.163 +			default:
   3.164 +				break;
   3.165 +		}		
   3.166 +
   3.167 +		// Update colors
   3.168 +		QPixmap pix( 16, 16 );
   3.169 +		pix.fill( m->getMapBackgroundColor() );
   3.170 +		actionFormatBackColor->setIconSet( pix );
   3.171 +		pix.fill( m->getSelectionColor() );
   3.172 +		actionFormatSelectionColor->setIconSet( pix );
   3.173 +		pix.fill( m->getMapDefLinkColor() );
   3.174 +		actionFormatLinkColor->setIconSet( pix );
   3.175 +
   3.176 +		// History window
   3.177 +		historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
   3.178 +
   3.179 +	} else
   3.180 +	{
   3.181 +		// Printing
   3.182 +		actionFilePrint->setEnabled (false);
   3.183 +
   3.184 +		// Selection
   3.185 +		selection=NULL;
   3.186 +	}
   3.187  
   3.188  	// updateActions is also called when NoteEditor is closed
   3.189  	actionViewToggleNoteEditor->setOn (textEditor->isVisible());
   3.190  	actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
   3.191  	actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
   3.192  
   3.193 -	if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
   3.194 +	if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) 
   3.195  		actionFormatLinkColorHint->setOn(true);
   3.196  	else	
   3.197  		actionFormatLinkColorHint->setOn(false);
   3.198  
   3.199 -	switch (m->getMapLinkStyle())
   3.200 -	{
   3.201 -		case LinkableMapObj::Line: 
   3.202 -			actionFormatLinkStyleLine->setOn(true);
   3.203 -			break;
   3.204 -		case LinkableMapObj::Parabel:
   3.205 -			actionFormatLinkStyleParabel->setOn(true);
   3.206 -			break;
   3.207 -		case LinkableMapObj::PolyLine:	
   3.208 -			actionFormatLinkStylePolyLine->setOn(true);
   3.209 -			break;
   3.210 -		case LinkableMapObj::PolyParabel:	
   3.211 -			actionFormatLinkStylePolyParabel->setOn(true);
   3.212 -			break;
   3.213 -		default:
   3.214 -			break;
   3.215 -	}	
   3.216 -
   3.217 -	// Update colors
   3.218 -	QPixmap pix( 16, 16 );
   3.219 -    pix.fill( m->getMapBackgroundColor() );
   3.220 -    actionFormatBackColor->setIconSet( pix );
   3.221 -    pix.fill( m->getSelectionColor() );
   3.222 -    actionFormatSelectionColor->setIconSet( pix );
   3.223 -    pix.fill( m->getMapDefLinkColor() );
   3.224 -    actionFormatLinkColor->setIconSet( pix );
   3.225 -
   3.226 -
   3.227 -	actionFileSave->setEnabled( m->hasChanged() );
   3.228 -	if (m->isUndoAvailable())
   3.229 +
   3.230 +	if (m && m->hasChanged() )
   3.231 +		actionFileSave->setEnabled( true);
   3.232 +	else	
   3.233 +		actionFileSave->setEnabled( true);
   3.234 +	if (m && m->isUndoAvailable())
   3.235  		actionUndo->setEnabled( true);
   3.236  	else	
   3.237  		actionUndo->setEnabled( false);
   3.238  
   3.239 -	if (m->isRedoAvailable())
   3.240 +	if (m && m->isRedoAvailable())
   3.241  		actionRedo->setEnabled( true);
   3.242  	else	
   3.243  		actionRedo->setEnabled( false);
   3.244  
   3.245 -	LinkableMapObj *selection=m->getSelection();
   3.246  	if (selection)
   3.247  	{
   3.248  		if ( (typeid(*selection) == typeid(BranchObj)) || 
   3.249 @@ -3612,10 +3555,12 @@
   3.250  			else	
   3.251  				actionMoveDown->setEnabled (false);
   3.252  
   3.253 +			actionSortChildren->setEnabled (true);
   3.254  
   3.255  			actionToggleHideExport->setEnabled (true);	
   3.256  			actionToggleHideExport->setOn (bo->hideInExport() );	
   3.257  
   3.258 +			actionFileSave->setEnabled (true);	
   3.259  			actionCopy->setEnabled (true);	
   3.260  			actionCut->setEnabled (true);	
   3.261  			if (!clipboardEmpty)
   3.262 @@ -3653,6 +3598,8 @@
   3.263  
   3.264  	} else
   3.265  	{
   3.266 +		standardFlagsDefault->setEnabled (false);
   3.267 +		actionFileSave->setEnabled (false);	
   3.268  		actionCopy->setEnabled (false);	
   3.269  		actionCut->setEnabled (false);	
   3.270  		actionPaste->setEnabled (false);	
   3.271 @@ -3667,6 +3614,7 @@
   3.272  		actionDelete->setEnabled (false);
   3.273  		actionMoveUp->setEnabled (false);
   3.274  		actionMoveDown->setEnabled (false);
   3.275 +		actionSortChildren->setEnabled (false);
   3.276  		actionToggleHideExport->setEnabled (false);	
   3.277  	}	
   3.278  }