insilmaril@0: #include insilmaril@0: insilmaril@0: #include "mapcenterobj.h" insilmaril@0: #include "floatimageobj.h" insilmaril@0: #include "mapeditor.h" 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@364: MapCenterObj::MapCenterObj(Q3Canvas* c) : BranchObj (c) insilmaril@0: { insilmaril@0: // cout << "Const MapCenterObj canvas="<setFont(font); insilmaril@164: depth=0; insilmaril@164: setDefAttr(MovedBranch); insilmaril@0: insilmaril@0: frame->setFrameType (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@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@388: // Move myself and childs 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@0: BranchObj *b; insilmaril@0: for (b=branch.first(); b; b=branch.next() ) insilmaril@0: b->updateLink(); 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@388: BranchObj *b; insilmaril@388: for (b=branch.first(); b; b=branch.next() ) insilmaril@388: { insilmaril@388: b->setRelPos(); insilmaril@388: b->setOrientation(); insilmaril@388: } insilmaril@388: insilmaril@388: FloatObj *fo; insilmaril@388: for (fo=floatimage.first(); fo; fo=floatimage.next() ) fo->setRelPos(); insilmaril@388: insilmaril@388: if (repositionRequest) reposition(); insilmaril@388: } insilmaril@388: insilmaril@0: LinkableMapObj* MapCenterObj::findMapObj(QPoint p, LinkableMapObj *excludeLMO) insilmaril@0: { insilmaril@0: BranchObj *bo; insilmaril@0: LinkableMapObj *lmo; insilmaril@0: insilmaril@0: // Search through child branches insilmaril@0: for (bo=branch.first(); bo; bo=branch.next() ) insilmaril@0: { insilmaril@0: lmo = bo->findMapObj(p, excludeLMO); insilmaril@169: if (lmo!= NULL) return lmo; insilmaril@0: } insilmaril@0: // is p in MapCenter? insilmaril@169: if (inBox (p) && (this != excludeLMO) ) return this; insilmaril@0: insilmaril@0: // Search float images insilmaril@0: FloatImageObj *foi; insilmaril@0: for (foi=floatimage.first(); foi; foi=floatimage.next() ) insilmaril@169: if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi; insilmaril@0: insilmaril@0: // nothing found insilmaril@0: return NULL; insilmaril@0: } insilmaril@0: insilmaril@0: QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPoint &offset) insilmaril@0: { insilmaril@0: QString s,a; insilmaril@0: insilmaril@0: // save area, if not scrolled insilmaril@0: QString areaAttr= insilmaril@0: attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) + insilmaril@0: attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) + insilmaril@0: attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) + insilmaril@0: attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10)); 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@169: idAttr=attribut ("id",getSelectString()); insilmaril@169: else insilmaril@169: idAttr=""; insilmaril@169: insilmaril@169: QString linkAttr=getLinkAttr(); insilmaril@169: insilmaril@0: s=beginElement ("mapcenter" insilmaril@239: +getOrnAttr() insilmaril@0: +attribut("frameType",frame->getFrameTypeName()) 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@0: s=s+valueElement("heading", getHeading(),a); insilmaril@0: insilmaril@0: // add link to file in s insilmaril@0: if (!note.isEmpty() ) insilmaril@0: s+=note.saveToDir(); insilmaril@0: insilmaril@95: // Save branches insilmaril@95: BranchObj *bo; insilmaril@95: for (bo=branch.first(); bo; bo=branch.next() ) insilmaril@95: s+=bo->saveToDir(tmpdir,prefix, offset); insilmaril@95: insilmaril@0: // Save FloatImages insilmaril@0: FloatImageObj *fio; insilmaril@0: for (fio=floatimage.first(); fio; fio=floatimage.next() ) insilmaril@377: s+=fio->saveToDir (tmpdir,prefix); insilmaril@0: insilmaril@95: // Save XLinks insilmaril@95: XLinkObj *xlo; insilmaril@95: for (xlo=xlink.first(); xlo; xlo=xlink.next() ) insilmaril@95: s+=xlo->saveToDir(); 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: