# HG changeset patch # User insilmaril # Date 1156840302 0 # Node ID 41c3d7f9f53215fcede98fbdd5b468cda0742713 # Parent 699f285290795a0e11ec36803d2431f4d9c7338c Runs basically on Mac now. Undo debug output still enabled diff -r 699f28529079 -r 41c3d7f9f532 aboutdialog.cpp --- a/aboutdialog.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/aboutdialog.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -190,6 +190,6 @@ void AboutTextBrowser::setSource(const QUrl &url ) { QProcess *proc= new QProcess (); - proc->start( settings.value("/vym/mainwindow/readerURL").toString(),QStringList ()<start( settings.value("/mainwindow/readerURL").toString(),QStringList ()<waitForStarted() &&mainWindow->settingsURL() ) setSource(url); } diff -r 699f28529079 -r 41c3d7f9f532 exportoofiledialog.cpp --- a/exportoofiledialog.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/exportoofiledialog.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -90,7 +90,7 @@ configPaths.append (fi.absFilePath()); set.clear(); set.readSettings (fi.absFilePath()); - addFilter (set.readEntry("Name") + " (*.odp)"); + addFilter (set.readEntry(QString("Name")) + " (*.odp)"); } } } diff -r 699f28529079 -r 41c3d7f9f532 exports.cpp --- a/exports.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/exports.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -129,8 +129,7 @@ // Main loop over all branches QString s; QString actIndent(""); - int i; - uint j; + int i,j; BranchObj *bo; bo=mapCenter->first(); while (bo) diff -r 699f28529079 -r 41c3d7f9f532 exportxhtmldialog.ui.h --- a/exportxhtmldialog.ui.h Tue Aug 15 12:01:14 2006 +0000 +++ b/exportxhtmldialog.ui.h Tue Aug 29 08:31:42 2006 +0000 @@ -25,42 +25,42 @@ void ExportXHTMLDialog::readSettings() { - dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir",vymBaseDir.currentDirPath() ); + dir=settings.readLocalEntry (filepath,"/export/xhtml/exportDir",vymBaseDir.currentDirPath() ); lineEditDir->setText(dir); - if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes") + if ( settings.readLocalEntry (filepath,"/export/xhtml/useImage","yes")=="yes") useImage=true; else useImage=false; imageButton->setChecked(useImage); - if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no")=="yes") + if ( settings.readLocalEntry (filepath,"/export/xhtml/useTextColor","no")=="yes") useTextColor=true; else useTextColor=false; textColorButton->setChecked(useTextColor); /* FIXME this was used in old html export, is not yet in new stylesheet - if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes") + if ( settings.readEntry ("/export/html/useHeading","no")=="yes") useHeading=true; else useHeading=false; checkBox4_2->setChecked(useHeading); */ - if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/saveSettingsInMap","no")=="yes") + if ( settings.readLocalEntry (filepath,"/export/xhtml/saveSettingsInMap","no")=="yes") saveSettingsInMap=true; else saveSettingsInMap=false; saveSettingsInMapButton->setChecked(saveSettingsInMap); - if ( settings.readEntry ("/vym/export/xhtml/showWarnings","yes")=="yes") + if ( settings.readEntry ("/export/xhtml/showWarnings","yes")=="yes") showWarnings=true; else showWarnings=false; warningsButton->setChecked(showWarnings); - if ( settings.readEntry ("/vym/export/xhtml/showOutput","no")=="yes") + if ( settings.readEntry ("/export/xhtml/showOutput","no")=="yes") showOutput=true; else showOutput=false; @@ -74,19 +74,19 @@ } else { xsl=settings.readLocalEntry - (filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl"); + (filepath,"/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl"); css=settings.readLocalEntry - (filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css"); + (filepath,"/export/xhtml/css","/usr/share/vym/styles/vym.css"); } lineEditXSL->setText(xsl); lineEditCSS->setText(css); prescript=settings.readLocalEntry - (filepath,"/vym/export/xhtml/prescript",""); + (filepath,"/export/xhtml/prescript",""); lineEditPreScript->setText (prescript); postscript=settings.readLocalEntry - (filepath,"/vym/export/xhtml/postscript",""); + (filepath,"/export/xhtml/postscript",""); lineEditPostScript->setText (postscript); if (!prescript.isEmpty() || !postscript.isEmpty()) @@ -251,38 +251,38 @@ // Save options to settings file // (but don't save at destructor, which // is called for "cancel", too) - settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir); - settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript); - settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript); + settings.setLocalEntry (filepath,"/export/xhtml/exportDir",dir); + settings.setLocalEntry (filepath,"/export/xhtml/prescript",prescript); + settings.setLocalEntry (filepath,"/export/xhtml/postscript",postscript); if (useImage) - settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","yes"); + settings.setLocalEntry (filepath,"/export/xhtml/useImage","yes"); else - settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","no"); + settings.setLocalEntry (filepath,"/export/xhtml/useImage","no"); if (useTextColor) - settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","yes"); + settings.setLocalEntry (filepath,"/export/xhtml/useTextColor","yes"); else - settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no"); + settings.setLocalEntry (filepath,"/export/xhtml/useTextColor","no"); if (showWarnings) - settings.writeEntry ("/vym/export/xhtml/showWarnings","yes"); + settings.writeEntry ("/export/xhtml/showWarnings","yes"); else - settings.writeEntry ("/vym/export/xhtml/showWarnings","no"); + settings.writeEntry ("/export/xhtml/showWarnings","no"); if (showOutput) - settings.writeEntry ("/vym/export/xhtml/showOutput","yes"); + settings.writeEntry ("/export/xhtml/showOutput","yes"); else - settings.writeEntry ("/vym/export/xhtml/showOutput","no"); + settings.writeEntry ("/export/xhtml/showOutput","no"); QString ipath; ipath=vymBaseDir.path()+"/flags/flag-url-16x16.png"; if (!options.isOn ("local")) { settings.setLocalEntry - (filepath,"/vym/export/xhtml/xsl",xsl); + (filepath,"/export/xhtml/xsl",xsl); settings.setLocalEntry - (filepath,"/vym/export/xhtml/css",css); + (filepath,"/export/xhtml/css",css); } // Provide a smaller URL-icon to improve Layout @@ -294,10 +294,10 @@ if(!pm.save (dir + "flags/flag-url-16x16.png","PNG")) QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath)); if (!saveSettingsInMap) - settings.clearLocal("/vym/export/xhtml"); + settings.clearLocal("/export/xhtml"); else settings.setLocalEntry - (filepath,"/vym/export/xhtml/saveSettingsInMap","yes"); + (filepath,"/export/xhtml/saveSettingsInMap","yes"); // Copy CSS file QFile css_src (css); diff -r 699f28529079 -r 41c3d7f9f532 main.cpp --- a/main.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/main.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -46,6 +46,7 @@ QAction *actionEditToggleScroll; QAction *actionEditOpenURL; QAction *actionEditOpenURLTab; +QAction *actionEditOpenMultipleURLTabs; QAction *actionEditURL; QAction *actionEditHeading2URL; QAction *actionEditBugzilla2URL; @@ -120,7 +121,8 @@ QMenu* fileExportMenu; -Settings settings ("vym","vym"); // Organization, Application name +Settings settings ("InSilmaril","vym"); // Organization, Application name + Options options; ImageIO imageIO; diff -r 699f28529079 -r 41c3d7f9f532 mainwindow.cpp --- a/mainwindow.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/mainwindow.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -63,6 +63,7 @@ extern QAction *actionEditToggleScroll; extern QAction* actionEditOpenURL; extern QAction* actionEditOpenURLTab; +extern QAction* actionEditOpenMultipleURLTabs; extern QAction* actionEditURL; extern QAction* actionEditHeading2URL; extern QAction* actionEditBugzilla2URL; @@ -214,6 +215,9 @@ connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), this, SLOT( editorChanged( QWidget * ) ) ); + lineedit=new QLineEdit (this); + lineedit->hide(); + setCentralWidget(tabWidget); setupFileActions(); @@ -459,14 +463,13 @@ editMenu->addAction (a); actionEditUndo=a; - if (settings.value( "/mainwindow/showTestMenu",false).toBool()) - { - a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); - a->setStatusTip (tr( "Redo" )); - a->setShortcut (Qt::CTRL + Qt::Key_Y ); - editMenu->addAction (a); - connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); - } + a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); + a->setStatusTip (tr( "Redo" )); + a->setShortcut (Qt::CTRL + Qt::Key_Y ); + tb->addAction (a); + editMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); + actionEditRedo=a; editMenu->addSeparator(); a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this); @@ -500,14 +503,14 @@ a = new QAction(tr( "Edit heading" ),this); a->setStatusTip ( tr( "edit Heading" )); a->setShortcut ( Qt::Key_Enter); - a->setShortcutContext (Qt::WindowShortcut); +// a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); a = new QAction( tr( "Edit heading" ), this); a->setStatusTip (tr( "edit Heading" )); a->setShortcut (Qt::Key_Return ); - a->setShortcutContext (Qt::WindowShortcut); + //a->setShortcutContext (Qt::WindowShortcut); addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) ); actionListBranches.append(a); @@ -675,6 +678,13 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); actionEditOpenURLTab=a; + a = new QAction( tr( "Open all URLs in subtree" ), this); + a->setStatusTip (tr( "Open all URLs in subtree" )); + a->setShortcut (Qt::CTRL+Qt::Key_U ); + addAction(a); + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); + actionEditOpenMultipleURLTabs=a; + a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this); a->setStatusTip ( tr( "Edit URL" ) ); a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U ); @@ -1503,7 +1513,6 @@ branchAddContextMenu->addSeparator(); branchAddContextMenu->addAction ( actionEditLoadImage); branchAddContextMenu->addSeparator(); - branchAddContextMenu->addAction ( actionEditLoadImage); branchAddContextMenu->addAction ( actionEditImportAdd ); branchAddContextMenu->addAction ( actionEditImportReplace ); @@ -1520,10 +1529,11 @@ branchContextMenu->addSeparator(); branchContextMenu->addAction ( actionEditOpenURL ); branchContextMenu->addAction ( actionEditOpenURLTab ); + branchContextMenu->addAction ( actionEditOpenMultipleURLTabs ); branchContextMenu->addAction ( actionEditURL ); branchContextMenu->addAction ( actionEditHeading2URL ); branchContextMenu->addAction ( actionEditBugzilla2URL ); - if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) + if (settings.value( "/mainwindow/showTestMenu",true).toBool() ) { branchContextMenu->addAction ( actionEditFATE2URL ); } @@ -2433,6 +2443,7 @@ 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() ) { @@ -2508,20 +2519,86 @@ currentMapEditor()->findReset(); } +void Main::openTabs(QStringList urls) +{ + if (!urls.isEmpty()) + { + bool success=true; + QStringList args; + QString browser=settings.value("/mainwindow/readerURL" ).toString(); + QProcess *p; + if (!procBrowser || procBrowser->state()!=QProcess::Running) + { + QString u=urls.takeFirst(); + procBrowser = new QProcess( this ); + args<start(browser,args); + if ( !procBrowser->waitForStarted()) + { + // try to set path to browser + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't find a viewer to open %1.\n").arg(u)+ + tr("Please use Settings->")+tr("Set application to open an URL")); + return; + } + sleep (3); + } + if (browser.contains("konqueror")) + { + for (int i=0; ipid())<< + "konqueror-mainwindow#1"<< + "newTab" << + urls.at(i); + p->start ("dcop",args); + if ( !p->waitForStarted() ) success=false; + } + if (!success) + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); + return; + } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) + { + for (int i=0; istart (browser,args); + if ( !p->waitForStarted() ) success=false; + } + if (!success) + QMessageBox::warning(0, + tr("Warning"), + tr("Couldn't start %1 to open a new tab").arg(browser)); + return; + } + QMessageBox::warning(0, + tr("Warning"), + tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing.")); + } +} + void Main::editOpenURL() { // Open new browser if (currentMapEditor()) { QString url=currentMapEditor()->getURL(); + QStringList args; if (url=="") return; QString browser=settings.value("/mainwindow/readerURL" ).toString(); - procBrowser = new Q3Process( this ); - - procBrowser->addArgument( browser); - procBrowser->addArgument( url); - - if ( !procBrowser->start() ) + procBrowser = new QProcess( this ); + args<start(browser,args); + if ( !procBrowser->waitForStarted()) { // try to set path to browser QMessageBox::warning(0, @@ -2536,45 +2613,24 @@ { if (currentMapEditor()) { - QString url=currentMapEditor()->getURL(); - if (url=="") return; - QString browser=settings.value("/mainwindow/readerURL" ).toString(); - if (procBrowser && procBrowser->isRunning()) - { - if (browser.contains("konqueror")) - { - // Try to open new tab in existing konqueror started previously by vym - Q3Process *p=new Q3Process (this); - p->addArgument ("dcop"); - p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier())); - p->addArgument ("konqueror-mainwindow#1"); - p->addArgument ("newTab"); - p->addArgument (url); - if ( !p->start() ) - // try to set browser - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); - return; - } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) - { - // Try to open new tab in firefox - Q3Process *p=new Q3Process (this); - p->addArgument (browser); - p->addArgument ("-remote"); - p->addArgument (QString("openurl(%1,new-tab)").arg(url)); - if ( !p->start() ) - // try to set browser - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't start %1 to open a new tab").arg(browser)); - return; - } - } - // Open new browser - editOpenURL(); + QStringList urls; + urls.append(currentMapEditor()->getURL()); + openTabs (urls); } } +void Main::editOpenMultipleURLTabs() +{ + if (currentMapEditor()) + { + QStringList urls; + urls.append ("www.suse.de"); + urls.append ("www.google.de"); + urls.append ("www.heise.de"); + urls.append ("www.insilmaril.de"); + openTabs (urls); + } +} + void Main::editURL() { @@ -2600,6 +2656,54 @@ currentMapEditor()->editFATE2URL(); } +void Main::editHeading() +{ + if (lineedit->isVisible()) + { + if (currentMapEditor()) + currentMapEditor()->setHeading(lineedit->text()); + lineedit->releaseKeyboard(); + lineedit->hide(); + setFocus(); + } else + { + if (currentMapEditor()) + { + bool ok; + QPoint p; + QString s=currentMapEditor()->getHeading(ok,p); + + if (ok) + { +#if defined(Q_OS_MACX) + p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p)); + QDialog *d =new QDialog(NULL); + QLineEdit *le=new QLineEdit (d); + d->setWindowFlags (Qt::FramelessWindowHint); + d->setGeometry(p.x(),p.y(),200,25); + le->resize (d->size()); + le->setText (s); + le->selectAll(); + connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); + d->activateWindow(); + d->exec(); + currentMapEditor()->setHeading (le->text()); +#else + p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p)); + lineedit->setGeometry(p.x(),p.y(),200,25); + lineedit->setText(s); + lineedit->setCursorPosition(1); + lineedit->selectAll(); + lineedit->show(); + lineedit->grabKeyboard(); + lineedit->setFocus(); +#endif + + } + } + } +} + void Main::editOpenVymLink() { // Get current path to map @@ -2689,15 +2793,10 @@ } } -void Main::editHeading() -{ - if (currentMapEditor()) - currentMapEditor()->editHeading(); -} - void Main::editNewBranch() { - if (currentMapEditor()) + + if (!lineedit->isVisible() && currentMapEditor()) currentMapEditor()->addNewBranch(0); } diff -r 699f28529079 -r 41c3d7f9f532 mainwindow.h --- a/mainwindow.h Tue Aug 15 12:01:14 2006 +0000 +++ b/mainwindow.h Tue Aug 29 08:31:42 2006 +0000 @@ -1,17 +1,12 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include -#include -#include -#include -#include #include +#include #include +#include #include -#include -#include -#include +#include //Added by qt3to4: #include #include @@ -94,16 +89,20 @@ void editOpenFindWindow(); void editFind(QString); void editFindChanged(); +private: + void openTabs(QStringList); public slots: void editOpenURL(); void editOpenURLTab(); private slots: + void editOpenMultipleURLTabs(); void editURL(); void editHeading2URL(); void editBugzilla2URL(); void editFATE2URL(); void editVymLink(); public slots: + void editHeading(); void editOpenVymLink(); private slots: void editDeleteVymLink(); @@ -113,7 +112,6 @@ void editMoveDown(); void editToggleScroll(); void editUnScrollAll(); - void editHeading(); void editNewBranch(); void editNewBranchHere(); void editNewBranchAbove(); @@ -188,9 +186,11 @@ FindWindow *findWindow; QStringList lastMaps; int maxLastMaps; - Q3Process *procBrowser; + QProcess *procBrowser; QStringList imageTypes; + + QLineEdit *lineedit; // to enter headings of branches }; diff -r 699f28529079 -r 41c3d7f9f532 mapeditor.cpp --- a/mapeditor.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/mapeditor.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -44,7 +44,6 @@ #include "linkablemapobj.h" #include "mainwindow.h" #include "misc.h" -#include "settings.h" #include "texteditor.h" #include "warningdialog.h" #include "xml.h" @@ -63,6 +62,7 @@ extern QAction *actionFileSave; extern QAction *actionEditUndo; +extern QAction *actionEditRedo; extern QAction *actionEditCopy; extern QAction *actionEditCut; extern QAction *actionEditPaste; @@ -177,10 +177,6 @@ printer=NULL; - lineedit = new QLineEdit(this, "lineedit" ); - connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) ); - lineedit->hide(); - actColor=Qt::black; setColor (actColor); defLinkColor=QColor (0,0,255); defXLinkColor=QColor (180,180,180); @@ -207,6 +203,8 @@ selectionLast=NULL; movingObj=NULL; + xelection.setMapCenter (mapCenter); + defXLinkWidth=1; defXLinkColor=QColor (230,230,230); @@ -220,8 +218,6 @@ mapName=""; undosTotal=settings.readNumEntry("/mapeditor/undoLevels",50); - undosAvail=0; - undoNum=0; // Initialize find routine itFind=NULL; @@ -248,6 +244,8 @@ historyWindow->setCaption (fileName); mapCenter->reposition(); // for positioning heading + + } MapEditor::~MapEditor() @@ -372,7 +370,8 @@ void MapEditor::makeTmpDirs() { // Create unique temporary directories - tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum); + tmpMapDir=QDir::convertSeparators (tmpVymDir+QString("/mapeditor-%1").arg(mapNum)); + histPath=QDir::convertSeparators (tmpMapDir+"/history"); QDir d; d.mkdir (tmpMapDir,true); } @@ -458,32 +457,29 @@ return s; } -void MapEditor::saveState(const QString &comment) +void MapEditor::saveStateComplete(const QString &comment) { // Save complete map saveState (CompleteMap,"",NULL,"",NULL, comment); } -void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment) +void MapEditor::saveStatePart(LinkableMapObj *undoSel, const QString &comment) { - // save the given part of the map + // save the selected part of the map saveState (PartOfMap,"",undoSel,"",NULL, comment); } -void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment) +void MapEditor::saveStateConstSelection(const QString &uc, const QString &rc, const QString &comment) { // selection does not change during action, // so just save commands for undo and redo - LinkableMapObj *unsel; - if (selection) - unsel=selection; - else - unsel=NULL; - saveState (UndoCommand,uc,unsel,rc,unsel, comment); + // and use current selection + saveState (UndoCommand,uc,selection,rc,selection, comment); } -void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment) +void MapEditor::saveStateX(LinkableMapObj *unsel, const QString &uncom, const QString &comment) { + // saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment); } @@ -494,24 +490,24 @@ if (blockSaveState) return; /* TODO remove after testing + */ cout << "ME::saveState() begin\n"<append (comment); setChanged(); + int undosAvail=undoSet.readNumEntry ("/history/undosAvail",0); + int curStep=undoSet.readNumEntry ("/history/curStep",0); // Find out current undo directory if (undosAvailundosTotal) undoNum=1; + curStep++; + if (curStep>undosTotal) curStep=1; QString backupXML; - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum)); + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml"); // Create bakMapDir if not available @@ -550,28 +546,27 @@ // Write XML Data to disk saveStringToDisk (QString(bakMapPath),backupXML); - SimpleSettings set; - set.setEntry (QString("undoCommand"),undoCommand); - set.setEntry (QString("undoSelection"),undoSelection); - set.setEntry (QString("redoCommand"),redoCom); - set.setEntry (QString("redoSelection"),redoSelection); - set.setEntry (QString("comment"),comment); - set.writeSettings(QString(bakMapDir+"/commands")); + undoSet.setEntry ("/history/undosAvail",QString::number(undosAvail)); + undoSet.setEntry ("/history/curStep",QString::number(curStep)); + undoSet.setEntry (QString("/history/step-%1/undoCommand").arg(curStep),undoCommand); + undoSet.setEntry (QString("/history/step-%1/undoSelection").arg(curStep),undoSelection); + undoSet.setEntry (QString("/history/step-%1/redoCommand").arg(curStep),redoCom); + undoSet.setEntry (QString("/history/step-%1/redoSelection").arg(curStep),redoSelection); + undoSet.setEntry (QString("/history/step-%1/comment").arg(curStep),comment); + undoSet.writeSettings(histPath); /* TODO remove after testing - cout << " into="<< bakMapDir<activateStandardFlag(s); + } + } + } + else if (com=="unsetFlag") + { + if (selection && typeid(*selection) == typeid(BranchObj) ) + { + if (api.checkParamCount(1) ) + { + s=api.parString(ok,0); + if (ok) ((BranchObj*)selection)->deactivateStandardFlag(s); + } + } + } // Internal commands, used for undo etc. else if (com==QString("undoMap")) { @@ -687,31 +716,6 @@ } } - -void MapEditor::finishedLineEdit() -{ - // This is called by finishedLineEdit or any MapEditor method, - // which wants to assure, that lineedits finish, before e.g. a branch is - // deleted - - // After calling LineEdit and using the clipboard, the - // focus is not any longer on the main widget, we - // have to restore it using parentWidget()->setFocus() - - if (editingBO!=NULL) - { - saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) ); - editingBO->setHeading(lineedit->text() ); - editingBO=NULL; - lineedit->releaseKeyboard(); - lineedit->hide(); - parentWidget()->setFocus(); - mapCenter->reposition(); - adjustCanvasSize(); - ensureSelectionVisible(); - } -} - void MapEditor::toggleHistoryWindow() { if (historyWindow->isVisible()) @@ -748,9 +752,6 @@ void MapEditor::closeMap() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - // Unselect before disabling the toolbar actions if (selection) selection->unselect(); selection=NULL; @@ -816,9 +817,6 @@ ErrorCode MapEditor::load (QString fname, LoadMode lmode) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - ErrorCode err=success; if (lmode==NewMap) @@ -830,7 +828,7 @@ // (map state is set later at end of load...) } else { - saveState(selection,"Load map"); + saveStatePart(selection,"Load map"); } @@ -885,9 +883,6 @@ int MapEditor::save (const SaveMode &savemode) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - int returnCode=0; // The SaveMode UndoCommand is not supported here @@ -935,9 +930,6 @@ void MapEditor::print() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if ( !printer ) { printer = new QPrinter; @@ -1111,9 +1103,6 @@ void MapEditor::exportImage(QString fn) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - setExportMode (true); QPixmap pix (getPixmap()); pix.save(fn, "PNG"); @@ -1132,9 +1121,6 @@ void MapEditor::exportImage(QString fn, QString format) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - setExportMode (true); QPixmap pix (getPixmap()); pix.save(fn, format); @@ -1201,9 +1187,6 @@ void MapEditor::copy() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { // write to directory @@ -1232,124 +1215,134 @@ void MapEditor::redo() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - blockSaveState=true; + // Restore variables + int curStep=undoSet.readNumEntry (QString("/history/curStep")); + int undosAvail=undoSet.readNumEntry (QString("/history/undosAvail")); + int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail")); + if (redosAvail>0) redosAvail--; + if (undosAvailundosTotal) curStep=1; + QString undoCommand= undoSet.readEntry (QString("/history/step-%1/undoCommand").arg(curStep)); + QString undoSelection=undoSet.readEntry (QString("/history/step-%1/undoSelection").arg(curStep)); + QString redoCommand= undoSet.readEntry (QString("/history/step-%1/redoCommand").arg(curStep)); + QString redoSelection=undoSet.readEntry (QString("/history/step-%1/redoSelection").arg(curStep)); + QString comment=undoSet.readEntry (QString("/history/step-%1/comment").arg(curStep)); + // Find out current undo directory - QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum)); - - // Restore variables - QString undoCommand; - QString undoSelection; - QString redoCommand; - QString redoSelection; - SimpleSettings set; - set.readSettings(QString(bakMapDir+"/commands")); - undoCommand=set.readEntry ("undoCommand"); - undoSelection=set.readEntry ("undoSelection"); - redoCommand=set.readEntry ("redoCommand"); - redoSelection=set.readEntry ("redoSelection"); + QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(curStep)); + +/* TODO remove testing +*/ + cout << "ME::redo() begin\n"; + cout << " undosAvail="<reposition(); + + //if (!redoSelection.isEmpty()) + // select (redoSelection); + + blockSaveState=false; /* TODO remove testing - cout << "ME::redo() begin\n"; - cout << " undosTotal="<reposition(); //if (!redoSelection.isEmpty()) // select (redoSelection); + undosAvail--; if (undosAvail<1) // Undo not longer available now actionEditUndo->setEnabled (false); else - undoNum--; if (undoNum<1) undoNum=undosTotal; + curStep--; if (curStep<1) curStep=undosTotal; + + redosAvail++; blockSaveState=false; /* TODO remove testing - cout << "ME::redo() end\n"; - cout << " undosAvail="<reposition(); - - //if (!redoSelection.isEmpty()) - // select (redoSelection); - - undosAvail--; - if (undosAvail<1) - // Undo not longer available now - actionEditUndo->setEnabled (false); - else - undoNum--; if (undoNum<1) undoNum=undosTotal; - - blockSaveState=false; -/* TODO remove testing +*/ cout << "ME::undo() end\n"; cout << " undosAvail="<reposition(); adjustCanvasSize(); @@ -1426,7 +1416,7 @@ void MapEditor::cut() { - saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection))); + saveStatePart(selection->getParObj(),QString("Cut %1").arg(getName(selection))); copy(); cutNoSave(); mapCenter->reposition(); @@ -1443,9 +1433,6 @@ void MapEditor::moveBranchUp() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (typeid(*selection) == typeid(BranchObj) ) @@ -1456,7 +1443,7 @@ selection->unselect(); selection=par->moveBranchUp (bo); selection->select(); - saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo))); + saveStateX(bo,"moveBranchDown ()",QString("Move up %1").arg(getName(bo))); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1464,9 +1451,6 @@ void MapEditor::moveBranchDown() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (typeid(*selection) == typeid(BranchObj) ) @@ -1477,7 +1461,7 @@ selection->unselect(); selection=par->moveBranchDown(bo); selection->select(); - saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo))); + saveStateX(bo,"moveBranchUp ()",QString("Move down %1").arg(getName(bo))); mapCenter->reposition(); ensureSelectionVisible(); } @@ -1485,32 +1469,56 @@ void MapEditor::editHeading() { - // Finish open lineEdits - if (lineedit->isVisible()) - { - finishedLineEdit(); - return; - } - +/* FIXME not needed any longer if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { editingBO=(BranchObj*)selection; - ensureSelectionVisible(); QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y())); - lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25); - QString s=editingBO->getHeading(); - lineedit->setText(s); - lineedit->setCursorPosition(1); - if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() ) - lineedit->selectAll(); - lineedit->show(); - lineedit->setFocus(); - lineedit->grabKeyboard(); - cout << "le="<getHeading()+"\")", + "setHeading (\""+le->text()+"\")", + QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(le->text()) ); + editingBO->setHeading(le->text() ); + editingBO=NULL; + mapCenter->reposition(); + adjustCanvasSize(); + ensureSelectionVisible(); + activateWindow(); + } +*/ +} + +QString MapEditor::getHeading(bool &ok, QPoint &p) +{ + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ok=true; + ensureSelectionVisible(); + p = ((BranchObj*)selection)->getAbsPos(); + p.setY(p.y()+((BranchObj*)selection)->height()/2); +// p = mapTo(mainWindow,worldMatrix().map( p)); + return ((BranchObj*)selection)->getHeading(); + } + ok=false; + return QString(); } void MapEditor::setHeading(const QString &s) @@ -1520,14 +1528,20 @@ (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { - ((BranchObj*)selection)->setHeading(s); + editingBO=(BranchObj*)selection; + saveStateConstSelection( + "setHeading (\""+editingBO->getHeading()+"\")", + "setHeading (\""+s+"\")", + QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(s) ); + editingBO->setHeading(s ); + editingBO=NULL; mapCenter->reposition(); adjustCanvasSize(); ensureSelectionVisible(); } } -void MapEditor::setURL (const QString &s) +void MapEditor::setURLInt (const QString &s) { // Internal function, no saveState needed if (selection && @@ -1541,7 +1555,20 @@ } } -void MapEditor::setVymLink (const QString &s) +void MapEditor::setHeadingInt(const QString &s) +{ + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ((BranchObj*)selection)->setHeading(s); + mapCenter->reposition(); + adjustCanvasSize(); + ensureSelectionVisible(); + } +} + +void MapEditor::setVymLinkInt (const QString &s) { // Internal function, no saveState needed if (selection && @@ -1557,15 +1584,11 @@ void MapEditor::addNewBranch(int pos) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { BranchObj* bo1 = (BranchObj*) selection; - saveState(selection, QString("Add new branch to %1").arg(getName(bo1))); //TODO undoCommand bool wasScrolled=false; BranchObj *newbo=NULL; @@ -1588,14 +1611,65 @@ newbo=parbo->insertBranch(bo1->getNum()+1); } else // This should not happen... + // ...but it happens if CTRL-A is pressed on MCO, + // ignore it then return; - } + saveStateX(selection,QString ("delete (\"%1\")").arg(newbo->getSelectString()),QString("Add new branch to %1").arg(getName(bo1))); //TODO undoCommand LinkableMapObj *oldselection=selection; mapCenter->reposition(); adjustCanvasSize(); + + + if (actionSettingsAutoedit->isOn() || + actionSettingsAutoselectHeading->isOn() ) + { + selection->unselect(); + selection=newbo; + selection->select(); + if (actionSettingsPasteNewHeading->isOn() ) + { + BranchObj *bo2= (BranchObj*)selection; + bo2->setHeading(""); + } + if (actionSettingsAutoedit->isOn() ) + mainWindow->editHeading(); + if (!actionSettingsAutoselectHeading->isOn() + && !wasScrolled) + { + selection->unselect(); + selection=oldselection; + selection->select(); + } + } + } +} + + +void MapEditor::addNewBranchHere() +{ + if (selection && + (typeid(*selection) == typeid(BranchObj) ) ) + { + BranchObj* bo1 = (BranchObj*) selection; + saveStatePart(selection, QString("Add new branch here").arg(getName(bo1))); + + bool wasScrolled=false; + BranchObj *newbo=NULL; + BranchObj *parbo=(BranchObj*)(selection->getParObj()); + if (parbo) + { + // add below selection + newbo=parbo->insertBranch(bo1->getNum()+1); + } + + LinkableMapObj *oldselection=selection; + ((BranchObj*)selection)->moveBranchTo (newbo,-1); + + mapCenter->reposition(); + adjustCanvasSize(); if (actionSettingsAutoedit->isOn() || actionSettingsAutoselectHeading->isOn() ) { @@ -1620,61 +1694,8 @@ } } - -void MapEditor::addNewBranchHere() -{ - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - - if (selection && - (typeid(*selection) == typeid(BranchObj) ) ) - { - BranchObj* bo1 = (BranchObj*) selection; - saveState(selection, QString("Add new branch here").arg(getName(bo1))); - - bool wasScrolled=false; - BranchObj *newbo=NULL; - BranchObj *parbo=(BranchObj*)(selection->getParObj()); - if (parbo) - { - // add below selection - newbo=parbo->insertBranch(bo1->getNum()+1); - } - - LinkableMapObj *oldselection=selection; - ((BranchObj*)selection)->moveBranchTo (newbo,-1); - - mapCenter->reposition(); - adjustCanvasSize(); - if (actionSettingsAutoedit->isOn() || - actionSettingsAutoselectHeading->isOn() ) - { - selection->unselect(); - selection=newbo; - selection->select(); - if (actionSettingsPasteNewHeading->isOn() ) - { - BranchObj *bo2= (BranchObj*)selection; - bo2->setHeading(""); - } - if (actionSettingsAutoedit->isOn() ) - editHeading(); - if (!actionSettingsAutoselectHeading->isOn() - && !wasScrolled) - { - selection->unselect(); - selection=oldselection; - selection->select(); - } - } - } -} - void MapEditor::deleteSelection() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection && typeid(*selection) ==typeid(BranchObj) ) { BranchObj* bo=dynamic_cast (selection); @@ -1682,12 +1703,12 @@ bo->unselect(); if (selection->getDepth()>1) // Normal branch, save parent with childs - saveState(par,QString("Delete %1").arg(getName(bo))); + saveStatePart(par,QString("Delete %1").arg(getName(bo))); else // Mainbranch, save whole map // TODO Better would be to insert mainbranch again at pos // But undoCommand is missing right now - saveState(QString("Delete %1").arg(getName(bo))); + saveStateComplete(QString("Delete %1").arg(getName(bo))); selection=NULL; par->removeBranch(bo); selection=par; @@ -1700,7 +1721,7 @@ { FloatImageObj* fio=dynamic_cast (selection); BranchObj* par=(BranchObj*)(fio->getParObj()); - saveState(par, QString("Delete %1").arg(getName(fio))); + saveStatePart(par, QString("Delete %1").arg(getName(fio))); fio->unselect(); selection=NULL; par->removeFloatImage(fio); @@ -1754,7 +1775,7 @@ return false; } -void MapEditor::select (LinkableMapObj *lmo) +void MapEditor::selectInt (LinkableMapObj *lmo) { if (lmo && selection != lmo) { @@ -1768,7 +1789,7 @@ } -void MapEditor::selectNextBranch() +void MapEditor::selectNextBranchInt() { // Increase number of branch if (selection) @@ -1848,7 +1869,7 @@ } } -void MapEditor::selectPrevBranch() +void MapEditor::selectPrevBranchInt() { // Decrease number of branch if (selection) @@ -1929,40 +1950,34 @@ void MapEditor::selectUpperBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { if (typeid(*selection) == typeid(BranchObj)) { if (selection->getOrientation()==OrientRightOfCenter) - selectPrevBranch(); + selectPrevBranchInt(); else if (selection->getDepth()==1) - selectNextBranch(); + selectNextBranchInt(); else - selectPrevBranch(); + selectPrevBranchInt(); } } } void MapEditor::selectLowerBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (selection) { if (typeid(*selection) == typeid(BranchObj)) { if (selection->getOrientation()==OrientRightOfCenter) - selectNextBranch(); + selectNextBranchInt(); else if (selection->getDepth()==1) - selectPrevBranch(); + selectPrevBranchInt(); else - selectNextBranch(); + selectNextBranchInt(); } } } @@ -1970,9 +1985,6 @@ void MapEditor::selectLeftBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; if (selection) @@ -2032,9 +2044,6 @@ void MapEditor::selectRightBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj* bo; BranchObj* par; @@ -2046,7 +2055,7 @@ bo=par->getLastSelectedBranch(); if (bo) { - // Workaround for relecting on left and right side + // Workaround for reselecting on left and right side if (bo->getOrientation()==OrientLeftOfCenter) bo=par->getFirstBranch(); if (bo) @@ -2092,9 +2101,6 @@ void MapEditor::selectFirstBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj *bo1; BranchObj *bo2; BranchObj* par; @@ -2117,9 +2123,6 @@ void MapEditor::selectLastBranch() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - BranchObj *bo1; BranchObj *bo2; BranchObj* par; @@ -2147,13 +2150,11 @@ void MapEditor::selectBackgroundColor() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this ); if ( !col.isValid() ) return; setBackgroundColor( col ); - saveState(QString("Set background color of map to %1").arg(col.name())); + //TODO undocomm + saveStateComplete(QString("Set background color of map to %1").arg(col.name())); } void MapEditor::setBackgroundColor(QColor c) @@ -2183,7 +2184,7 @@ typeid(*selection) == typeid(MapCenterObj)) { BranchObj *bo=(BranchObj*)selection; - saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand + saveStatePart(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand bo->setColor(actColor); // color branch } } @@ -2197,7 +2198,7 @@ typeid(*selection) == typeid(MapCenterObj)) { BranchObj *bo=(BranchObj*)selection; - saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand + saveStatePart(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name())); //TODO undoCommand bo->setColorChilds(actColor); // color links, color childs } } @@ -2212,12 +2213,20 @@ typeid(*selection) == typeid(MapCenterObj)) { BranchObj *bo=(BranchObj*)selection; - QString s; + QString u,r; if (bo->isSetStandardFlag(f)) - s="Unset"; + { + r="unsetFlag"; + u="setFlag"; + } else - s="Set"; - saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand + { + u="unsetFlag"; + r="setFlag"; + } + saveStateConstSelection(QString("%1 (\"%2\")").arg(u).arg(f), + QString("%1 (\"%2\")").arg(r).arg(f), + QString("Toggling standard flag \"%1\" of %2").arg(f).arg(getName(bo))); bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn()); adjustCanvasSize(); } @@ -2311,7 +2320,7 @@ if ( ok) { // user entered something and pressed OK - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text)); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text)); bo->setURL (text); updateActions(); } @@ -2333,7 +2342,7 @@ typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo))); bo->setURL (bo->getHeading()); updateActions(); } @@ -2346,7 +2355,7 @@ { BranchObj *bo=(BranchObj*)selection; QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading(); - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo))); bo->setURL (url); updateActions(); } @@ -2359,7 +2368,7 @@ { BranchObj *bo=(BranchObj*)selection; QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading(); - saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo))); + saveStateConstSelection("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo))); bo->setURL (url); updateActions(); } @@ -2381,7 +2390,7 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())); + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile())); bo->setVymLink (fd->selectedFile() ); updateActions(); mapCenter->reposition(); @@ -2397,7 +2406,7 @@ typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=(BranchObj*)selection; - saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo))); + saveStateConstSelection("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo))); bo->setVymLink ("" ); updateActions(); mapCenter->reposition(); @@ -2425,7 +2434,7 @@ oo->setHideInExport(true); s="Set"; } - saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand + saveStateComplete(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection))); //TODO undoCommand actionEditToggleHideExport->setOn (oo->hideInExport()); updateActions(); mapCenter->reposition(); @@ -2453,9 +2462,9 @@ BranchObj* par=(BranchObj*)(bo->getParObj()); QString s=QString("Remove %1 and keep its childs").arg(getName(bo)); if (bo->getDepth()==1) - saveState(s); + saveStateComplete(s); else - saveState(selection->getParObj(),s); // TODO undoCommand + saveStatePart(selection->getParObj(),s); // TODO undoCommand QString sel=selection->getSelectString(); unselect(); par->removeBranchHere(bo); @@ -2468,7 +2477,7 @@ { if (selection && (typeid(*selection) == typeid(BranchObj) )) { - saveState(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection))); + saveStatePart(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection))); ((BranchObj*)selection)->removeChilds(); mapCenter->reposition(); } @@ -2512,7 +2521,7 @@ // Finally show dialog if (dia.exec() == QDialog::Accepted) { - saveState("Edit info about map"); //TODO undoCommand + saveStateComplete("Edit info about map"); //TODO undoCommand mapCenter->setAuthor (dia.getAuthor() ); mapCenter->setComment (dia.getComment() ); } @@ -2550,8 +2559,16 @@ pix.fill( defLinkColor ); actionFormatLinkColor->setIconSet( pix ); - actionEditUndo->setEnabled( mapChanged ); actionFileSave->setEnabled( mapUnsaved ); + if (undoSet.readNumEntry("/history/undosAvail",0)>0) + actionEditUndo->setEnabled( true); + else + actionEditUndo->setEnabled( false); + + if (undoSet.readNumEntry("/history/redosAvail",0)>0) + actionEditRedo->setEnabled( true); + else + actionEditRedo->setEnabled( false); if (selection) { @@ -2710,7 +2727,7 @@ { linkstyle=ls; - saveState("Set link style"); // TODO undoCommand + saveStateComplete("Set link style"); // TODO undoCommand BranchObj *bo; bo=mapCenter->first(); bo=bo->next(); @@ -2798,13 +2815,10 @@ void MapEditor::selectLinkColor() { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QColor col = QColorDialog::getColor( defLinkColor, this ); if ( !col.isValid() ) return; setLinkColor( col ); - saveState(QString("Set link color to %1").arg(col.name())); //TODO undoCommand + saveStateComplete(QString("Set link color to %1").arg(col.name())); //TODO undoCommand } @@ -2820,7 +2834,7 @@ s="Unscroll"; else s="Scroll"; - saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo))); + saveStatePart(selection, QString ("%1 %2").arg(s).arg(getName(bo))); bo->toggleScroll(); adjustCanvasSize(); canvas()->update(); @@ -2860,7 +2874,7 @@ QString fn; if ( fd->exec() == QDialog::Accepted ) { - saveState(selection, QString("Add floatimage to %1").arg(getName(selection))); + saveStatePart(selection, QString("Add floatimage to %1").arg(getName(selection))); // FIXME in QT4 use: lastImageDir=fd->directory(); lastImageDir=QDir (fd->dirPath()); QStringList flist = fd->selectedFiles(); @@ -2968,7 +2982,7 @@ selection->setHideLinkUnselected(b); } -void MapEditor::importDir(BranchObj *dst, QDir d) +void MapEditor::importDirInt(BranchObj *dst, QDir d) { if (selection && (typeid(*selection) == typeid(BranchObj)) || @@ -2996,7 +3010,7 @@ else { // Recursively add subdirs - importDir (bo,d); + importDirInt (bo,d); d.cdUp(); } } @@ -3034,7 +3048,7 @@ if ( fd->exec() == QDialog::Accepted ) { BranchObj *bo=((BranchObj*)selection); - importDir (bo,QDir(fd->selectedFile()) ); + importDirInt (bo,QDir(fd->selectedFile()) ); mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); @@ -3061,7 +3075,7 @@ void MapEditor::editXLink(int i) { - qDebug ("ko."); + qDebug ("ko."); //FIXME Huh? if (selection && (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj)) ) @@ -3081,7 +3095,7 @@ } if (dia.deleteXLink()) ((BranchObj*)selection)->deleteXLinkAt(i); - saveState("Edit xLink"); //TODO undoCommand + saveStateComplete("Edit xLink"); //TODO undoCommand } } } @@ -3091,32 +3105,43 @@ { cout << "MapEditor::testFunction() called\n"; - mapCenter->positionBBox(); +/* + bool ok; + QString text = QInputDialog::getText( + this, + tr("QInputDialog::getText()"), + tr("User name:"), QLineEdit::Normal, + QDir::home().dirName(), &ok, Qt::FramelessWindowHint); +*/ + + QDialog *d =new QDialog(NULL); + QLineEdit *le=new QLineEdit (d); +// d->setModal (true); + d->setWindowFlags (Qt::FramelessWindowHint); + le->setFocus(); + le->setText ("Foo"); + le->selectAll(); + connect (le, SIGNAL (returnPressed()), d, SLOT (accept())); + d->exec(); + qWarning( le->text()); return; - + + + +/* WarningDialog dia; dia.setCancelButton (true); dia.setText("This is a longer \nWarning"); dia.setCaption("Warning: Flux problem"); dia.setShowAgainName("/warnings/mapeditor"); + dia.setWindowFlags (Qt::FramelessWindowHint); if (dia.exec()==QDialog::Accepted) cout << "accepted!\n"; else cout << "canceled!\n"; return; - - QString ub=vymBaseDir.path()+"/scripts/update-bookmarks"; - - QProcess *proc= new QProcess (this); - proc->start( ub); - if (!proc->waitForStarted()); - { - QMessageBox::warning(0, - tr("Warning"), - tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub)); - } - - +*/ + /* Hide hidden stuff temporary, maybe add this as regular function somewhere if (hidemode==HideNone) { @@ -3222,9 +3247,6 @@ return; } - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - QPoint p = inverseWorldMatrix().map(e->pos()); LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); @@ -3239,7 +3261,7 @@ if (!foname.isEmpty()) { // systemFlag clicked - select (lmo); + selectInt (lmo); if (foname=="url") { if (e->state() & Qt::ControlModifier) @@ -3297,7 +3319,7 @@ } if (lmo) { - select (lmo); + selectInt (lmo); // Left Button Move Branches if (e->button() == Qt::LeftButton ) { @@ -3370,7 +3392,7 @@ if (typeid(*selection) == typeid(FloatImageObj)) { FloatObj *fo=(FloatObj*)selection; - saveState( + saveStateConstSelection( "move "+qpointToString(movingObj_orgPos),fo->getSelectString() , QString("Move %1").arg(getName(selection))); fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); @@ -3387,7 +3409,8 @@ { if (typeid(*fo) == typeid(FloatImageObj)) { - saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) ); + //TODO undocom + saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) ); FloatImageObj *fio=(FloatImageObj*)(fo); ((BranchObj*)(lmo))->addFloatImage (fio); fio->unselect(); @@ -3513,7 +3536,7 @@ tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); tmpXLink->activate(); - saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand + saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand } else { delete(tmpXLink); @@ -3578,11 +3601,11 @@ if (dst->getDepth()==0) bs->move (savePos); } - saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) ); + saveStateConstSelection (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) ); } else if (selection->getDepth()==1) // If we have moved mainbranch only save endposition - saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos))); + saveStateConstSelection("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos))); // Draw the original link, before selection was moved around mapCenter->reposition(); @@ -3599,9 +3622,6 @@ void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e) { - // Finish open lineEdits - if (lineedit) finishedLineEdit(); - if (e->button() == Qt::LeftButton ) { QPoint p = inverseWorldMatrix().map(e->pos()); @@ -3782,7 +3802,7 @@ if (update) { //FIXME saveState has to be called earlier for each of the drops... - saveState("Drop Event"); //TODO undo Command + saveStateComplete("Drop Event"); //TODO undo Command mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); @@ -3797,7 +3817,7 @@ (typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=((BranchObj*)selection); - saveState(selection,QString("Add floatimage to %1").arg(getName(bo))); + saveStatePart(selection,QString("Add floatimage to %1").arg(getName(bo))); //QString fn=fd->selectedFile(); //lastImageDir=fn.left(fn.findRev ("/")); bo->addFloatImage(); diff -r 699f28529079 -r 41c3d7f9f532 mapeditor.h --- a/mapeditor.h Tue Aug 15 12:01:14 2006 +0000 +++ b/mapeditor.h Tue Aug 29 08:31:42 2006 +0000 @@ -2,23 +2,24 @@ #define MAPEDITOR_H #include -#include -#include -#include -#include -#include +#include +//#include +#include +//#include #include -//Added by qt3to4: +#include #include #include +#include +#include +#include #include -#include -#include -#include #include "mapcenterobj.h" #include "file.h" #include "misc.h" +#include "selection.h" +#include "settings.h" #include "showtextdialog.h" class Q3NetworkOperation; @@ -41,17 +42,16 @@ QString getName(LinkableMapObj*); // Get e.g. heading or filename void makeTmpDirs(); // create temporary directories QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*); - void saveState(const QString &); // save actual state to backup - void saveState(LinkableMapObj *, const QString &); - void saveState(const QString &, const QString &, const QString &); - void saveState(const QString &, LinkableMapObj *, const QString &); + void saveStateComplete (const QString &); + void saveStatePart (LinkableMapObj *, const QString &); + void saveStateConstSelection (const QString &, const QString &, const QString &); + void saveStateX (LinkableMapObj *, const QString &, const QString &); void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *, const QString &); void parseAtom(const QString &); void addFloatImage(const QPixmap &img); private slots: - void finishedLineEdit(); void fetchImage(const QString &img); void imageDataFetched(const QByteArray &, Q3NetworkOperation *); void imageDataFinished(Q3NetworkOperation *); @@ -99,11 +99,13 @@ void move(const int &,const int&); void moveBranchUp(); void moveBranchDown(); - void editHeading(); // Start editing heading + void editHeading(); // Start editing heading + QString getHeading (bool &,QPoint &); // Get heading, ok if selection is branch + void setHeading(const QString &); private: - void setHeading(const QString &); // Just set the heading for selection - void setURL(const QString &); // Just set the URL for selection - void setVymLink(const QString &); // Set vymLink for selection + void setHeadingInt(const QString &); + void setURLInt(const QString &); // Just set the URL for selection + void setVymLinkInt(const QString &); // Set vymLink for selection public: void addNewBranch(int); // pos allows to add above/below selection void addNewBranchHere(); // insert and make selection its @@ -113,9 +115,9 @@ void reselect(); // after changing current noteedit bool select(const QString &); // Select private: - void select(LinkableMapObj*); - void selectNextBranch(); // Increment number of branch - void selectPrevBranch(); // Decrement number of branch + void selectInt(LinkableMapObj*); + void selectNextBranchInt(); // Increment number of branch + void selectPrevBranchInt(); // Decrement number of branch public: void selectUpperBranch(); void selectLowerBranch(); @@ -170,7 +172,7 @@ void setHideLinkUnselected (bool); bool getHideLinkUnselected (); private: - void importDir(BranchObj *,QDir); + void importDirInt(BranchObj *,QDir); public: void importDir(); void followXLink (int); @@ -194,7 +196,6 @@ bool adjustCanvasRequested; // collect requests until end of user event BranchObj *editingBO; // entering Text into BO - QLineEdit* lineedit; QColor actColor; // actual color QColor defLinkColor; // default color for links @@ -209,7 +210,8 @@ bool drawingLink; // true while creating a link bool copyingObj; // true while creating a link XLinkObj* tmpXLink; - + + Selection xelection; LinkableMapObj* selection; // select a LinkableMapObj LinkableMapObj* selectionLast; // last selection MapObj* movingObj; // moving a MapObj @@ -238,9 +240,9 @@ bool isInteractive; // non interactive don't need tmpdirs QString tmpMapDir; // tmp directory with data for undo/redo + QString histPath; // Path to history file int undosTotal; // total number of undos - int undoNum; // current number of bakMapDir to be used - int undosAvail; // how many actions can currently be undone + SimpleSettings undoSet; // undo/redo commands bool blockReposition; // block while load or undo bool blockSaveState; // block while load or undo diff -r 699f28529079 -r 41c3d7f9f532 ornamentedobj.cpp --- a/ornamentedobj.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/ornamentedobj.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -281,6 +281,15 @@ forceReposition(); } +void OrnamentedObj::deactivateStandardFlag(QString f) +{ + standardFlags->deactivate(f); + calcBBoxSize(); + positionBBox(); + move (absPos.x(), absPos.y() ); + forceReposition(); +} + bool OrnamentedObj::isSetStandardFlag (QString f) { return standardFlags->isActive(f); diff -r 699f28529079 -r 41c3d7f9f532 ornamentedobj.h --- a/ornamentedobj.h Tue Aug 15 12:01:14 2006 +0000 +++ b/ornamentedobj.h Tue Aug 29 08:31:42 2006 +0000 @@ -35,6 +35,7 @@ virtual void toggleStandardFlag(QString, bool); virtual void activateStandardFlag(QString); + virtual void deactivateStandardFlag(QString); virtual bool isSetStandardFlag(QString); virtual QString getSystemFlagName (const QPoint &p); virtual bool isActiveFlag(const QString&); // check if flag is set diff -r 699f28529079 -r 41c3d7f9f532 selection.cpp --- a/selection.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/selection.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -5,21 +5,19 @@ { } -Selection::Selection(const Selection &other) -{ -} - Selection::~Selection() { } -void Selection::init() +void Selection::setMapCenter(MapCenterObj *mco) { - selectList.setAutoDelete(true); + mapCenter=mco; } void Selection::copy(const Selection &other) { + mapCenter=other.mapCenter; + selectList=other.selectList; } void Selection::clear() @@ -29,11 +27,29 @@ bool Selection::select(LinkableMapObj *lmo) { + clear(); + selectList.append (lmo); return false; } -void Selection::unselect(LinkableMapObj *lmo) +bool Selection::select (const QString &s) { + LinkableMapObj *lmo=mapCenter->findObjBySelect(s); + + // Finally select the found object + if (lmo) + { + clear(); + select (lmo); + return true; + } + return false; + +} + +void Selection::unselect() +{ + clear(); } bool Selection::isEmpty() @@ -45,3 +61,14 @@ { return selectList.count(); } + +QString Selection::getSelectString() +{ + // TODO multiselection (maybe separated by ";") + if (selectList.count()==1) + return selectList.first()->getSelectString(); + else + return""; +} + + diff -r 699f28529079 -r 41c3d7f9f532 selection.h --- a/selection.h Tue Aug 15 12:01:14 2006 +0000 +++ b/selection.h Tue Aug 29 08:31:42 2006 +0000 @@ -1,26 +1,32 @@ -#ifndef SELECTIONOBJ_H -#define SELECTIONOBJ_H +#ifndef SELECTION_H +#define SELECTION_H + +#include #include "linkablemapobj.h" -#include +#include "mapcenterobj.h" class Selection { public: Selection (); - Selection (const Selection&); ~Selection(); - void init(); void copy(const Selection&); void clear(); + void setMapCenter (MapCenterObj *); bool select (LinkableMapObj*); - void unselect (LinkableMapObj*); + bool select (const QString &); + void unselect (); bool isEmpty(); uint count(); + QString getSelectString(); + private: - Q3PtrList selectList; + void init(); + QList selectList; + MapCenterObj *mapCenter; }; #endif diff -r 699f28529079 -r 41c3d7f9f532 settings.cpp --- a/settings.cpp Tue Aug 15 12:01:14 2006 +0000 +++ b/settings.cpp Tue Aug 29 08:31:42 2006 +0000 @@ -61,6 +61,7 @@ qWarning ("SimpleSettings::writeSettings() Couldn't write "+path); } +/* QString SimpleSettings::readEntry (const QString &key) { QStringList::Iterator itk=keylist.begin(); @@ -77,6 +78,46 @@ qWarning ("SimpleSettings::readEntry() Couldn't find key "+key); return ""; } +*/ + +QString SimpleSettings::readEntry (const QString &key, const QString &def) +{ + QStringList::Iterator itk=keylist.begin(); + QStringList::Iterator itv=valuelist.begin(); + + // First search for value in settings saved in map + while (itk !=keylist.end() ) + { + if (*itk == key) + return *itv; + itk++; + itv++; + } + return def; +} + +int SimpleSettings::readNumEntry (const QString &key, int def) +{ + QStringList::Iterator itk=keylist.begin(); + QStringList::Iterator itv=valuelist.begin(); + + // First search for value in settings saved in map + while (itk !=keylist.end() ) + { + if (*itk == key) + { + bool ok; + int i=(*itv).toInt(&ok,10); + if (ok) + return i; + else + return def; + } + itk++; + itv++; + } + return def; +} void SimpleSettings::setEntry (const QString &key, const QString &value) { diff -r 699f28529079 -r 41c3d7f9f532 settings.h --- a/settings.h Tue Aug 15 12:01:14 2006 +0000 +++ b/settings.h Tue Aug 29 08:31:42 2006 +0000 @@ -18,7 +18,8 @@ void clear(); void readSettings(const QString &); void writeSettings(const QString &); - QString readEntry (const QString &); + QString readEntry (const QString &key, const QString &def=QString()); + int readNumEntry (const QString &, int=0); void setEntry (const QString &,const QString &); private: QStringList keylist; diff -r 699f28529079 -r 41c3d7f9f532 version.h --- a/version.h Tue Aug 15 12:01:14 2006 +0000 +++ b/version.h Tue Aug 29 08:31:42 2006 +0000 @@ -2,7 +2,7 @@ #define VERSION_H #define __VYM "VYM" -#define __VYM_VERSION "1.8.52" -#define __BUILD_DATE "August 15, 2006" +#define __VYM_VERSION "1.8.53" +#define __BUILD_DATE "August 23, 2006" #endif