diff -r 1b4d1ea6ea8c -r 54d44ecd6097 mainwindow.cpp --- a/mainwindow.cpp Fri Mar 06 15:02:58 2009 +0000 +++ b/mainwindow.cpp Thu Mar 19 11:45:28 2009 +0000 @@ -217,7 +217,12 @@ if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); setupHelpActions(); + // Status bar and progress bar there statusBar(); + progressMax=0; + progressBar=new QProgressBar; + progressBar->hide(); + statusBar()->addPermanentWidget(progressBar); restoreState (settings.value("/mainwindow/state",0).toByteArray()); @@ -239,7 +244,7 @@ settings.setValue( "/version/version", vymVersion ); settings.setValue( "/version/builddate", vymBuildDate ); - settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() ); + settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() ); settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() ); settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); @@ -254,6 +259,7 @@ delete textEditor; delete historyWindow; delete branchPropertyWindow; + delete progressBar; // Remove temporary directory removeDir (QDir(tmpVymDir)); @@ -280,7 +286,39 @@ void Main::statusMessage(const QString &s) { - statusBar()->message( s); + // Surpress messages while progressbar during + // load is active + if (progressMin==progressMax) + statusBar()->message( s); +} + +void Main::setProgressMinimum (int min) +{ + progressBar->setMinimum(min); + progressMin=min; +} + +void Main::setProgressMaximum (int max) +{ + progressBar->setMaximum(max); + progressMax=max; + if (max>0) + { + statusBar()->addPermanentWidget(progressBar); + progressBar->show(); + } +} + +void Main::setProgressValue (int v) +{ + progressBar->setValue (v); +} + +void Main::removeProgressBar() +{ + if (progressMax>0) + statusBar()->removeWidget(progressBar); + progressMax=progressMin=0; } void Main::closeEvent (QCloseEvent* ) @@ -337,10 +375,15 @@ fileImportMenu = fileMenu->addMenu (tr("Import","File menu")); - a = new QAction(tr("KDE Bookmarks"), this); - a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks"))); + a = new QAction(tr("KDE 3 Bookmarks"), this); + a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks"))); a->addTo (fileImportMenu); - connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) ); + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) ); + + a = new QAction(tr("KDE 4 Bookmarks"), this); + a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks"))); + a->addTo (fileImportMenu); + connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) ); if (settings.value( "/mainwindow/showTestMenu",false).toBool()) { @@ -393,9 +436,14 @@ connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) ); fileExportMenu->addAction (a); - a = new QAction( tr("KDE Bookmarks","File menu"), this); - a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" ))); - connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) ); + a = new QAction( tr("KDE 3 Bookmarks","File menu"), this); + a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" ))); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) ); + fileExportMenu->addAction (a); + + a = new QAction( tr("KDE 4 Bookmarks","File menu"), this); + a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" ))); + connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) ); fileExportMenu->addAction (a); a = new QAction( "Taskjuggler...", this ); @@ -1403,7 +1451,7 @@ a = new QAction( tr( "Autosave","Settings action"), this); a->setStatusTip( tr( "Autosave")); a->setToggleAction(true); - a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool()); + a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool()); connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); settingsMenu->addAction (a); actionSettingsAutosaveToggle=a; @@ -2065,11 +2113,19 @@ fileSaveAs (CompleteMap); } -void Main::fileImportKDEBookmarks() +void Main::fileImportKDE3Bookmarks() { - ImportKDEBookmarks im; + ImportKDE3Bookmarks im; im.transform(); - if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) + if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) + currentMapEditor()->getModel()->setFilePath (""); +} + +void Main::fileImportKDE4Bookmarks() +{ + ImportKDE4Bookmarks im; + im.transform(); + if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) currentMapEditor()->getModel()->setFilePath (""); } @@ -2091,7 +2147,7 @@ { im.setFile (*it); if (im.transform() && - success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && + aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && currentMapEditor() ) currentMapEditor()->getModel()->setFilePath (""); ++it; @@ -2229,9 +2285,20 @@ } } -void Main::fileExportKDEBookmarks() //FIXME not scriptable yet +void Main::fileExportKDE3Bookmarks() //FIXME not scriptable yet { - ExportKDEBookmarks ex; + ExportKDE3Bookmarks ex; + VymModel *m=currentModel(); + if (m) + { + ex.setModel (m); + ex.doExport(); + } +} + +void Main::fileExportKDE4Bookmarks() //FIXME not scriptable yet +{ + ExportKDE4Bookmarks ex; VymModel *m=currentModel(); if (m) { @@ -2321,10 +2388,16 @@ return; } } - me->close(); tabModel.removeAt (tabWidget->currentIndex() ); tabWidget->removeTab (tabWidget->currentIndex() ); - delete me; // FIXME if event was triggered _in_ ME this causes warning message + + // Remove mapEditor; + // Better would be delete (me), but then we could have a Qt error: + // "QObject: Do not delete object, 'MapEditor', during its event handler!" + // So we only remove data now and call deconstructor when vym closes later + // FIXME this needs to be moved to vymview... me->clear(); + // some model->clear is needed to free up memory ... + updateActions(); } } @@ -2792,9 +2865,9 @@ dia.setAuthor (m->getAuthor() ); dia.setComment(m->getComment() ); -/* FIXME no stats at the moment (view dependent...) // Calc some stats QString stats; +/* FIXME no stats at the moment (view dependent...) stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6); uint b=0; @@ -2811,13 +2884,13 @@ xl+=bo->countXLinks(); bo=m->next(bo); } - stats+=QString ("%1 branches\n").arg (b-1,6); stats+=QString ("%1 xLinks \n").arg (xl,6); stats+=QString ("%1 notes\n").arg (n,6); stats+=QString ("%1 images\n").arg (f,6); +*/ + stats+=QString ("%1 branches\n").arg (m->countBranches(),6); dia.setStats (stats); -*/ // Finally show dialog if (dia.exec() == QDialog::Accepted) { @@ -3282,7 +3355,7 @@ void Main::settingsAutosaveToggle() { - settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() ); + settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() ); } void Main::settingsAutosaveTime() @@ -3291,14 +3364,14 @@ int i = QInputDialog::getInteger( this, tr("QInputDialog::getInteger()"), - tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok); + tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok); if (ok) - settings.setValue ("/mapeditor/autosave/ms",i * 1000); + settings.setValue ("/mainwindow/autosave/ms",i * 1000); } void Main::settingsWriteBackupFileToggle() { - settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); + settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); } void Main::settingsToggleAnimation()