diff -r 3590c3490789 -r 56c57552f1d2 mapeditor.cpp --- a/mapeditor.cpp Sun Jul 31 12:24:53 2005 +0000 +++ b/mapeditor.cpp Mon Aug 01 19:32:45 2005 +0000 @@ -706,7 +706,22 @@ s=api.parString (ok,0); if (ok) setHeading (s); } - } + } else if (com=="setURL") + { + if (api.checkParamCount(1)) + { + s=api.parString (ok,0); + if (ok) setURL(s); + } + } else if (com=="setVymLink") + { + if (api.checkParamCount(1)) + { + s=api.parString (ok,0); + if (ok) setVymLink(s); + } + } + // Internal commands, used for undo etc. else if (com==QString("undoMap")) { @@ -1548,6 +1563,34 @@ } } +void MapEditor::setURL (const QString &s) +{ + // Internal function, no saveState needed + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ((BranchObj*)(selection))->setURL(s); + mapCenter->reposition(); + adjustCanvasSize(); + ensureSelectionVisible(); + } +} + +void MapEditor::setVymLink (const QString &s) +{ + // Internal function, no saveState needed + if (selection && + (typeid(*selection) == typeid(BranchObj) || + typeid(*selection) == typeid(MapCenterObj) ) ) + { + ((BranchObj*)(selection))->setVymLink(s); + mapCenter->reposition(); + adjustCanvasSize(); + ensureSelectionVisible(); + } +} + void MapEditor::addNewBranch(int pos) { // Finish open lineEdits @@ -1557,7 +1600,7 @@ (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj) ) ) { - saveState(selection); + saveState(selection); //FIXME undoCommand BranchObj* bo1 = (BranchObj*) (selection); bool wasScrolled=false; @@ -2161,7 +2204,7 @@ if (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj)) { - saveState(selection); + saveState(selection); //FIXME undoCommand BranchObj *bo=(BranchObj*)(selection); bo->setColor(actColor, false); // color links, color childs } @@ -2187,7 +2230,7 @@ { if (selection) { - saveState(selection); + saveState(selection);// FIXME undoCommand ((BranchObj*)(selection))->toggleStandardFlag (f,actionSettingsUseFlagGroups); } } @@ -2297,15 +2340,16 @@ typeid(*selection) == typeid(MapCenterObj)) ) { bool ok; + BranchObj *bo=(BranchObj*)(selection); QString text = QInputDialog::getText( "VYM", tr("Enter URL:"), QLineEdit::Normal, - ((BranchObj*)(selection))->getURL(), &ok, this ); + bo->getURL(), &ok, this ); if ( ok) { // user entered something and pressed OK - ((BranchObj*)(selection))->setURL (text); + saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")"); + bo->setURL (text); updateActions(); - saveState(); //FIXME undoCommand } } } @@ -2315,10 +2359,10 @@ if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj)) ) { - BranchObj *b=(BranchObj*)(selection); - b->setURL (b->getHeading()); + BranchObj *bo=(BranchObj*)(selection); + saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")"); + bo->setURL (bo->getHeading()); updateActions(); - saveState(); //FIXME undoCommand } } @@ -2327,10 +2371,11 @@ if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj)) ) { - BranchObj *b=(BranchObj*)(selection); - b->setURL ("https://bugzilla.novell.com/show_bug.cgi?id="+b->getHeading()); + BranchObj *bo=(BranchObj*)(selection); + QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading(); + saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")"); + bo->setURL (url); updateActions(); - saveState(); //FIXME undoCommand } } @@ -2339,21 +2384,24 @@ if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj)) ) { + BranchObj *bo=(BranchObj*)(selection); QFileDialog *fd=new QFileDialog( this,tr("VYM - Link to another map")); fd->addFilter (QString (tr("vym map") + " (*.vym)")); fd->setCaption(tr("VYM - Link to another map")); - if (! ((BranchObj*)(selection))->getVymLink().isEmpty() ) - fd->setSelection( ((BranchObj*)(selection))->getVymLink() ); + if (! bo->getVymLink().isEmpty() ) + fd->setSelection( bo->getVymLink() ); fd->show(); QString fn; if ( fd->exec() == QDialog::Accepted ) - ((BranchObj*)(selection))->setVymLink (fd->selectedFile() ); - updateActions(); - mapCenter->reposition(); - adjustCanvasSize(); - canvas()->update(); - saveState(); //FIXME undoCommand + { + saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")"); + bo->setVymLink (fd->selectedFile() ); + updateActions(); + mapCenter->reposition(); + adjustCanvasSize(); + canvas()->update(); + } } } @@ -2362,12 +2410,13 @@ if (selection && (typeid(*selection) == typeid(BranchObj) || typeid(*selection) == typeid(MapCenterObj)) ) { - ((BranchObj*)(selection))->setVymLink ("" ); + BranchObj *bo=(BranchObj*)(selection); + saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")"); + bo->setVymLink ("" ); updateActions(); mapCenter->reposition(); adjustCanvasSize(); canvas()->update(); - saveState(); //FIXME undoCommand } }