mainwindow.cpp
changeset 847 43268373032d
parent 845 b98c1793bb8b
child 848 e265f07f2173
     1.1 --- a/mainwindow.cpp	Fri Apr 09 14:24:04 2010 +0000
     1.2 +++ b/mainwindow.cpp	Wed Jun 09 13:14:08 2010 +0000
     1.3 @@ -720,7 +720,7 @@
     1.4  
     1.5  	a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
     1.6  	a->setStatusTip ( tr( "Move branch up" ) );
     1.7 -	a->setShortcut (Qt::Key_PageUp );				// Move branch up	//FIXME-2 If already on top, GraphicsView scrolls up, probably because this action is disabled?!
     1.8 +	a->setShortcut (Qt::Key_PageUp );				// Move branch up	
     1.9  	a->setEnabled (false);
    1.10  	switchboard.addConnection(a,tr("Edit","Shortcut group"));
    1.11  	tb->addAction (a);
    1.12 @@ -2001,7 +2001,7 @@
    1.13  		fileNew();
    1.14  		VymModel *dstModel=vymViews.last()->getModel();
    1.15  		dstModel->select("mc:");
    1.16 -		dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
    1.17 +		dstModel->loadMap (clipboardDir+"/"+clipboardFile,ImportReplace);
    1.18  	}
    1.19  }
    1.20  
    1.21 @@ -2116,7 +2116,7 @@
    1.22  
    1.23  			// Finally load map into mapEditor
    1.24  			vm->setFilePath (fn);
    1.25 -			err=vm->load(fn,lmode,ftype);
    1.26 +			err=vm->loadMap(fn,lmode,true,ftype);
    1.27  
    1.28  			// Restore old (maybe empty) filepath, if this is an import
    1.29  			if (lmode!=NewMap)
    1.30 @@ -2571,11 +2571,12 @@
    1.31  	}
    1.32  }
    1.33  
    1.34 -void Main::fileCloseMap()	
    1.35 +bool Main::fileCloseMap()	
    1.36  {
    1.37  	VymModel *m=currentModel();
    1.38  	if (m)
    1.39  	{
    1.40 +		//qDebug()<<"Main::fileCloseMap  currentIndex="<<tabWidget->currentIndex();
    1.41  		if (m->hasChanged())
    1.42  		{
    1.43  			QMessageBox mb( vymName,
    1.44 @@ -2586,6 +2587,9 @@
    1.45  				QMessageBox::Cancel | QMessageBox::Escape );
    1.46  			mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
    1.47  			mb.setButtonText( QMessageBox::No, tr("Discard changes"));
    1.48 +			mb.setModal (true);
    1.49 +			mb.show();
    1.50 +			mb.setActiveWindow();
    1.51  			switch( mb.exec() ) 
    1.52  			{
    1.53  				case QMessageBox::Yes:
    1.54 @@ -2597,7 +2601,7 @@
    1.55  					break;
    1.56  				case QMessageBox::Cancel:
    1.57  					// do nothing
    1.58 -				return;
    1.59 +					return true;
    1.60  			}
    1.61  		} 
    1.62  		// And here comes the segfault, because removeTab triggers 
    1.63 @@ -2609,7 +2613,9 @@
    1.64  		//delete (m->getMapEditor());
    1.65  
    1.66  		updateActions();
    1.67 +		return false;
    1.68  	}
    1.69 +	return true; // Better don't exit vym if there is no currentModel()...
    1.70  }
    1.71  
    1.72  void Main::filePrint()
    1.73 @@ -2618,41 +2624,16 @@
    1.74  		currentMapEditor()->print();
    1.75  }
    1.76  
    1.77 -void Main::fileExitVYM()
    1.78 +void Main::fileExitVYM()	
    1.79  {
    1.80  	// Check if one or more editors have changed
    1.81 -	int i;
    1.82 -	for (i=0;i<=vymViews.count() -1;i++)
    1.83 +	int i=0;
    1.84 +	while (vymViews.count()>0)
    1.85  	{
    1.86 -		// If something changed, ask what to do
    1.87 -		if (vymViews.at(i)->getModel()->hasChanged())
    1.88 -		{
    1.89 -			tabWidget->setCurrentPage(i);
    1.90 -			QMessageBox mb( vymName,
    1.91 -				tr("This map is not saved yet. Do you want to"),
    1.92 -				QMessageBox::Warning,
    1.93 -				QMessageBox::Yes | QMessageBox::Default,
    1.94 -				QMessageBox::No,
    1.95 -				QMessageBox::Cancel | QMessageBox::Escape );
    1.96 -			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
    1.97 -			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
    1.98 -			mb.setModal (true);
    1.99 -			mb.show();
   1.100 -			mb.setActiveWindow();
   1.101 -			switch( mb.exec() ) {
   1.102 -				case QMessageBox::Yes:
   1.103 -					// save (the changed editors) and exit
   1.104 -					fileSave(currentModel(), CompleteMap);
   1.105 -					break;
   1.106 -				case QMessageBox::No:
   1.107 -					// exit without saving
   1.108 -					break;
   1.109 -				case QMessageBox::Cancel:
   1.110 -					// don't save and don't exit
   1.111 -				return;
   1.112 -			}
   1.113 -		}
   1.114 -	} // loop over all MEs	
   1.115 +		//qDebug()<<"Main::fileExitVym  count="<<vymViews.count();
   1.116 +		tabWidget->setCurrentPage(i);
   1.117 +		if (fileCloseMap()) return;
   1.118 +	} 
   1.119      qApp->quit();
   1.120  }
   1.121  
   1.122 @@ -2784,12 +2765,6 @@
   1.123  				// Try to open new tab in existing konqueror started previously by vym
   1.124  				args.clear();
   1.125  
   1.126 -/*	On KDE3 use DCOP
   1.127 -				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
   1.128 -					"konqueror-mainwindow#1"<<
   1.129 -					"newTab" <<
   1.130 -					urls.at(i);
   1.131 -*/					
   1.132  				args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
   1.133  					"/konqueror/MainWindow_1"<<
   1.134  					"newTab" <<
   1.135 @@ -2837,7 +2812,7 @@
   1.136  		QString browser=settings.value("/mainwindow/readerURL" ).toString();
   1.137  		args<<url;
   1.138  		QString workDir=QDir::currentDirPath();
   1.139 -		if (!procBrowser->startDetached(browser,args))
   1.140 +		if (!QProcess::startDetached(browser,args))
   1.141  		{
   1.142  			// try to set path to browser
   1.143  			QMessageBox::warning(0, 
   1.144 @@ -3049,7 +3024,7 @@
   1.145  		m->nextBranch(cur,prev);
   1.146  	}
   1.147  
   1.148 -    stats+=QString ("%1 xLinks \n").arg (xl,6);
   1.149 +    stats+=QString ("%1 xLinks \n").arg (xl/2,6);
   1.150      stats+=QString ("%1 notes\n").arg (n,6);
   1.151      stats+=QString ("%1 images\n").arg (f,6);
   1.152      stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
   1.153 @@ -3671,7 +3646,7 @@
   1.154  
   1.155  void Main::updateActions()
   1.156  {
   1.157 -	// updateActions is also called when satellites are closed	//FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
   1.158 +	// updateActions is also called when satellites are closed	
   1.159  	actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
   1.160  	actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
   1.161  	actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());