diff -r 9eb7767c2dfa -r 608f976aa7bb ornamentedobj.cpp --- a/ornamentedobj.cpp Sun Jan 30 12:58:47 2005 +0000 +++ b/ornamentedobj.cpp Tue Jun 06 14:58:11 2006 +0000 @@ -18,7 +18,7 @@ init (); } -OrnamentedObj::OrnamentedObj(QCanvas* c) :LinkableMapObj(c) +OrnamentedObj::OrnamentedObj(Q3Canvas* c) :LinkableMapObj(c) { // cout << "Const OrnamentedObj\n"; init (); @@ -54,20 +54,29 @@ standardFlags->clone(standardFlagsDefault); standardFlags->setName ("standardFlags"); + hideExport=false; + hidden=false; - + url=""; + vymLink=""; + } void OrnamentedObj::copy (OrnamentedObj* other) { LinkableMapObj::copy(other); heading->copy(other->heading); - setColor (other->heading->getColor(),false); + setColor (other->heading->getColor()); note.copy (other->note); systemFlags->copy (other->systemFlags); standardFlags->copy (other->standardFlags); + ornamentsBBox=other->ornamentsBBox; + + hideExport=other->hideExport; + url=other->url; + vymLink=other->vymLink; } QString OrnamentedObj::getHeading() @@ -83,27 +92,45 @@ LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor()); } +void OrnamentedObj::setColor (QColor col) +{ + heading->setColor(col); + setLinkColor(); +} + QColor OrnamentedObj::getColor () { return heading->getColor(); } +void OrnamentedObj::positionContents() +{ + double d=frame->getBorder()/2; + double x=absPos.x(); + double y=absPos.y(); + + double ox,oy; // Offset due to padding + + ox=leftPad + d; + oy=topPad + d; + + systemFlags-> move (ox +x , oy + y ); + + // vertical align heading to bottom + heading->move (ox + x + systemFlags->getBBox().width(), + oy + y + ornamentsBBox.height() - heading->getHeight() + ); + standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y ); + + ornamentsBBox.moveTopLeft ( QPoint ((int)(ox+x),(int)(oy+y))); + clickBox.moveTopLeft (QPoint ((int)(ox + x), (int)(oy + y))); +} + void OrnamentedObj::move (double x, double y) { MapObj::move (x,y); - double dx=frame->getBorder()/2; // care for border around object - double dy=frame->getBorder()/2; - systemFlags-> move (x + dx, y + dy); - - // vertical align heading to bottom - int h=max (systemFlags->getBBox().height(), standardFlags->getBBox().height()); - h=max (h,heading->getHeight()); - heading->move (x + dx + systemFlags->getBBox().width(), - y + dy + h - heading->getHeight() - ); - standardFlags->move (x + heading->getWidth() + systemFlags->getBBox().width(), y + dy ); - + positionContents(); updateLink(); requestReposition(); } @@ -138,8 +165,7 @@ void OrnamentedObj::move2RelPos(QPoint p) { - if (!parObj) return; - move (parObj->getChildPos().x() + p.x(), parObj->getChildPos().y() + p.y() ); + move2RelPos (p.x(),p.y()); } void OrnamentedObj::setNote(QString s) @@ -174,9 +200,72 @@ return note.getNote(); } -void OrnamentedObj::toggleStandardFlag(QString f) +QString OrnamentedObj::getNoteASCII() { - standardFlags->toggle(f); + return note.getNoteASCII(); +} + +QString OrnamentedObj::getNoteOpenDoc() +{ + return note.getNoteOpenDoc(); +} + +void OrnamentedObj::setURL(QString s) +{ + url=s; + if (!url.isEmpty()) + systemFlags->activate("url"); + else + systemFlags->deactivate("url"); + calcBBoxSize(); // recalculate bbox + positionBBox(); // rearrange contents + forceReposition(); +} + +QString OrnamentedObj::getURL() +{ + return url; +} + +void OrnamentedObj::setVymLink(QString s) +{ + if (!s.isEmpty()) + { + // We need the relative (from loading) + // or absolute path (from User event) + // and build the absolute path. + // Note: If we have relative, use path of + // current map to build absolute path + QDir d(s); + if (!d.path().startsWith ("/")) + { + QString p=mapEditor->getDestPath(); + int i=p.findRev("/",-1); + d.setPath(p.left(i)+"/"+s); + d.convertToAbs(); + } + vymLink=d.path(); + systemFlags->activate("vymLink"); + } + else + { + systemFlags->deactivate("vymLink"); + vymLink=""; + } + calcBBoxSize(); // recalculate bbox + positionBBox(); // rearrange contents + forceReposition(); +} + +QString OrnamentedObj::getVymLink() +{ + return vymLink; +} + + +void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive) +{ + standardFlags->toggle(f,exclusive); calcBBoxSize(); positionBBox(); move (absPos.x(), absPos.y() ); @@ -192,20 +281,93 @@ forceReposition(); } +bool OrnamentedObj::isSetStandardFlag (QString f) +{ + return standardFlags->isActive(f); +} + QString OrnamentedObj::getSystemFlagName(const QPoint &p) { return systemFlags->getFlagName(p); } +bool OrnamentedObj::isActiveFlag (const QString & fname) +{ + if (standardFlags->isActive (fname) ) return true; + return false; +} + void OrnamentedObj::updateNoteFlag() { - // text in NoteEditor has changed, notify MapEditor - mapEditor->setChanged(); + if (selected) + { + // text in NoteEditor has changed, notify MapEditor + mapEditor->setChanged(); - // save text - setNote( textEditor->getText() ); + // save text + setNote( textEditor->getText() ); - // save font - note.setFontHint (textEditor->getFontHint() ); + // save font + note.setFontHint (textEditor->getFontHint() ); + } } +void OrnamentedObj::setHideInExport(bool b) +{ + if (parObj) + { + // Don't allow to MapCenter to be hidden + hideExport=b; + if (b) + systemFlags->activate("hideInExport"); + else + systemFlags->deactivate("hideInExport"); + calcBBoxSize(); + positionBBox(); + requestReposition(); + } +} + +bool OrnamentedObj::hideInExport() +{ + return hideExport; +} + +bool OrnamentedObj::isHidden() +{ + return hidden; +} + +QString OrnamentedObj::getOrnAttr() +{ + QString posAttr; + + if (useRelPos) + posAttr=attribut("relPosX",QString().setNum(relPos.x(),10)) + + attribut("relPosY",QString().setNum(relPos.y(),10)); + else + { + if (depth==0 || depth==1) posAttr= + attribut("absPosX",QString().setNum(absPos.x(),10)) + + attribut("absPosY",QString().setNum(absPos.y(),10)); + else + posAttr=""; + } + + QString urlAttr; + if (!url.isEmpty()) + urlAttr=attribut ("url",url); + + QString vymLinkAttr; + if (!vymLink.isEmpty()) + vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) ); + + QString hideExpAttr; + if (hideExport) + hideExpAttr= attribut("hideInExport","true"); + else + hideExpAttr=""; + + return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr; +} +