mainwindow.cpp
changeset 769 a6931cd6309a
parent 768 382a444f5b0c
child 770 57ce1ba6d1cb
     1.1 --- a/mainwindow.cpp	Thu May 14 12:42:58 2009 +0000
     1.2 +++ b/mainwindow.cpp	Fri May 15 15:22:15 2009 +0000
     1.3 @@ -228,6 +228,7 @@
     1.4  	restoreState (settings.value("/mainwindow/state",0).toByteArray());
     1.5  
     1.6  	updateGeometry();
     1.7 +
     1.8  }
     1.9  
    1.10  Main::~Main()
    1.11 @@ -882,52 +883,6 @@
    1.12  	actionListBranches.append(a);
    1.13  	actionDeleteChildren=a;
    1.14  
    1.15 -    // Shortcuts for navigating with cursor:
    1.16 -    a = new QAction(tr( "Select upper branch","Edit menu" ), this);
    1.17 -	a->setStatusTip ( tr( "Select upper branch" ));
    1.18 -	a->setShortcut (Qt::Key_Up );
    1.19 -	a->setShortcutContext (Qt::WindowShortcut);
    1.20 -	addAction (a);
    1.21 -    connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
    1.22 -    a = new QAction( tr( "Select lower branch","Edit menu" ),this);
    1.23 -	a->setStatusTip (tr( "Select lower branch" ));
    1.24 -	a->setShortcut ( Qt::Key_Down );
    1.25 -	a->setShortcutContext (Qt::WindowShortcut);
    1.26 -	addAction (a);
    1.27 -    connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
    1.28 -    a = new QAction(tr( "Select left branch","Edit menu" ), this);
    1.29 -	a->setStatusTip ( tr( "Select left branch" ));
    1.30 -	a->setShortcut (Qt::Key_Left );
    1.31 -	a->setShortcutContext (Qt::WindowShortcut);
    1.32 -	addAction (a);
    1.33 -    connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
    1.34 -    a = new QAction( tr( "Select child branch","Edit menu" ), this);
    1.35 -	a->setStatusTip (tr( "Select right branch" ));
    1.36 -	a->setShortcut (Qt::Key_Right);
    1.37 -	a->setShortcutContext (Qt::WindowShortcut);
    1.38 -	addAction (a);
    1.39 -    connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
    1.40 -    a = new QAction( tr( "Select first branch","Edit menu" ), this);
    1.41 -	a->setStatusTip (tr( "Select first branch" ));
    1.42 -	a->setShortcut (Qt::Key_Home );
    1.43 -	a->setShortcutContext (Qt::WindowShortcut);
    1.44 -	addAction (a);
    1.45 -	a->setEnabled (false);
    1.46 -	editMenu->addAction (a);
    1.47 -	actionListBranches.append(a);
    1.48 -	actionSelectFirst=a;
    1.49 -    connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
    1.50 -    a = new QAction( tr( "Select last branch","Edit menu" ),this);
    1.51 -	a->setStatusTip (tr( "Select last branch" ));
    1.52 -	a->setShortcut ( Qt::Key_End );
    1.53 -	a->setShortcutContext (Qt::WindowShortcut);
    1.54 -	addAction (a);
    1.55 -    connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
    1.56 -	a->setEnabled (false);
    1.57 -	editMenu->addAction (a);
    1.58 -	actionListBranches.append(a);
    1.59 -	actionSelectLast=a;
    1.60 -
    1.61      a = new QAction( tr( "Add Image...","Edit menu" ), this);
    1.62  	a->setStatusTip (tr( "Add Image" ));
    1.63      connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
    1.64 @@ -1766,24 +1721,19 @@
    1.65  	updateActions();
    1.66  }
    1.67  
    1.68 -VymView *Main::createView (VymModel *model)
    1.69 -{
    1.70 -	VymView *vm=new VymView (model);
    1.71 -	return vm;
    1.72 -}
    1.73 -
    1.74  void Main::fileNew()
    1.75  {
    1.76 -	VymModel *m=new VymModel;
    1.77 -	tabModel.append (m);
    1.78 -	//MapEditor* me = new MapEditor (m);
    1.79 -	//me->setObjectName ("MapEditor");
    1.80 -
    1.81 -	tabWidget->addTab (createView (m),tr("unnamed","MainWindow: name for new and empty file"));
    1.82 +	VymModel *vm=new VymModel;
    1.83 +	tabModel.append (vm);
    1.84 +
    1.85 +	VymView *vv=new VymView (vm);
    1.86 +	tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
    1.87  	tabWidget->setCurrentIndex (tabModel.count() );
    1.88 +	vv->initFocus();
    1.89 +
    1.90  	
    1.91  	// For the very first map we do not have flagrows yet...
    1.92 -	m->select("mc:");
    1.93 +	vm->select("mc:");
    1.94  }
    1.95  
    1.96  void Main::fileNewCopy()
    1.97 @@ -1860,10 +1810,12 @@
    1.98  		if ( lmode==NewMap && (!vm || !vm->isDefault() )  )
    1.99  		{
   1.100  			vm=new VymModel;
   1.101 +			VymView *vv=new VymView (vm);
   1.102  			tabModel.append (vm);
   1.103 -			tabWidget->addTab (createView (vm),fn);
   1.104 +			tabWidget->addTab (vv,fn);
   1.105  			tabIndex=tabWidget->count()-1;
   1.106  			tabWidget->setCurrentPage (tabIndex);
   1.107 +			vv->initFocus();
   1.108  		}
   1.109  		
   1.110  		// Check, if file exists (important for creating new files
   1.111 @@ -2965,43 +2917,6 @@
   1.112  		m->deleteSelection();
   1.113  }
   1.114  
   1.115 -void Main::editUpperBranch()
   1.116 -{
   1.117 -	VymModel *m=currentModel();
   1.118 -	if (m) m->selectUpperBranch();	// FIXME-3 check also lower... this probably should go into view...
   1.119 -}
   1.120 -
   1.121 -void Main::editLowerBranch()	// FIXME-3 check also lower... this probably should go into view...
   1.122 -
   1.123 -{
   1.124 -	VymModel *m=currentModel();
   1.125 -	if (m) m->selectLowerBranch();
   1.126 -}
   1.127 -
   1.128 -void Main::editLeftBranch()
   1.129 -{
   1.130 -	VymModel *m=currentModel();
   1.131 -	if (m) m->selectLeftBranch();
   1.132 -}
   1.133 -
   1.134 -void Main::editRightBranch()
   1.135 -{
   1.136 -	VymModel *m=currentModel();
   1.137 -	if (m) m->selectRightBranch();
   1.138 -}
   1.139 -
   1.140 -void Main::editFirstBranch()
   1.141 -{
   1.142 -	VymModel *m=currentModel();
   1.143 -	if (m) m->selectFirstBranch();
   1.144 -}
   1.145 -
   1.146 -void Main::editLastBranch()
   1.147 -{
   1.148 -	VymModel *m=currentModel();
   1.149 -	if (m) m->selectLastBranch();
   1.150 -}
   1.151 -
   1.152  void Main::editLoadImage()
   1.153  {
   1.154  	VymModel *m=currentModel();
   1.155 @@ -3693,14 +3608,13 @@
   1.156  void Main::testFunction1()
   1.157  {
   1.158  	if (!currentMapEditor()) return;
   1.159 -		currentMapEditor()->testFunction1();
   1.160 -	//editAttribute();
   1.161 +	currentMapEditor()->testFunction1();
   1.162  }
   1.163  
   1.164  void Main::testFunction2()
   1.165  {
   1.166  	if (!currentMapEditor()) return;
   1.167 -	currentMapEditor()->testFunction2();
   1.168 +	currentMapEditor()->setFocus();
   1.169  }
   1.170  
   1.171  void Main::testCommand()