mainwindow.cpp
changeset 742 54d44ecd6097
parent 739 3d43b46a8564
child 746 ee6b0f3a4c2f
     1.1 --- a/mainwindow.cpp	Fri Mar 06 15:02:58 2009 +0000
     1.2 +++ b/mainwindow.cpp	Thu Mar 19 11:45:28 2009 +0000
     1.3 @@ -217,7 +217,12 @@
     1.4      if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
     1.5      setupHelpActions();
     1.6      
     1.7 +	// Status bar and progress bar there
     1.8      statusBar();
     1.9 +	progressMax=0;
    1.10 +	progressBar=new QProgressBar; 
    1.11 +	progressBar->hide();
    1.12 +	statusBar()->addPermanentWidget(progressBar);
    1.13  
    1.14  	restoreState (settings.value("/mainwindow/state",0).toByteArray());
    1.15  
    1.16 @@ -239,7 +244,7 @@
    1.17  	settings.setValue( "/version/version", vymVersion );
    1.18  	settings.setValue( "/version/builddate", vymBuildDate );
    1.19  
    1.20 -	settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
    1.21 +	settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
    1.22  	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
    1.23  	settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
    1.24  	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
    1.25 @@ -254,6 +259,7 @@
    1.26  	delete textEditor;
    1.27  	delete historyWindow;
    1.28  	delete branchPropertyWindow;
    1.29 +	delete progressBar;
    1.30  
    1.31  	// Remove temporary directory
    1.32  	removeDir (QDir(tmpVymDir));
    1.33 @@ -280,7 +286,39 @@
    1.34  
    1.35  void Main::statusMessage(const QString &s)
    1.36  {
    1.37 -	statusBar()->message( s);
    1.38 +	// Surpress messages while progressbar during 
    1.39 +	// load is active
    1.40 +	if (progressMin==progressMax)
    1.41 +		statusBar()->message( s);
    1.42 +}
    1.43 +
    1.44 +void Main::setProgressMinimum (int min)
    1.45 +{
    1.46 +	progressBar->setMinimum(min);
    1.47 +	progressMin=min;
    1.48 +}
    1.49 +
    1.50 +void Main::setProgressMaximum (int max)
    1.51 +{
    1.52 +	progressBar->setMaximum(max);
    1.53 +	progressMax=max;
    1.54 +	if (max>0)
    1.55 +	{
    1.56 +		statusBar()->addPermanentWidget(progressBar);
    1.57 +		progressBar->show();
    1.58 +	}
    1.59 +}
    1.60 +
    1.61 +void Main::setProgressValue (int v)
    1.62 +{
    1.63 +	progressBar->setValue (v);
    1.64 +}
    1.65 +
    1.66 +void Main::removeProgressBar()
    1.67 +{
    1.68 +	if (progressMax>0)
    1.69 +		statusBar()->removeWidget(progressBar);
    1.70 +	progressMax=progressMin=0;
    1.71  }
    1.72  
    1.73  void Main::closeEvent (QCloseEvent* )
    1.74 @@ -337,10 +375,15 @@
    1.75  
    1.76  	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
    1.77  
    1.78 -	a = new QAction(tr("KDE Bookmarks"), this);
    1.79 -	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
    1.80 +	a = new QAction(tr("KDE 3 Bookmarks"), this);
    1.81 +	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
    1.82  	a->addTo (fileImportMenu);
    1.83 -	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
    1.84 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
    1.85 +
    1.86 +	a = new QAction(tr("KDE 4 Bookmarks"), this);
    1.87 +	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
    1.88 +	a->addTo (fileImportMenu);
    1.89 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
    1.90  
    1.91      if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
    1.92  	{
    1.93 @@ -393,9 +436,14 @@
    1.94      connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
    1.95  	fileExportMenu->addAction (a);
    1.96  
    1.97 -	a = new QAction( tr("KDE Bookmarks","File menu"), this);
    1.98 -	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
    1.99 -	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
   1.100 +	a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
   1.101 +	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
   1.102 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
   1.103 +	fileExportMenu->addAction (a);
   1.104 +
   1.105 +	a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
   1.106 +	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
   1.107 +	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
   1.108  	fileExportMenu->addAction (a);
   1.109  
   1.110      a = new QAction( "Taskjuggler...", this );
   1.111 @@ -1403,7 +1451,7 @@
   1.112      a = new QAction( tr( "Autosave","Settings action"), this);
   1.113      a->setStatusTip( tr( "Autosave"));
   1.114  	a->setToggleAction(true);
   1.115 -	a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
   1.116 +	a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
   1.117      connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
   1.118  	settingsMenu->addAction (a);
   1.119  	actionSettingsAutosaveToggle=a;
   1.120 @@ -2065,11 +2113,19 @@
   1.121  	fileSaveAs (CompleteMap);
   1.122  }
   1.123  
   1.124 -void Main::fileImportKDEBookmarks()
   1.125 +void Main::fileImportKDE3Bookmarks()
   1.126  {
   1.127 -	ImportKDEBookmarks im;
   1.128 +	ImportKDE3Bookmarks im;
   1.129  	im.transform();
   1.130 -	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
   1.131 +	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
   1.132 +		currentMapEditor()->getModel()->setFilePath ("");
   1.133 +}
   1.134 +
   1.135 +void Main::fileImportKDE4Bookmarks()
   1.136 +{
   1.137 +	ImportKDE4Bookmarks im;
   1.138 +	im.transform();
   1.139 +	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
   1.140  		currentMapEditor()->getModel()->setFilePath ("");
   1.141  }
   1.142  
   1.143 @@ -2091,7 +2147,7 @@
   1.144  		{
   1.145  			im.setFile (*it);
   1.146  			if (im.transform() && 
   1.147 -				success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
   1.148 +				aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
   1.149  				currentMapEditor() )
   1.150  				currentMapEditor()->getModel()->setFilePath ("");
   1.151  			++it;
   1.152 @@ -2229,9 +2285,20 @@
   1.153  	}
   1.154  }
   1.155  
   1.156 -void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
   1.157 +void Main::fileExportKDE3Bookmarks()	//FIXME not scriptable yet
   1.158  {
   1.159 -	ExportKDEBookmarks ex;
   1.160 +	ExportKDE3Bookmarks ex;
   1.161 +	VymModel *m=currentModel();
   1.162 +	if (m)
   1.163 +	{
   1.164 +		ex.setModel (m);
   1.165 +		ex.doExport();
   1.166 +	}	
   1.167 +}
   1.168 +
   1.169 +void Main::fileExportKDE4Bookmarks()	//FIXME not scriptable yet
   1.170 +{
   1.171 +	ExportKDE4Bookmarks ex;
   1.172  	VymModel *m=currentModel();
   1.173  	if (m)
   1.174  	{
   1.175 @@ -2321,10 +2388,16 @@
   1.176  				return;
   1.177  			}
   1.178  		} 
   1.179 -		me->close();
   1.180  		tabModel.removeAt (tabWidget->currentIndex() );
   1.181  		tabWidget->removeTab (tabWidget->currentIndex() );
   1.182 -        delete me;	// FIXME if event was triggered _in_ ME this causes warning message
   1.183 +
   1.184 +		// Remove mapEditor;
   1.185 +		// Better would be delete (me), but then we could have a Qt error:
   1.186 +		// "QObject: Do not delete object, 'MapEditor', during its event handler!"
   1.187 +		// So we only remove data now and call deconstructor when vym closes later
   1.188 +		// FIXME  this needs to be moved to vymview...   me->clear();
   1.189 +		// some model->clear is needed to free up memory ...
   1.190 +
   1.191  		updateActions();
   1.192  	}
   1.193  }
   1.194 @@ -2792,9 +2865,9 @@
   1.195  	dia.setAuthor (m->getAuthor() );
   1.196  	dia.setComment(m->getComment() );
   1.197  
   1.198 -/* FIXME no stats at the moment (view dependent...)
   1.199  	// Calc some stats
   1.200  	QString stats;
   1.201 +/* FIXME no stats at the moment (view dependent...)
   1.202      stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
   1.203  
   1.204  	uint b=0;
   1.205 @@ -2811,13 +2884,13 @@
   1.206  		xl+=bo->countXLinks();
   1.207  		bo=m->next(bo);
   1.208  	}
   1.209 -    stats+=QString ("%1 branches\n").arg (b-1,6);
   1.210      stats+=QString ("%1 xLinks \n").arg (xl,6);
   1.211      stats+=QString ("%1 notes\n").arg (n,6);
   1.212      stats+=QString ("%1 images\n").arg (f,6);
   1.213 +*/
   1.214 +    stats+=QString ("%1 branches\n").arg (m->countBranches(),6);
   1.215  	dia.setStats (stats);
   1.216  
   1.217 -*/
   1.218  	// Finally show dialog
   1.219  	if (dia.exec() == QDialog::Accepted)
   1.220  	{
   1.221 @@ -3282,7 +3355,7 @@
   1.222  
   1.223  void Main::settingsAutosaveToggle()
   1.224  {
   1.225 -	settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
   1.226 +	settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
   1.227  }
   1.228  
   1.229  void Main::settingsAutosaveTime()
   1.230 @@ -3291,14 +3364,14 @@
   1.231  	int i = QInputDialog::getInteger(
   1.232  		this, 
   1.233  		tr("QInputDialog::getInteger()"),
   1.234 -	    tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
   1.235 +	    tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
   1.236  	if (ok)
   1.237 -		settings.setValue ("/mapeditor/autosave/ms",i * 1000);
   1.238 +		settings.setValue ("/mainwindow/autosave/ms",i * 1000);
   1.239  }
   1.240  
   1.241  void Main::settingsWriteBackupFileToggle()
   1.242  {
   1.243 -	settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
   1.244 +	settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
   1.245  }
   1.246  
   1.247  void Main::settingsToggleAnimation()