diff -r 087e60400acc -r 1b52ff19aad5 mapeditor.cpp --- a/mapeditor.cpp Wed Jul 27 18:56:35 2005 +0000 +++ b/mapeditor.cpp Tue Aug 02 08:12:14 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 } }