insilmaril@52: #include insilmaril@0: insilmaril@52: #include "floatimageobj.h" insilmaril@52: #include "geometry.h" insilmaril@0: #include "mapcenterobj.h" insilmaril@0: #include "mapeditor.h" insilmaril@0: insilmaril@52: 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@52: MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s) insilmaril@0: { insilmaril@52: // cout << "Const MapCenterObj canvas="<setFont(font); insilmaril@52: depth=0; insilmaril@52: setDefAttr(MovedBranch); insilmaril@0: insilmaril@52: 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@52: } insilmaril@52: insilmaril@52: void MapCenterObj::move (QPointF absPos) insilmaril@52: { insilmaril@52: BranchObj::move(absPos); insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::moveBy (double x, double y) insilmaril@0: { insilmaril@0: 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@52: // Move myself and childs insilmaril@52: BranchObj::moveBy(dx,dy); insilmaril@0: } insilmaril@0: insilmaril@0: void MapCenterObj::updateLink() insilmaril@0: { insilmaril@0: // set childPos to middle of MapCenterObj insilmaril@52: childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 ); insilmaril@52: childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 ); insilmaril@0: parPos=childPos; insilmaril@52: for (int i=0; iupdateLink(); insilmaril@0: } insilmaril@0: insilmaril@52: void MapCenterObj::updateRelPositions() insilmaril@52: { insilmaril@52: if (repositionRequest) unsetAllRepositionRequests(); insilmaril@52: insilmaril@52: // update relative Positions of branches and floats insilmaril@52: for (int i=0; isetRelPos(); insilmaril@52: branch.at(i)->setOrientation(); insilmaril@52: } insilmaril@52: insilmaril@52: for (int i=0; isetRelPos(); insilmaril@52: insilmaril@52: if (repositionRequest) reposition(); insilmaril@52: } insilmaril@52: insilmaril@52: LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO) insilmaril@52: { insilmaril@0: LinkableMapObj *lmo; insilmaril@0: insilmaril@0: // Search through child branches insilmaril@52: for (int i=0; ifindMapObj(p, excludeLMO); insilmaril@52: if (lmo!= NULL) return lmo; insilmaril@0: } insilmaril@0: // is p in MapCenter? insilmaril@52: if (inBox (p,clickBox) && (this != excludeLMO) ) return this; insilmaril@0: insilmaril@0: // Search float images insilmaril@52: 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@52: 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@52: attribut("x1",QString().setNum(absPos.x()-offset.x())) + insilmaril@52: attribut("y1",QString().setNum(absPos.y()-offset.y())) + insilmaril@52: attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) + insilmaril@52: attribut("y2",QString().setNum(absPos.y()+height()-offset.y())); insilmaril@0: insilmaril@52: // Providing an ID for a branch makes export to XHTML easier insilmaril@52: QString idAttr; insilmaril@52: if (countXLinks()>0) insilmaril@52: idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model insilmaril@52: insilmaril@52: else insilmaril@52: idAttr=""; insilmaril@52: insilmaril@52: QString linkAttr=getLinkAttr(); insilmaril@52: insilmaril@0: s=beginElement ("mapcenter" insilmaril@52: +getOrnXMLAttr() insilmaril@0: +areaAttr insilmaril@52: +idAttr insilmaril@52: +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@0: insilmaril@52: // Save heading insilmaril@52: s+=valueElement("heading", getHeading(),a); insilmaril@0: insilmaril@52: // Save frame insilmaril@52: s+=frame->saveToDir (); insilmaril@52: insilmaril@52: // Update of note is usually done while unselecting a branch insilmaril@52: if (isNoteInEditor) getNoteFromTextEditor(); insilmaril@52: insilmaril@52: // save note insilmaril@0: if (!note.isEmpty() ) insilmaril@0: s+=note.saveToDir(); insilmaril@0: insilmaril@52: // Save branches insilmaril@52: for (int i=0; isaveToDir(tmpdir,prefix, offset); insilmaril@52: insilmaril@0: // Save FloatImages insilmaril@52: for (int i=0; isaveToDir (tmpdir,prefix); insilmaril@0: insilmaril@52: // Save XLinks insilmaril@52: 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@52: