diff -r f0fe7c36ec5c -r 43268373032d mainwindow.cpp --- a/mainwindow.cpp Fri Apr 09 14:24:04 2010 +0000 +++ b/mainwindow.cpp Wed Jun 09 13:14:08 2010 +0000 @@ -720,7 +720,7 @@ a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this); a->setStatusTip ( tr( "Move branch up" ) ); - a->setShortcut (Qt::Key_PageUp ); // Move branch up //FIXME-2 If already on top, GraphicsView scrolls up, probably because this action is disabled?! + a->setShortcut (Qt::Key_PageUp ); // Move branch up a->setEnabled (false); switchboard.addConnection(a,tr("Edit","Shortcut group")); tb->addAction (a); @@ -2001,7 +2001,7 @@ fileNew(); VymModel *dstModel=vymViews.last()->getModel(); dstModel->select("mc:"); - dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); + dstModel->loadMap (clipboardDir+"/"+clipboardFile,ImportReplace); } } @@ -2116,7 +2116,7 @@ // Finally load map into mapEditor vm->setFilePath (fn); - err=vm->load(fn,lmode,ftype); + err=vm->loadMap(fn,lmode,true,ftype); // Restore old (maybe empty) filepath, if this is an import if (lmode!=NewMap) @@ -2571,11 +2571,12 @@ } } -void Main::fileCloseMap() +bool Main::fileCloseMap() { VymModel *m=currentModel(); if (m) { + //qDebug()<<"Main::fileCloseMap currentIndex="<currentIndex(); if (m->hasChanged()) { QMessageBox mb( vymName, @@ -2586,6 +2587,9 @@ QMessageBox::Cancel | QMessageBox::Escape ); mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") ); mb.setButtonText( QMessageBox::No, tr("Discard changes")); + mb.setModal (true); + mb.show(); + mb.setActiveWindow(); switch( mb.exec() ) { case QMessageBox::Yes: @@ -2597,7 +2601,7 @@ break; case QMessageBox::Cancel: // do nothing - return; + return true; } } // And here comes the segfault, because removeTab triggers @@ -2609,7 +2613,9 @@ //delete (m->getMapEditor()); updateActions(); + return false; } + return true; // Better don't exit vym if there is no currentModel()... } void Main::filePrint() @@ -2618,41 +2624,16 @@ currentMapEditor()->print(); } -void Main::fileExitVYM() +void Main::fileExitVYM() { // Check if one or more editors have changed - int i; - for (i=0;i<=vymViews.count() -1;i++) + int i=0; + while (vymViews.count()>0) { - // If something changed, ask what to do - if (vymViews.at(i)->getModel()->hasChanged()) - { - tabWidget->setCurrentPage(i); - QMessageBox mb( vymName, - tr("This map is not saved yet. Do you want to"), - QMessageBox::Warning, - QMessageBox::Yes | QMessageBox::Default, - QMessageBox::No, - QMessageBox::Cancel | QMessageBox::Escape ); - mb.setButtonText( QMessageBox::Yes, tr("Save map") ); - mb.setButtonText( QMessageBox::No, tr("Discard changes") ); - mb.setModal (true); - mb.show(); - mb.setActiveWindow(); - switch( mb.exec() ) { - case QMessageBox::Yes: - // save (the changed editors) and exit - fileSave(currentModel(), CompleteMap); - break; - case QMessageBox::No: - // exit without saving - break; - case QMessageBox::Cancel: - // don't save and don't exit - return; - } - } - } // loop over all MEs + //qDebug()<<"Main::fileExitVym count="<setCurrentPage(i); + if (fileCloseMap()) return; + } qApp->quit(); } @@ -2784,12 +2765,6 @@ // Try to open new tab in existing konqueror started previously by vym args.clear(); -/* On KDE3 use DCOP - args<< QString("konqueror-%1").arg(procBrowser->pid())<< - "konqueror-mainwindow#1"<< - "newTab" << - urls.at(i); -*/ args<< QString("org.kde.konqueror-%1").arg(*browserPID)<< "/konqueror/MainWindow_1"<< "newTab" << @@ -2837,7 +2812,7 @@ QString browser=settings.value("/mainwindow/readerURL" ).toString(); args<startDetached(browser,args)) + if (!QProcess::startDetached(browser,args)) { // try to set path to browser QMessageBox::warning(0, @@ -3049,7 +3024,7 @@ m->nextBranch(cur,prev); } - stats+=QString ("%1 xLinks \n").arg (xl,6); + stats+=QString ("%1 xLinks \n").arg (xl/2,6); stats+=QString ("%1 notes\n").arg (n,6); stats+=QString ("%1 images\n").arg (f,6); stats+=QString ("%1 branches\n").arg (m->branchCount(),6); @@ -3671,7 +3646,7 @@ void Main::updateActions() { - // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed + // updateActions is also called when satellites are closed actionViewToggleNoteEditor->setChecked (textEditor->isVisible()); actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible()); actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());