insilmaril@406: #include insilmaril@0: insilmaril@641: #include "floatimageobj.h" insilmaril@641: #include "geometry.h" insilmaril@0: #include "mapcenterobj.h" insilmaril@681: #include "mapeditor.h" insilmaril@681: insilmaril@0: insilmaril@0: ///////////////////////////////////////////////////////////////// insilmaril@0: // MapCenterObj insilmaril@0: ///////////////////////////////////////////////////////////////// insilmaril@0: MapCenterObj::MapCenterObj() : BranchObj () insilmaril@0: { insilmaril@0: // cout << "Const MapCenterObj\n"; insilmaril@0: init(); insilmaril@0: } insilmaril@0: insilmaril@408: MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s) insilmaril@0: { insilmaril@408: // cout << "Const MapCenterObj canvas="<setFont(font); insilmaril@164: depth=0; insilmaril@164: setDefAttr(MovedBranch); insilmaril@0: insilmaril@459: frame->setFrameType (FrameObj::Rectangle); insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::move (double x, double y) insilmaril@0: { insilmaril@0: BranchObj::move(x,y); insilmaril@0: } insilmaril@0: insilmaril@681: void MapCenterObj::move (QPointF absPos) insilmaril@681: { insilmaril@681: BranchObj::move(absPos); insilmaril@681: } insilmaril@681: insilmaril@0: void MapCenterObj::moveBy (double x, double y) insilmaril@0: { insilmaril@169: BranchObj::moveBy(x,y); insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::moveAll (double x, double y) insilmaril@0: { insilmaril@0: // Get rel. position insilmaril@0: double dx=x-absPos.x(); insilmaril@0: double dy=y-absPos.y(); insilmaril@0: insilmaril@0: // Move myself and branches insilmaril@0: moveAllBy (dx,dy); insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::moveAllBy (double dx, double dy) insilmaril@0: { insilmaril@721: // Move myself and children insilmaril@388: BranchObj::moveBy(dx,dy); insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::updateLink() insilmaril@0: { insilmaril@0: // set childPos to middle of MapCenterObj insilmaril@169: childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 ); insilmaril@169: childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 ); insilmaril@0: parPos=childPos; insilmaril@406: for (int i=0; iupdateLink(); insilmaril@0: } insilmaril@0: insilmaril@388: void MapCenterObj::updateRelPositions() insilmaril@388: { insilmaril@388: if (repositionRequest) unsetAllRepositionRequests(); insilmaril@388: insilmaril@388: // update relative Positions of branches and floats insilmaril@406: for (int i=0; isetRelPos(); insilmaril@406: branch.at(i)->setOrientation(); insilmaril@388: } insilmaril@388: insilmaril@404: for (int i=0; isetRelPos(); insilmaril@388: insilmaril@388: if (repositionRequest) reposition(); insilmaril@388: } insilmaril@388: insilmaril@408: LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO) insilmaril@0: { insilmaril@0: LinkableMapObj *lmo; insilmaril@0: insilmaril@0: // Search through child branches insilmaril@406: for (int i=0; ifindMapObj(p, excludeLMO); insilmaril@169: if (lmo!= NULL) return lmo; insilmaril@0: } insilmaril@0: // is p in MapCenter? insilmaril@641: if (inBox (p,clickBox) && (this != excludeLMO) ) return this; insilmaril@0: insilmaril@0: // Search float images insilmaril@404: for (int i=0; igetClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i); insilmaril@0: insilmaril@0: // nothing found insilmaril@0: return NULL; insilmaril@0: } insilmaril@0: insilmaril@408: QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset) insilmaril@0: { insilmaril@0: QString s,a; insilmaril@0: insilmaril@0: // save area, if not scrolled insilmaril@0: QString areaAttr= insilmaril@408: attribut("x1",QString().setNum(absPos.x()-offset.x())) + insilmaril@408: attribut("y1",QString().setNum(absPos.y()-offset.y())) + insilmaril@408: attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) + insilmaril@408: attribut("y2",QString().setNum(absPos.y()+height()-offset.y())); insilmaril@0: insilmaril@169: // Providing an ID for a branch makes export to XHTML easier insilmaril@169: QString idAttr; insilmaril@169: if (countXLinks()>0) insilmaril@681: idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model insilmaril@681: insilmaril@169: else insilmaril@169: idAttr=""; insilmaril@169: insilmaril@169: QString linkAttr=getLinkAttr(); insilmaril@169: insilmaril@0: s=beginElement ("mapcenter" insilmaril@628: +getOrnXMLAttr() insilmaril@0: +areaAttr insilmaril@239: +idAttr insilmaril@239: +getIncludeImageAttr() ); insilmaril@0: incIndent(); insilmaril@0: if (heading->getColor()!=QColor("black")) insilmaril@0: a=attribut ("textColor",QColor(heading->getColor()).name() ); insilmaril@0: else insilmaril@0: a=""; insilmaril@0: insilmaril@0: // Save flags. If verbose is set (export to xml dir), also write insilmaril@0: // the flags as picture insilmaril@0: s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose); insilmaril@421: insilmaril@421: // Save heading insilmaril@421: s+=valueElement("heading", getHeading(),a); insilmaril@421: insilmaril@421: // Save frame insilmaril@421: s+=frame->saveToDir (); insilmaril@0: insilmaril@729: // Update of note is usually done while unselecting a branch insilmaril@729: if (isNoteInEditor) getNoteFromTextEditor(); insilmaril@729: insilmaril@729: // save note insilmaril@0: if (!note.isEmpty() ) insilmaril@0: s+=note.saveToDir(); insilmaril@0: insilmaril@95: // Save branches insilmaril@406: for (int i=0; isaveToDir(tmpdir,prefix, offset); insilmaril@95: insilmaril@0: // Save FloatImages insilmaril@404: for (int i=0; isaveToDir (tmpdir,prefix); insilmaril@0: insilmaril@95: // Save XLinks insilmaril@406: for (int i=0;isaveToDir(); insilmaril@0: insilmaril@0: decIndent(); insilmaril@0: s+=endElement ("mapcenter"); insilmaril@0: return s; insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::setVersion (const QString &s) insilmaril@0: { insilmaril@0: version=s; insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::setAuthor (const QString &s) insilmaril@0: { insilmaril@0: author=s; insilmaril@0: } insilmaril@0: insilmaril@0: QString MapCenterObj::getAuthor() insilmaril@0: { insilmaril@0: return author; insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::setComment (const QString &s) insilmaril@0: { insilmaril@0: comment=s; insilmaril@0: } insilmaril@0: insilmaril@0: QString MapCenterObj::getComment () insilmaril@0: { insilmaril@0: return comment; insilmaril@0: } insilmaril@0: insilmaril@0: QString MapCenterObj::getDate () insilmaril@0: { insilmaril@0: return QDate::currentDate().toString ("yyyy-MM-dd"); insilmaril@0: } insilmaril@83: