author | insilmaril |
Mon, 08 Mar 2010 12:21:46 +0000 | |
changeset 827 | a591443f229c |
parent 823 | 0bba81dde1bc |
child 835 | 31841b366d5e |
permissions | -rw-r--r-- |
insilmaril@760 | 1 |
#include "mapitem.h" |
insilmaril@760 | 2 |
|
insilmaril@760 | 3 |
#include "linkablemapobj.h" |
insilmaril@760 | 4 |
#include "ornamentedobj.h" |
insilmaril@760 | 5 |
|
insilmaril@823 | 6 |
#include <QDebug> |
insilmaril@823 | 7 |
|
insilmaril@760 | 8 |
MapItem::MapItem() |
insilmaril@760 | 9 |
{ |
insilmaril@776 | 10 |
init(); |
insilmaril@776 | 11 |
} |
insilmaril@776 | 12 |
|
insilmaril@779 | 13 |
MapItem::MapItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent) |
insilmaril@779 | 14 |
{ |
insilmaril@779 | 15 |
init(); |
insilmaril@779 | 16 |
} |
insilmaril@779 | 17 |
|
insilmaril@776 | 18 |
void MapItem::init() |
insilmaril@776 | 19 |
{ |
insilmaril@760 | 20 |
lmo=NULL; |
insilmaril@760 | 21 |
posMode=Unused; |
insilmaril@779 | 22 |
hideLinkUnselected=false; |
insilmaril@779 | 23 |
} |
insilmaril@779 | 24 |
|
insilmaril@779 | 25 |
void MapItem::appendChild (TreeItem *item) |
insilmaril@779 | 26 |
{ |
insilmaril@779 | 27 |
TreeItem::appendChild (item); |
insilmaril@779 | 28 |
|
insilmaril@779 | 29 |
// FIXME-4 maybe access parent in MapObjs directly via treeItem |
insilmaril@779 | 30 |
// and remove this here... |
insilmaril@779 | 31 |
|
insilmaril@779 | 32 |
// If lmo exists, also set parObj there |
insilmaril@779 | 33 |
if (lmo && (item->isBranchLikeType() || item->getType()==TreeItem::Image) ) |
insilmaril@779 | 34 |
{ |
insilmaril@779 | 35 |
LinkableMapObj *itemLMO=((MapItem*)item)->lmo; |
insilmaril@779 | 36 |
if (itemLMO) |
insilmaril@779 | 37 |
itemLMO->setParObj (lmo); |
insilmaril@779 | 38 |
} |
insilmaril@760 | 39 |
} |
insilmaril@760 | 40 |
|
insilmaril@760 | 41 |
void MapItem::setRelPos (const QPointF &p) |
insilmaril@760 | 42 |
{ |
insilmaril@760 | 43 |
posMode=Relative; |
insilmaril@760 | 44 |
pos=p; |
insilmaril@760 | 45 |
if (lmo) |
insilmaril@760 | 46 |
{ |
insilmaril@760 | 47 |
((OrnamentedObj*)lmo)->setUseRelPos (true); |
insilmaril@760 | 48 |
((OrnamentedObj*)lmo)->move2RelPos(p); |
insilmaril@760 | 49 |
} |
insilmaril@760 | 50 |
} |
insilmaril@760 | 51 |
|
insilmaril@760 | 52 |
void MapItem::setAbsPos (const QPointF &p) |
insilmaril@760 | 53 |
{ |
insilmaril@760 | 54 |
posMode=Absolute; |
insilmaril@760 | 55 |
pos=p; |
insilmaril@760 | 56 |
if (lmo) lmo->move (p); |
insilmaril@760 | 57 |
} |
insilmaril@760 | 58 |
|
insilmaril@775 | 59 |
void MapItem::setPositionMode (PositionMode mode) |
insilmaril@775 | 60 |
{ |
insilmaril@775 | 61 |
posMode=mode; |
insilmaril@775 | 62 |
} |
insilmaril@775 | 63 |
|
insilmaril@779 | 64 |
void MapItem::setHideLinkUnselected (bool b) |
insilmaril@779 | 65 |
{ |
insilmaril@779 | 66 |
hideLinkUnselected=b; |
insilmaril@823 | 67 |
if (lmo) |
insilmaril@823 | 68 |
{ |
insilmaril@823 | 69 |
//lmo->setHideLinkUnselected(); |
insilmaril@823 | 70 |
lmo->setVisibility (lmo->isVisibleObj()); |
insilmaril@823 | 71 |
lmo->updateLinkGeometry(); |
insilmaril@823 | 72 |
} |
insilmaril@779 | 73 |
} |
insilmaril@779 | 74 |
|
insilmaril@779 | 75 |
bool MapItem::getHideLinkUnselected() |
insilmaril@779 | 76 |
{ |
insilmaril@779 | 77 |
return hideLinkUnselected; |
insilmaril@779 | 78 |
} |
insilmaril@779 | 79 |
|
insilmaril@779 | 80 |
QString MapItem::getMapAttr () |
insilmaril@779 | 81 |
{ |
insilmaril@779 | 82 |
QString s; |
insilmaril@779 | 83 |
|
insilmaril@779 | 84 |
if (parentItem==rootItem) |
insilmaril@779 | 85 |
posMode=Absolute; |
insilmaril@779 | 86 |
else |
insilmaril@779 | 87 |
{ |
insilmaril@779 | 88 |
if (type==TreeItem::Image ||depth()==1) |
insilmaril@779 | 89 |
posMode=Relative; |
insilmaril@779 | 90 |
else |
insilmaril@779 | 91 |
posMode=Unused; |
insilmaril@779 | 92 |
} |
insilmaril@779 | 93 |
switch (posMode) |
insilmaril@779 | 94 |
{ |
insilmaril@779 | 95 |
case Relative: |
insilmaril@779 | 96 |
if (lmo) pos=lmo->getRelPos(); |
insilmaril@779 | 97 |
s= attribut("relPosX",QString().setNum(pos.x())) + |
insilmaril@779 | 98 |
attribut("relPosY",QString().setNum(pos.y())); |
insilmaril@779 | 99 |
break; |
insilmaril@779 | 100 |
case Absolute: |
insilmaril@779 | 101 |
if (lmo) pos=lmo->getAbsPos(); |
insilmaril@779 | 102 |
s=attribut("absPosX",QString().setNum(pos.x())) + |
insilmaril@779 | 103 |
attribut("absPosY",QString().setNum(pos.y())); |
insilmaril@779 | 104 |
break; |
insilmaril@779 | 105 |
default: break; |
insilmaril@779 | 106 |
} |
insilmaril@779 | 107 |
if (hideLinkUnselected) |
insilmaril@779 | 108 |
s+=attribut ("hideLink","true"); |
insilmaril@779 | 109 |
else |
insilmaril@779 | 110 |
s+=attribut ("hideLink","false"); |
insilmaril@779 | 111 |
return s; |
insilmaril@779 | 112 |
} |
insilmaril@779 | 113 |
|
insilmaril@823 | 114 |
QRectF MapItem::getBBoxURLFlag () |
insilmaril@823 | 115 |
{ |
insilmaril@823 | 116 |
QStringList list=systemFlags.activeFlagNames().filter ("system-url"); |
insilmaril@823 | 117 |
if (list.count()>1) |
insilmaril@823 | 118 |
{ |
insilmaril@823 | 119 |
qWarning()<<"MapItem::getBBoxURLFlag found more than one system-url*"; |
insilmaril@823 | 120 |
return QRectF (); |
insilmaril@823 | 121 |
} |
insilmaril@823 | 122 |
return getBBoxFlag (list.first()); |
insilmaril@823 | 123 |
} |
insilmaril@823 | 124 |
|
insilmaril@819 | 125 |
QRectF MapItem::getBBoxFlag (const QString &fname) |
insilmaril@819 | 126 |
{ |
insilmaril@819 | 127 |
if (lmo) |
insilmaril@819 | 128 |
return ((OrnamentedObj*)lmo)->getBBoxFlag (fname); |
insilmaril@819 | 129 |
else |
insilmaril@819 | 130 |
return QRectF (); |
insilmaril@819 | 131 |
} |
insilmaril@819 | 132 |
|
insilmaril@760 | 133 |
LinkableMapObj* MapItem::getLMO() |
insilmaril@760 | 134 |
{ |
insilmaril@760 | 135 |
return lmo; |
insilmaril@760 | 136 |
} |
insilmaril@760 | 137 |
|
insilmaril@760 | 138 |
void MapItem::setLMO(LinkableMapObj *l) |
insilmaril@760 | 139 |
{ |
insilmaril@760 | 140 |
lmo=l; |
insilmaril@760 | 141 |
} |
insilmaril@760 | 142 |
|
insilmaril@760 | 143 |
void MapItem::initLMO() |
insilmaril@760 | 144 |
{ |
insilmaril@760 | 145 |
if (!lmo) return; |
insilmaril@760 | 146 |
switch (posMode) |
insilmaril@760 | 147 |
{ |
insilmaril@760 | 148 |
case Relative: |
insilmaril@760 | 149 |
lmo->setRelPos (pos); |
insilmaril@760 | 150 |
break; |
insilmaril@760 | 151 |
case Absolute: |
insilmaril@760 | 152 |
lmo->move (pos); |
insilmaril@760 | 153 |
break; |
insilmaril@760 | 154 |
default: |
insilmaril@760 | 155 |
break; |
insilmaril@760 | 156 |
} |
insilmaril@760 | 157 |
} |
insilmaril@760 | 158 |