1.1 --- a/xml-vym.cpp Wed Jun 03 20:37:17 2009 +0000
1.2 +++ b/xml-vym.cpp Mon Jun 08 11:36:56 2009 +0000
1.3 @@ -13,8 +13,8 @@
1.4 #include "mainwindow.h"
1.5 #include "version.h"
1.6
1.7 -static FloatObj *lastFloat;
1.8 -static OrnamentedObj *lastOO;
1.9 +static ImageItem *lastImageItem;
1.10 +static MapItem *lastMI;
1.11
1.12 extern Main *mainWindow;
1.13 extern Settings settings;
1.14 @@ -54,7 +54,7 @@
1.15 {
1.16 // Create mapCenter
1.17 model->clear();
1.18 - lastBranchItem=NULL;
1.19 + lastBranch=NULL;
1.20
1.21 if (!atts.value( "author").isEmpty() )
1.22 model->setAuthor(atts.value( "author" ) );
1.23 @@ -140,7 +140,7 @@
1.24 {
1.25 // Really use the found mapcenter as MCO in a new map
1.26
1.27 - lastBranchItem=(BranchItem*)model->createMapCenter();
1.28 + lastBranch=model->createMapCenter();
1.29 } else
1.30 {
1.31 // Treat the found mapcenter as a branch
1.32 @@ -148,10 +148,10 @@
1.33 BranchItem *bi=model->getSelectedBranchItem();
1.34 if (bi)
1.35 {
1.36 - lastBranchItem=bi;
1.37 + lastBranch=bi;
1.38 if (loadMode==ImportAdd)
1.39 {
1.40 - lastBranchItem=model->createBranch(lastBranchItem);
1.41 + lastBranch=model->createBranch(lastBranch);
1.42 } //else
1.43 //FIXME-3 lastBranch->clear();
1.44 } else
1.45 @@ -170,7 +170,7 @@
1.46 if (!atts.value( "textColor").isEmpty() )
1.47 {
1.48 col.setNamedColor(atts.value("textColor"));
1.49 - lastBranchItem->setHeadingColor(col );
1.50 + lastBranch->setHeadingColor(col );
1.51 }
1.52 } else if ( eName == "note" &&
1.53 (state == StateMapCenter ||state==StateBranch))
1.54 @@ -184,10 +184,9 @@
1.55 } else if ( eName == "floatimage" &&
1.56 (state == StateMapCenter ||state==StateBranch))
1.57 {
1.58 - state=StateFloatImage;
1.59 - //FIXME-2 lastBranch->addFloatImage();
1.60 - //FIXME-2 lastFloat=lastBranch->getLastFloatImage();
1.61 - if (!readFloatImageAttr(atts)) return false;
1.62 + state=StateImage;
1.63 + lastImage=model->createImage(lastBranch);
1.64 + if (!readImageAttr(atts)) return false;
1.65 } else if ( (eName == "branch"||eName=="floatimage") && state == StateMap)
1.66 {
1.67 // This is used in vymparts, which have no mapcenter!
1.68 @@ -205,29 +204,28 @@
1.69 }
1.70 if (ti && ti->isBranchLikeType() )
1.71 {
1.72 - lastBranchItem=(BranchItem*)ti;
1.73 + lastBranch=(BranchItem*)ti;
1.74 if (eName=="branch")
1.75 {
1.76 state=StateBranch;
1.77 if (loadMode==ImportAdd)
1.78 {
1.79 - lastBranchItem=model->createBranch(lastBranchItem);
1.80 + lastBranch=model->createBranch(lastBranch);
1.81
1.82 } else
1.83 //FIXME-2 lastBranch->clear();
1.84 readBranchAttr (atts);
1.85 } else if (eName=="floatimage")
1.86 {
1.87 - state=StateFloatImage;
1.88 - //FIXME-2 lastBranch->addFloatImage();
1.89 - //FIXME-2 lastFloat=lastBranch->getLastFloatImage();
1.90 - if (!readFloatImageAttr(atts)) return false;
1.91 + state=StateImage;
1.92 + lastImage=model->createImage (lastBranch);
1.93 + if (!readImageAttr(atts)) return false;
1.94 } else return false;
1.95 } else return false;
1.96 } else if ( eName == "branch" && state == StateMapCenter)
1.97 {
1.98 state=StateBranch;
1.99 - lastBranchItem=model->createBranch(lastBranchItem);
1.100 + lastBranch=model->createBranch(lastBranch);
1.101 readBranchAttr (atts);
1.102 } else if ( eName == "htmlnote" && state == StateBranch)
1.103 {
1.104 @@ -247,7 +245,7 @@
1.105 if (!readXLinkAttr (atts)) return false;
1.106 } else if ( eName == "branch" && state == StateBranch )
1.107 {
1.108 - lastBranchItem=model->createBranch(lastBranchItem);
1.109 + lastBranch=model->createBranch(lastBranch);
1.110 readBranchAttr (atts);
1.111 } else if ( eName == "html" && state == StateHtmlNote )
1.112 {
1.113 @@ -282,15 +280,15 @@
1.114 break;
1.115 case StateMapCenter:
1.116 model->selectParent();
1.117 - model->emitDataHasChanged (lastBranchItem);
1.118 - lastBranchItem=(BranchItem*)(lastBranchItem->parent());
1.119 - lastBranchItem->setLastSelectedBranch (0); // Reset last selected to first child branch
1.120 + model->emitDataHasChanged (lastBranch);
1.121 + lastBranch=(BranchItem*)(lastBranch->parent());
1.122 + lastBranch->setLastSelectedBranch (0); // Reset last selected to first child branch
1.123 break;
1.124 case StateBranch:
1.125 model->selectParent();
1.126 - model->emitDataHasChanged (lastBranchItem);
1.127 - lastBranchItem=(BranchItem*)(lastBranchItem->parent());
1.128 - lastBranchItem->setLastSelectedBranch (0); // Reset last selected to first child branch
1.129 + model->emitDataHasChanged (lastBranch);
1.130 + lastBranch=(BranchItem*)(lastBranch->parent());
1.131 + lastBranch->setLastSelectedBranch (0); // Reset last selected to first child branch
1.132 break;
1.133 case StateHtml:
1.134 htmldata+="</"+eName+">";
1.135 @@ -299,7 +297,7 @@
1.136 state=StateHtmlNote;
1.137 htmldata.replace ("<br></br>","<br />");
1.138 no.setNote (htmldata);
1.139 - lastBranchItem->setNoteObj (no);
1.140 + lastBranch->setNoteObj (no);
1.141 }
1.142 break;
1.143 default:
1.144 @@ -327,19 +325,19 @@
1.145 case StateMapSetting:break;
1.146 case StateMapCenter: break;
1.147 case StateNote:
1.148 - lastBranchItem->setNote(ch_simplified);
1.149 + lastBranch->setNote(ch_simplified);
1.150 break;
1.151 case StateBranch: break;
1.152 case StateStandardFlag:
1.153 - lastBranchItem->activateStandardFlag(ch_simplified);
1.154 + lastBranch->activateStandardFlag(ch_simplified);
1.155 break;
1.156 - case StateFloatImage: break;
1.157 + case StateImage: break;
1.158 case StateHtmlNote: break;
1.159 case StateHtml:
1.160 htmldata+=ch_org;
1.161 break;
1.162 case StateHeading:
1.163 - lastBranchItem->setHeading(ch_simplified);
1.164 + lastBranch->setHeading(ch_simplified);
1.165 break;
1.166 default:
1.167 return false;
1.168 @@ -356,10 +354,12 @@
1.169 {
1.170 mainWindow->setProgressValue (branchesCurrent++);
1.171
1.172 + lastMI=lastBranch;
1.173 +
1.174 if (!readOOAttr(a)) return false;
1.175
1.176 if (!a.value( "scrolled").isEmpty() )
1.177 - lastBranchItem->toggleScroll();
1.178 + lastBranch->toggleScroll();
1.179 /*
1.180 if (!a.value( "frameType").isEmpty() )
1.181 lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
1.182 @@ -386,7 +386,7 @@
1.183 {
1.184 bool ok;
1.185 int x;
1.186 - if (lastOO)
1.187 + /* FIXME-2 if (lastOO)
1.188 {
1.189 if (!a.value( "frameType").isEmpty() )
1.190 lastOO->setFrameType (a.value("frameType"));
1.191 @@ -405,12 +405,13 @@
1.192 if (ok) lastOO->setFrameBorderWidth(x);
1.193 }
1.194 }
1.195 + */
1.196 return true;
1.197 }
1.198
1.199 bool parseVYMHandler::readOOAttr (const QXmlAttributes& a)
1.200 {
1.201 - if (lastBranchItem)
1.202 + if (lastMI)
1.203 {
1.204 bool okx,oky;
1.205 float x,y;
1.206 @@ -421,7 +422,7 @@
1.207 x=a.value("relPosX").toFloat (&okx);
1.208 y=a.value("relPosY").toFloat (&oky);
1.209 if (okx && oky )
1.210 - lastBranchItem->setRelPos (QPointF(x,y));
1.211 + lastBranch->setRelPos (QPointF(x,y));
1.212 else
1.213 return false; // Couldn't read relPos
1.214 }
1.215 @@ -433,21 +434,21 @@
1.216 x=a.value("absPosX").toFloat (&okx);
1.217 y=a.value("absPosY").toFloat (&oky);
1.218 if (okx && oky )
1.219 - lastBranchItem->setAbsPos (QPointF(x,y));
1.220 + lastBranch->setAbsPos (QPointF(x,y));
1.221 else
1.222 return false; // Couldn't read absPos
1.223 }
1.224 }
1.225 //if (!a.value( "id").isEmpty() )
1.226 - // lastBranchItem->setID (a.value ("id"));
1.227 + // lastBranch->setID (a.value ("id"));
1.228
1.229 if (!a.value( "url").isEmpty() )
1.230 - lastBranchItem->setURL (a.value ("url"));
1.231 + lastBranch->setURL (a.value ("url"));
1.232 if (!a.value( "vymLink").isEmpty() )
1.233 - lastBranchItem->setVymLink (a.value ("vymLink"));
1.234 + lastBranch->setVymLink (a.value ("vymLink"));
1.235 if (!a.value( "hideInExport").isEmpty() )
1.236 if (a.value("hideInExport")=="true")
1.237 - lastBranchItem->setHideInExport(true);
1.238 + lastBranch->setHideInExport(true);
1.239
1.240 /* FIXME-2
1.241 if (!a.value( "hideLink").isEmpty())
1.242 @@ -490,46 +491,39 @@
1.243 }
1.244 if (!a.value( "fonthint").isEmpty() )
1.245 no.setFontHint(a.value ("fonthint") );
1.246 - lastBranchItem->setNoteObj(no);
1.247 + lastBranch->setNoteObj(no);
1.248 return true;
1.249 }
1.250
1.251 -bool parseVYMHandler::readFloatImageAttr (const QXmlAttributes& a)
1.252 +bool parseVYMHandler::readImageAttr (const QXmlAttributes& a)
1.253 {
1.254 - lastOO=lastFloat;
1.255 + lastMI=lastImage;
1.256
1.257 //if (!readOOAttr(a)) return false;
1.258
1.259 - if (!a.value( "useOrientation").isEmpty() )
1.260 + /* FIXME-1 if (!a.value( "useOrientation").isEmpty() )
1.261 {
1.262 if (a.value ("useOrientation") =="true")
1.263 - lastFloat->setUseOrientation (true);
1.264 + lastImage->setUseOrientation (true);
1.265 else
1.266 - lastFloat->setUseOrientation (false);
1.267 + lastImage->setUseOrientation (false);
1.268 }
1.269 + */
1.270 if (!a.value( "href").isEmpty() )
1.271 {
1.272 - // Load FloatImage
1.273 - if (!lastFloat->load (parseHREF(a.value ("href") ) ))
1.274 + // Load Image
1.275 + if (!lastImage->load (parseHREF(a.value ("href") ) ))
1.276 {
1.277 QMessageBox::warning( 0, "Warning: " ,
1.278 - "Couldn't load float image\n"+parseHREF(a.value ("href") ));
1.279 - //FIXME-2 lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
1.280 - lastFloat=NULL;
1.281 + "Couldn't load image\n"+parseHREF(a.value ("href") ));
1.282 + //FIXME-0 lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat)));
1.283 + lastImage=NULL;
1.284 return true;
1.285 }
1.286
1.287 }
1.288 - if (!a.value( "floatExport").isEmpty() )
1.289 - {
1.290 - // Only for compatibility. THis is not used since 1.7.11
1.291 - if (a.value ("floatExport") =="true")
1.292 - lastFloat->setFloatExport(true);
1.293 - else
1.294 - lastFloat->setFloatExport (false);
1.295 - }
1.296 if (!a.value( "zPlane").isEmpty() )
1.297 - lastFloat->setZValue (a.value("zPlane").toInt ());
1.298 + lastImage->setZValue (a.value("zPlane").toInt ());
1.299 float x,y;
1.300 bool okx,oky;
1.301 if (!a.value( "relPosX").isEmpty() )
1.302 @@ -542,9 +536,9 @@
1.303 if (okx && oky)
1.304
1.305 {
1.306 - lastFloat->setRelPos (QPointF (x,y) );
1.307 + lastImage->setRelPos (QPointF (x,y) );
1.308 // make sure floats in mapcenter are repositioned to relative pos
1.309 - //FIXME-2 if (lastBranchItem->depth()==0) lastBranch->positionContents();
1.310 + //FIXME-0 if (lastBranch->depth()==0) lastBranch->positionContents();
1.311 }
1.312 else
1.313 // Couldn't read relPos
1.314 @@ -554,9 +548,9 @@
1.315
1.316 if (!readOOAttr(a)) return false;
1.317
1.318 - if (!a.value ("orgName").isEmpty() )
1.319 + if (!a.value ("originalName").isEmpty() )
1.320 {
1.321 - ((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName"));
1.322 + lastImage->setOriginalFilename (a.value("originalName"));
1.323 }
1.324 return true;
1.325 }