1.1 --- a/mapeditor.cpp Mon Oct 30 12:39:37 2006 +0000
1.2 +++ b/mapeditor.cpp Thu Nov 16 10:07:11 2006 +0000
1.3 @@ -91,13 +91,18 @@
1.4 linkstyle=StylePolyParabel;
1.5
1.6 // Create bitmap cursors, platform dependant
1.7 - #if defined(Q_OS_MACX)
1.8 - handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png"),1,1 );
1.9 - pickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 );
1.10 - #else
1.11 - handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);
1.12 - pickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 );
1.13 - #endif
1.14 + // FIXME should now work also on Mac...
1.15 + //#if defined(Q_OS_MACX)
1.16 + // HandOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png"),1,1 );
1.17 + // PickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 );
1.18 + //#else
1.19 + HandOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen.png"),1,1);
1.20 + PickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 );
1.21 + CopyCursor=QCursor ( QPixmap(iconPath+"cursorcopy.png"), 5,5 );
1.22 + XLinkCursor=QCursor ( QPixmap(iconPath+"cursorxlink.png"), 5,27 );
1.23 + //#endif
1.24 +
1.25 + setFocusPolicy (Qt::StrongFocus);
1.26
1.27 pickingColor=false;
1.28 drawingLink=false;
1.29 @@ -122,7 +127,7 @@
1.30 fileName=tr("unnamed");
1.31 mapName="";
1.32
1.33 - stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",50);
1.34 + stepsTotal=settings.readNumEntry("/mapeditor/stepsTotal",100);
1.35 undoSet.setEntry ("/history/stepsTotal",QString::number(stepsTotal));
1.36
1.37 // Initialize find routine
1.38 @@ -162,11 +167,6 @@
1.39 //cout <<"Destructor MapEditor\n";
1.40 }
1.41
1.42 -QColor MapEditor::getBackgroundColor()
1.43 -{
1.44 - return mapCanvas->backgroundColor();
1.45 -}
1.46 -
1.47 MapCenterObj* MapEditor::getMapCenter()
1.48 {
1.49 return mapCenter;
1.50 @@ -304,7 +304,7 @@
1.51 colhint=attribut("linkColorHint","HeadingColor");
1.52
1.53 QString mapAttr=attribut("version",__VYM_VERSION);
1.54 - if (!saveSel)
1.55 + if (!saveSel || saveSel==mapCenter)
1.56 mapAttr+= attribut("author",mapCenter->getAuthor()) +
1.57 attribut("comment",mapCenter->getComment()) +
1.58 attribut("date",mapCenter->getDate()) +
1.59 @@ -324,7 +324,7 @@
1.60 FloatImageObj (mapCanvas).resetSaveCounter();
1.61
1.62 // Build xml recursivly
1.63 - if (!saveSel)
1.64 + if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj))
1.65 // Save complete map, if saveSel not set
1.66 s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
1.67 else
1.68 @@ -338,6 +338,7 @@
1.69
1.70 else if (selection && typeid(*selection)==typeid(BranchObj))
1.71 // Save selected branch is saved from mainwindow //FIXME maybe use "subtree" above?
1.72 + // FIXME is this possible at all? BO is already above...
1.73 s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
1.74 }
1.75
1.76 @@ -356,16 +357,6 @@
1.77 return s;
1.78 }
1.79
1.80 -void MapEditor::saveStateComplete(const QString &comment)
1.81 -{
1.82 - // Save complete map, Undo will replace whole map
1.83 - saveState (CompleteMap,
1.84 - "", "",
1.85 - "", "",
1.86 - comment,
1.87 - mapCenter);
1.88 -}
1.89 -
1.90 void MapEditor::saveStateChangingPart(LinkableMapObj *undoSel, LinkableMapObj* redoSel, const QString &rc, const QString &comment)
1.91 {
1.92 // save the selected part of the map, Undo will replace part of map
1.93 @@ -382,7 +373,7 @@
1.94
1.95
1.96 saveState (PartOfMap,
1.97 - undoSelection, "",
1.98 + undoSelection, "addMapReplace (\"PATH\")",
1.99 redoSelection, rc,
1.100 comment,
1.101 undoSel);
1.102 @@ -397,7 +388,7 @@
1.103 }
1.104 QString undoSelection=redoSel->getParObj()->getSelectString();
1.105 QString redoSelection=redoSel->getSelectString();
1.106 - if (typeid(*redoSel) == typeid(BranchObj) && redoSel->getDepth()>1 )
1.107 + if (typeid(*redoSel) == typeid(BranchObj) )
1.108 {
1.109 // save the selected branch of the map, Undo will insert part of map
1.110 saveState (PartOfMap,
1.111 @@ -405,15 +396,6 @@
1.112 redoSelection, "delete ()",
1.113 comment,
1.114 redoSel);
1.115 - } else if (typeid(*redoSel) == typeid(BranchObj) )
1.116 - {
1.117 - // save the selected mainbranch of the map, Undo will insert part of map
1.118 - saveState (PartOfMap,
1.119 - undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(((BranchObj*)redoSel)->getNum()),
1.120 - redoSelection, "delete ()",
1.121 - comment,
1.122 - redoSel);
1.123 -
1.124 }
1.125 }
1.126
1.127 @@ -467,7 +449,7 @@
1.128 curStep++;
1.129 if (curStep>stepsTotal) curStep=1;
1.130
1.131 - QString backupXML;
1.132 + QString backupXML="";
1.133 QString bakMapName=QDir::convertSeparators (QString("history-%1").arg(curStep));
1.134 QString bakMapDir=QDir::convertSeparators (tmpMapDir +"/"+bakMapName);
1.135 QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml");
1.136 @@ -478,9 +460,7 @@
1.137 makeSubDirs (bakMapDir);
1.138
1.139 // Save depending on how much needs to be saved
1.140 - if (!saveSel)
1.141 - backupXML="";
1.142 - else
1.143 + if (saveSel)
1.144 backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),saveSel);
1.145
1.146 QString undoCommand="";
1.147 @@ -492,10 +472,8 @@
1.148 {
1.149 undoCommand=undoCom;
1.150 undoCommand.replace ("PATH",bakMapPath);
1.151 - } else
1.152 - {
1.153 - undoCommand="undoMap (\""+bakMapPath+"\")";
1.154 }
1.155 +
1.156 if (!backupXML.isEmpty())
1.157 // Write XML Data to disk
1.158 saveStringToDisk (QString(bakMapPath),backupXML);
1.159 @@ -529,6 +507,7 @@
1.160 cout << " undoSel="<<undoSelection.toStdString()<<endl;
1.161 cout << " redoCom="<<redoCom.toStdString()<<endl;
1.162 cout << " redoSel="<<redoSelection.toStdString()<<endl;
1.163 + if (saveSel) cout << " saveSel="<<saveSel->getSelectString().ascii()<<endl;
1.164 cout << " ---------------------------"<<endl;
1.165
1.166 historyWindow.update (undoSet);
1.167 @@ -597,12 +576,12 @@
1.168 typeid(*selection) != typeid(MapCenterObj)) )
1.169 {
1.170 api.setError (Aborted,"Type of selection is not a branch");
1.171 - } else if (api.checkParamCount(2))
1.172 + } else if (api.checkParamCount(1))
1.173 {
1.174 - s=api.parString (ok,0); // selection
1.175 - t=api.parString (ok,1); // path to map
1.176 + //s=api.parString (ok,0); // selection
1.177 + t=api.parString (ok,0); // path to map
1.178 if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
1.179 - addMapReplaceInt(s,t);
1.180 + addMapReplaceInt(selection->getSelectString(),t);
1.181 }
1.182 } else if (com==QString("addMapInsert"))
1.183 {
1.184 @@ -818,6 +797,62 @@
1.185 {
1.186 paste();
1.187 }
1.188 + } else if (com=="select")
1.189 + {
1.190 + if (api.checkParamCount(1))
1.191 + {
1.192 + s=api.parString(ok,0);
1.193 + if (ok) select (s);
1.194 + }
1.195 + } else if (com=="setMapAuthor")
1.196 + {
1.197 + if (api.checkParamCount(1))
1.198 + {
1.199 + s=api.parString(ok,0);
1.200 + if (ok) setMapAuthor (s);
1.201 + }
1.202 + } else if (com=="setMapComment")
1.203 + {
1.204 + if (api.checkParamCount(1))
1.205 + {
1.206 + s=api.parString(ok,0);
1.207 + if (ok) setMapComment(s);
1.208 + }
1.209 + } else if (com=="setMapBackgroundColor")
1.210 + {
1.211 + if (!selection)
1.212 + {
1.213 + api.setError (Aborted,"Nothing selected");
1.214 + } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.215 + typeid(*selection) != typeid(MapCenterObj)) )
1.216 + {
1.217 + api.setError (Aborted,"Type of selection is not a branch");
1.218 + } else if (api.checkParamCount(1))
1.219 + {
1.220 + QColor c=api.parColor (ok,0);
1.221 + if (ok) setMapBackgroundColor (c);
1.222 + }
1.223 + } else if (com=="setMapDefLinkColor")
1.224 + {
1.225 + if (!selection)
1.226 + {
1.227 + api.setError (Aborted,"Nothing selected");
1.228 + } else if ( (typeid(*selection) != typeid(BranchObj) &&
1.229 + typeid(*selection) != typeid(MapCenterObj)) )
1.230 + {
1.231 + api.setError (Aborted,"Type of selection is not a branch");
1.232 + } else if (api.checkParamCount(1))
1.233 + {
1.234 + QColor c=api.parColor (ok,0);
1.235 + if (ok) setMapDefLinkColor (c);
1.236 + }
1.237 + } else if (com=="setMapLinkStyle")
1.238 + {
1.239 + if (api.checkParamCount(1))
1.240 + {
1.241 + s=api.parString (ok,0);
1.242 + if (ok) setMapLinkStyle(s);
1.243 + }
1.244 } else if (com=="setHeading")
1.245 {
1.246 if (!selection)
1.247 @@ -915,20 +950,7 @@
1.248 bo->updateFlagsToolbar();
1.249 }
1.250 }
1.251 - // Internal commands
1.252 - } else if (com==QString("undoMap"))
1.253 - {
1.254 - if (api.checkParamCount(1))
1.255 - addMapReplaceInt("",api.parString (ok,0));
1.256 - } else if (com=="select")
1.257 - {
1.258 - if (api.checkParamCount(1))
1.259 - {
1.260 - s=api.parString(ok,0);
1.261 - if (ok) select (s);
1.262 - }
1.263 - }
1.264 - else
1.265 + } else
1.266 {
1.267 api.setError (Aborted,"Unknown command");
1.268 }
1.269 @@ -1126,9 +1148,6 @@
1.270 {
1.271 int returnCode=0;
1.272
1.273 - // The SaveMode UndoCommand is not supported here
1.274 - if (savemode==UndoCommand) return 1;
1.275 -
1.276 // Create mapName and fileDir
1.277 makeSubDirs (fileDir);
1.278 QString fname;
1.279 @@ -2454,18 +2473,29 @@
1.280 }
1.281 }
1.282
1.283 -void MapEditor::selectBackgroundColor()
1.284 +void MapEditor::selectMapBackgroundColor()
1.285 {
1.286 QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
1.287 if ( !col.isValid() ) return;
1.288 setBackgroundColor( col );
1.289 - //TODO undocomm
1.290 - saveStateComplete(QString("Set background color of map to %1").arg(col.name()));
1.291 }
1.292
1.293 -void MapEditor::setBackgroundColor(QColor c)
1.294 +
1.295 +void MapEditor::setMapBackgroundColor(QColor col)
1.296 {
1.297 - mapCanvas->setBackgroundColor (c);
1.298 + QColor oldcol=mapCanvas->backgroundColor();
1.299 + saveState(
1.300 + selection,
1.301 + QString ("setMapBackgroundColor (%1)").arg(oldcol.name()),
1.302 + selection,
1.303 + QString ("setMapBackgroundColor (%1)").arg(col.name()),
1.304 + QString("Set background color of map to %1").arg(col.name()));
1.305 + mapCanvas->setBackgroundColor (col);
1.306 +}
1.307 +
1.308 +QColor MapEditor::getMapBackgroundColor()
1.309 +{
1.310 + return mapCanvas->backgroundColor();
1.311 }
1.312
1.313 QColor MapEditor::getCurrentHeadingColor()
1.314 @@ -2492,12 +2522,13 @@
1.315 typeid(*selection) == typeid(MapCenterObj))
1.316 {
1.317 BranchObj *bo=(BranchObj*)selection;
1.318 - saveStateChangingPart(
1.319 + saveState(
1.320 selection,
1.321 + QString ("colorItem (%1)").arg(bo->getColor().name()),
1.322 selection,
1.323 QString ("colorItem (%1)").arg(c.name()),
1.324 QString("Set color of %1 to %2").arg(getName(bo)).arg(c.name())
1.325 - ); //TODO with complete API: undoCommand
1.326 + );
1.327 bo->setColor(c); // color branch
1.328 }
1.329 }
1.330 @@ -2918,9 +2949,8 @@
1.331 // Finally show dialog
1.332 if (dia.exec() == QDialog::Accepted)
1.333 {
1.334 - saveStateComplete("Edit info about map"); //TODO undoCommand
1.335 - mapCenter->setAuthor (dia.getAuthor() );
1.336 - mapCenter->setComment (dia.getComment() );
1.337 + setMapAuthor (dia.getAuthor() );
1.338 + setMapComment (dia.getComment() );
1.339 }
1.340 }
1.341
1.342 @@ -2938,11 +2968,48 @@
1.343 ((BranchObj*)selection)->updateNoteFlag();
1.344 }
1.345
1.346 -void MapEditor::setLinkStyle (LinkStyle ls)
1.347 +void MapEditor::setMapAuthor (const QString &s)
1.348 {
1.349 - linkstyle=ls;
1.350 -
1.351 - saveStateComplete("Set link style"); // TODO undoCommand
1.352 + saveState (
1.353 + selection,
1.354 + QString ("setMapAuthor (\"%1\")").arg(mapCenter->getAuthor()),
1.355 + selection,
1.356 + QString ("setMapAuthor (\"%1\")").arg(s),
1.357 + QString ("Set author of map to \"%1\"").arg(s)
1.358 + );
1.359 + mapCenter->setAuthor (s);
1.360 +}
1.361 +
1.362 +void MapEditor::setMapComment (const QString &s)
1.363 +{
1.364 + saveState (
1.365 + selection,
1.366 + QString ("setMapComment (\"%1\")").arg(mapCenter->getComment()),
1.367 + selection,
1.368 + QString ("setMapComment (\"%1\")").arg(s),
1.369 + QString ("Set comment of map")
1.370 + );
1.371 + mapCenter->setComment (s);
1.372 +}
1.373 +
1.374 +void MapEditor::setMapLinkStyle (const QString & s)
1.375 +{
1.376 + saveStateChangingPart (
1.377 + mapCenter,
1.378 + mapCenter,
1.379 + QString("setMapLinkStyle (\"%1\")").arg(s),
1.380 + QString("Set map link style (\"%1\")").arg(s)
1.381 + );
1.382 +
1.383 + if (s=="StyleLine")
1.384 + linkstyle=StyleLine;
1.385 + else if (s=="StyleParabel")
1.386 + linkstyle=StyleParabel;
1.387 + else if (s=="StylePolyLine")
1.388 + linkstyle=StylePolyLine;
1.389 + else
1.390 + linkstyle=StylePolyParabel;
1.391 +
1.392 BranchObj *bo;
1.393 bo=mapCenter->first();
1.394 bo=bo->next();
1.395 @@ -2954,20 +3021,20 @@
1.396 mapCenter->reposition();
1.397 }
1.398
1.399 -LinkStyle MapEditor::getLinkStyle ()
1.400 +LinkStyle MapEditor::getMapLinkStyle ()
1.401 {
1.402 return linkstyle;
1.403 }
1.404
1.405 -void MapEditor::setLinkColor(QColor c)
1.406 +void MapEditor::setMapDefLinkColor(QColor c)
1.407 {
1.408 defLinkColor=c;
1.409 updateActions();
1.410 }
1.411
1.412 -void MapEditor::setLinkColorHint()
1.413 +void MapEditor::setMapLinkColorHintInt()
1.414 {
1.415 - // called from setLinkColorHint(lch) or at end of parse
1.416 + // called from setMapLinkColorHint(lch) or at end of parse
1.417 BranchObj *bo;
1.418 bo=mapCenter->first();
1.419 while (bo)
1.420 @@ -2977,13 +3044,13 @@
1.421 }
1.422 }
1.423
1.424 -void MapEditor::setLinkColorHint(LinkColorHint lch)
1.425 +void MapEditor::setMapLinkColorHint(LinkColorHint lch)
1.426 {
1.427 linkcolorhint=lch;
1.428 - setLinkColorHint();
1.429 + setMapLinkColorHintInt();
1.430 }
1.431
1.432 -void MapEditor::toggleLinkColorHint()
1.433 +void MapEditor::toggleMapLinkColorHint()
1.434 {
1.435 if (linkcolorhint==HeadingColor)
1.436 linkcolorhint=DefaultColor;
1.437 @@ -2998,42 +3065,48 @@
1.438 }
1.439 }
1.440
1.441 -LinkColorHint MapEditor::getLinkColorHint()
1.442 +LinkColorHint MapEditor::getMapLinkColorHint()
1.443 {
1.444 return linkcolorhint;
1.445 }
1.446
1.447 -QColor MapEditor::getDefLinkColor()
1.448 +QColor MapEditor::getMapDefLinkColor()
1.449 {
1.450 return defLinkColor;
1.451 }
1.452
1.453 -void MapEditor::setDefXLinkColor(QColor col)
1.454 +void MapEditor::setMapDefXLinkColor(QColor col)
1.455 {
1.456 defXLinkColor=col;
1.457 }
1.458
1.459 -QColor MapEditor::getDefXLinkColor()
1.460 +QColor MapEditor::getMapDefXLinkColor()
1.461 {
1.462 return defXLinkColor;
1.463 }
1.464
1.465 -void MapEditor::setDefXLinkWidth (int w)
1.466 +void MapEditor::setMapDefXLinkWidth (int w)
1.467 {
1.468 defXLinkWidth=w;
1.469 }
1.470
1.471 -int MapEditor::getDefXLinkWidth()
1.472 +int MapEditor::getMapDefXLinkWidth()
1.473 {
1.474 return defXLinkWidth;
1.475 }
1.476
1.477 -void MapEditor::selectLinkColor()
1.478 +void MapEditor::selectMapLinkColor()
1.479 {
1.480 QColor col = QColorDialog::getColor( defLinkColor, this );
1.481 if ( !col.isValid() ) return;
1.482 - setLinkColor( col );
1.483 - saveStateComplete(QString("Set link color to %1").arg(col.name())); //TODO undoCommand
1.484 + saveState (
1.485 + selection,
1.486 + QString("setMapDefLinkColor (\"%1\")").arg(getMapDefLinkColor().name()),
1.487 + selection,
1.488 + QString("setMapDefLinkColor (\"%1\")").arg(col.name()),
1.489 + QString("Set link color to %1").arg(col.name())
1.490 + );
1.491 + setMapDefLinkColor( col );
1.492
1.493 }
1.494
1.495 @@ -3326,12 +3399,12 @@
1.496 {
1.497 if (dia.useSettingsGlobal() )
1.498 {
1.499 - setDefXLinkColor (xlo->getColor() );
1.500 - setDefXLinkWidth (xlo->getWidth() );
1.501 + setMapDefXLinkColor (xlo->getColor() );
1.502 + setMapDefXLinkWidth (xlo->getWidth() );
1.503 }
1.504 if (dia.deleteXLink())
1.505 ((BranchObj*)selection)->deleteXLinkAt(i);
1.506 - saveStateComplete("Edit xLink"); //TODO undoCommand
1.507 + //saveStateComplete("Edit xLink"); //FIXME undoCommand
1.508 }
1.509 }
1.510 }
1.511 @@ -3459,6 +3532,34 @@
1.512 e->accept();
1.513 }
1.514
1.515 +void MapEditor::keyPressEvent(QKeyEvent* e)
1.516 +{
1.517 + if (e->modifiers() && Qt::ControlModifier)
1.518 + {
1.519 + switch (mainWindow->getModMode())
1.520 + {
1.521 + case ModModeColor:
1.522 + setCursor (PickColorCursor);
1.523 + break;
1.524 + case ModModeCopy:
1.525 + setCursor (CopyCursor);
1.526 + break;
1.527 + case ModModeXLink:
1.528 + setCursor (XLinkCursor);
1.529 + break;
1.530 + default :
1.531 + setCursor (Qt::ArrowCursor);
1.532 + break;
1.533 + }
1.534 + }
1.535 +}
1.536 +
1.537 +void MapEditor::keyReleaseEvent(QKeyEvent* e)
1.538 +{
1.539 + if (!(e->modifiers() && Qt::ControlModifier))
1.540 + setCursor (Qt::ArrowCursor);
1.541 +}
1.542 +
1.543 void MapEditor::contentsMousePressEvent(QMouseEvent* e)
1.544 {
1.545 // Ignore right clicks, these will go to context menus
1.546 @@ -3510,7 +3611,7 @@
1.547 if (mainWindow->getModMode()==ModModeColor)
1.548 {
1.549 pickingColor=true;
1.550 - setCursor (pickColorCursor);
1.551 + setCursor (PickColorCursor);
1.552 return;
1.553 }
1.554 if (mainWindow->getModMode()==ModModeXLink)
1.555 @@ -3582,7 +3683,7 @@
1.556 movingObj_start=e->globalPos();
1.557 movingCont_start=QPoint (contentsX(), contentsY() );
1.558 movingVec=QPoint(0,0);
1.559 - setCursor(handOpenCursor);
1.560 + setCursor(HandOpenCursor);
1.561 }
1.562 }
1.563 }
1.564 @@ -3629,7 +3730,7 @@
1.565 if (typeid(*fo) == typeid(FloatImageObj))
1.566 {
1.567 //TODO undocom
1.568 - saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
1.569 + //saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
1.570 FloatImageObj *fio=(FloatImageObj*)(fo);
1.571 ((BranchObj*)(lmo))->addFloatImage (fio);
1.572 fio->unselect();
1.573 @@ -3756,7 +3857,7 @@
1.574 tmpXLink->setEnd ( ((BranchObj*)(dst)) );
1.575 tmpXLink->updateXLink();
1.576 tmpXLink->activate();
1.577 - saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //TODO undoCommand
1.578 + //saveStateComplete(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) ); //FIXME undoCommand
1.579 } else
1.580 {
1.581 delete(tmpXLink);
1.582 @@ -4064,7 +4165,7 @@
1.583 if (update)
1.584 {
1.585 //FIXME saveState has to be called earlier for each of the drops...
1.586 - saveStateComplete("Drop Event"); //TODO undo Command
1.587 + //saveStateComplete("Drop Event"); //TODO undo Command
1.588 mapCenter->reposition();
1.589 adjustCanvasSize();
1.590 canvas()->update();