mainwindow.cpp
changeset 753 25a77484ec72
parent 749 9ff332964015
child 754 db0ec4bcf416
     1.1 --- a/mainwindow.cpp	Thu Apr 02 09:57:47 2009 +0000
     1.2 +++ b/mainwindow.cpp	Tue Apr 07 16:15:53 2009 +0000
     1.3 @@ -541,7 +541,7 @@
     1.4  	editMenu->addAction (a);
     1.5  	actionPaste=a;
     1.6  
     1.7 -/*
     1.8 +/*	FIXME-5
     1.9      // Shortcuts to modify heading:
    1.10      a = new QAction(tr( "Edit heading","Edit menu" ),this);
    1.11  	a->setStatusTip ( tr( "edit Heading" ));
    1.12 @@ -579,8 +579,12 @@
    1.13  	actionDelete=a;
    1.14      
    1.15      // Shortcut to add mapcenter
    1.16 -	a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
    1.17 +	a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
    1.18 +	a->setShortcut ( Qt::Key_M);	
    1.19 +	a->setShortcutContext (Qt::WindowShortcut);
    1.20      connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
    1.21 +	//actionListBranches.append(a);
    1.22 +	tb->addAction (a);
    1.23  	actionAddMapCenter = a;
    1.24  
    1.25  
    1.26 @@ -1590,6 +1594,7 @@
    1.27  		// Submenu "Add"
    1.28  		branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
    1.29  		branchAddContextMenu->addAction (actionPaste );
    1.30 +		branchAddContextMenu->addAction ( actionAddMapCenter );
    1.31  		branchAddContextMenu->addAction ( actionAddBranch );
    1.32  		branchAddContextMenu->addAction ( actionAddBranchBefore );
    1.33  		branchAddContextMenu->addAction ( actionAddBranchAbove);
    1.34 @@ -1660,8 +1665,7 @@
    1.35  	
    1.36  	// Context menu for canvas
    1.37  	canvasContextMenu =new QMenu (this);
    1.38 -	if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) 
    1.39 -		actionAddMapCenter->addTo( canvasContextMenu );
    1.40 +	actionAddMapCenter->addTo( canvasContextMenu );
    1.41  	actionMapInfo->addTo( canvasContextMenu );
    1.42  	canvasContextMenu->insertSeparator();	
    1.43  	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
    1.44 @@ -2496,10 +2500,10 @@
    1.45  	if (m)
    1.46  	{
    1.47  		bool cs=false;
    1.48 -		BranchObj *bo=m->findText(s, cs);
    1.49 -		if (bo)
    1.50 +		BranchItem *bi=m->findText(s, cs);
    1.51 +		if (bi)
    1.52  		{	
    1.53 -			statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
    1.54 +			statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
    1.55  		} else
    1.56  		{
    1.57  			QMessageBox::information( findWindow, tr( "VYM -Information:" ),
    1.58 @@ -2935,6 +2939,7 @@
    1.59  	VymModel *m=currentModel();
    1.60  	if (m)
    1.61  	{
    1.62 +		cout <<"Main::editAddMapCenter\n";
    1.63  		m->addMapCenter ();
    1.64  	}	
    1.65  }
    1.66 @@ -2944,12 +2949,10 @@
    1.67  	VymModel *m=currentModel();
    1.68  	if (m)
    1.69  	{
    1.70 -		BranchObj *bo=m->getSelectedBranch();
    1.71 -		prevSelection=m->getSelectString(bo);
    1.72 -		BranchObj *newbo=m->addNewBranch(0);
    1.73 -
    1.74 -		if (newbo) 
    1.75 -			m->select (newbo);
    1.76 +		BranchItem *bi=m->createBranch();
    1.77 +
    1.78 +		if (bi) 
    1.79 +			m->select (bi);
    1.80  		else
    1.81  			return;
    1.82  
    1.83 @@ -2971,18 +2974,17 @@
    1.84  	VymModel *m=currentModel();
    1.85  	if (m)
    1.86  	{
    1.87 -		BranchObj *bo=m->getSelectedBranch();
    1.88 -		BranchObj *newbo=m->addNewBranchBefore();
    1.89 -
    1.90 -		if (newbo) 
    1.91 -			m->select (newbo);
    1.92 +		BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranchBefore();
    1.93 +
    1.94 +		if (bi) 
    1.95 +			m->select (bi);
    1.96  		else
    1.97  			return;
    1.98  
    1.99  		if (actionSettingsAutoEditNewBranch->isOn())
   1.100  		{
   1.101  			if (!actionSettingsAutoSelectNewBranch->isOn())
   1.102 -				prevSelection=m->getSelectString(bo); 
   1.103 +				prevSelection=m->getSelectString(bi); 
   1.104  			currentMapEditor()->editHeading();
   1.105  		}
   1.106  	}	
   1.107 @@ -2993,18 +2995,18 @@
   1.108  	VymModel *m=currentModel();
   1.109  	if ( m)
   1.110  	{
   1.111 -		BranchObj *bo=m->getSelectedBranch();
   1.112 -		BranchObj *newbo=m->addNewBranch (-1);
   1.113 -
   1.114 -		if (newbo) 
   1.115 -			m->select (newbo);
   1.116 +		BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranch (-1);
   1.117 +
   1.118 +
   1.119 +		if (bi) 
   1.120 +			m->select (bi);
   1.121  		else
   1.122  			return;
   1.123  
   1.124  		if (actionSettingsAutoEditNewBranch->isOn())
   1.125  		{
   1.126  			if (!actionSettingsAutoSelectNewBranch->isOn())
   1.127 -				prevSelection=m->getSelectString (bo);	
   1.128 +				prevSelection=m->getSelectString (bi);	
   1.129  			currentMapEditor()->editHeading();
   1.130  		}
   1.131  	}	
   1.132 @@ -3015,18 +3017,17 @@
   1.133  	VymModel *m=currentModel();
   1.134  	if (m)
   1.135  	{
   1.136 -		BranchObj *bo=m->getSelectedBranch();
   1.137 -		BranchObj *newbo=m->addNewBranch (1);
   1.138 -
   1.139 -		if (newbo) 
   1.140 -			m->select (newbo);
   1.141 +		BranchItem *bi=m->createBranch();//FIXME-1 *newbo=m->addNewBranch (1);
   1.142 +
   1.143 +		if (bi) 
   1.144 +			m->select (bi);
   1.145  		else
   1.146  			return;
   1.147  
   1.148  		if (actionSettingsAutoEditNewBranch->isOn())
   1.149  		{
   1.150  			if (!actionSettingsAutoSelectNewBranch->isOn())
   1.151 -				prevSelection=m->getSelectString(bo);
   1.152 +				prevSelection=m->getSelectString(bi);
   1.153  			currentMapEditor()->editHeading();
   1.154  		}
   1.155  	}	
   1.156 @@ -3474,9 +3475,9 @@
   1.157  }
   1.158  */
   1.159  
   1.160 -void Main::updateContent (QModelIndex index )
   1.161 +void Main::updateNoteEditor(QModelIndex index )
   1.162  {
   1.163 -	cout << "Main::updateContent model="<<sender();
   1.164 +	cout << "Main::updateNoteEditor model="<<sender();
   1.165  	TreeItem *ti=((VymModel*)sender())->getItem(index);
   1.166  	cout << "  item="<<ti->getHeading().toStdString()<<" ("<<ti<<")"<<endl;
   1.167  	textEditor->setNote (ti->getNoteObj() );
   1.168 @@ -3510,14 +3511,15 @@
   1.169  			textEditor->setInactive();
   1.170  		}
   1.171  
   1.172 -		// Show URL and link in statusbar
   1.173 +		// Show URL and link in statusbar	// FIXME-2
   1.174 +		/*
   1.175  		QString status;
   1.176  		QString s=model->getURL();
   1.177  		if (!s.isEmpty() ) status+="URL: "+s+"  ";
   1.178  		s=model->getVymLink();
   1.179  		if (!s.isEmpty() ) status+="Link: "+s;
   1.180  		if (!status.isEmpty() ) statusMessage (status);
   1.181 -
   1.182 +*/
   1.183  
   1.184  		// Update Toolbar // FIXME-1, was so far in BranchObj
   1.185  		//updateFlagsToolbar();
   1.186 @@ -3604,13 +3606,12 @@
   1.187  	else	
   1.188  		actionRedo->setEnabled( false);
   1.189  
   1.190 -	if (selection)
   1.191 +	TreeItem *selti=m->getSelectedItem();
   1.192 +	BranchItem *selbi=m->getSelectedBranchItem();
   1.193 +	if (selti)
   1.194  	{
   1.195 -		if ( (typeid(*selection) == typeid(BranchObj)) || 
   1.196 -			(typeid(*selection) == typeid(MapCenterObj))  )
   1.197 +		if (selbi)
   1.198  		{
   1.199 -			BranchItem *bi=(BranchItem*)(selection->getTreeItem() );
   1.200 -			BranchObj *bo=(BranchObj*)selection;
   1.201  			// Take care of links  // FIXME-1
   1.202  			/*
   1.203  			if (bo->countXLinks()==0)
   1.204 @@ -3641,12 +3642,12 @@
   1.205  			standardFlagsDefault->setEnabled (true);
   1.206  
   1.207  			actionToggleScroll->setEnabled (true);
   1.208 -			if ( bi->isScrolled() )
   1.209 +			if ( selbi->isScrolled() )
   1.210  				actionToggleScroll->setOn(true);
   1.211  			else	
   1.212  				actionToggleScroll->setOn(false);
   1.213  
   1.214 -			if ( bo->getURL().isEmpty() )
   1.215 +/* FIXME-1 if ( selti->getURL().isEmpty() )
   1.216  			{
   1.217  				actionOpenURL->setEnabled (false);
   1.218  				actionOpenURLTab->setEnabled (false);
   1.219 @@ -3656,7 +3657,7 @@
   1.220  				actionOpenURL->setEnabled (true);
   1.221  				actionOpenURLTab->setEnabled (true);
   1.222  			}
   1.223 -			if ( bo->getVymLink().isEmpty() )
   1.224 +			if ( selti->getVymLink().isEmpty() )
   1.225  			{
   1.226  				actionOpenVymLink->setEnabled (false);
   1.227  				actionDeleteVymLink->setEnabled (false);
   1.228 @@ -3665,20 +3666,20 @@
   1.229  				actionOpenVymLink->setEnabled (true);
   1.230  				actionDeleteVymLink->setEnabled (true);
   1.231  			}	
   1.232 -
   1.233 -			if (bo->canMoveBranchUp()) 
   1.234 +*/
   1.235 +/* FIXME-1  if (selbi->canMoveBranchUp()) 
   1.236  				actionMoveUp->setEnabled (true);
   1.237  			else	
   1.238  				actionMoveUp->setEnabled (false);
   1.239 -			if (bo->canMoveBranchDown()) 
   1.240 +			if (selbi->canMoveBranchDown()) 
   1.241  				actionMoveDown->setEnabled (true);
   1.242  			else	
   1.243  				actionMoveDown->setEnabled (false);
   1.244 -
   1.245 +*/
   1.246  			actionSortChildren->setEnabled (true);
   1.247  
   1.248  			actionToggleHideExport->setEnabled (true);	
   1.249 -			actionToggleHideExport->setOn (bo->hideInExport() );	
   1.250 +			actionToggleHideExport->setOn (selbi->hideInExport() );	
   1.251  
   1.252  			actionFileSave->setEnabled (true);	
   1.253  			actionCopy->setEnabled (true);	
   1.254 @@ -3693,8 +3694,9 @@
   1.255  			actionFormatHideLinkUnselected->setOn
   1.256  				(selection->getHideLinkUnselected());
   1.257  		}
   1.258 -		if ( (typeid(*selection) == typeid(FloatImageObj)) )
   1.259 +		if ( selti->getType()==TreeItem::Image)
   1.260  		{
   1.261 +		/* FIXME-2
   1.262  			FloatObj *fo=(FloatImageObj*)selection;
   1.263  
   1.264  			actionOpenURL->setEnabled (false);
   1.265 @@ -3714,6 +3716,7 @@
   1.266  				( selection->getHideLinkUnselected());
   1.267  			actionMoveUp->setEnabled (false);
   1.268  			actionMoveDown->setEnabled (false);
   1.269 +			*/
   1.270  		}
   1.271  
   1.272  	} else