# HG changeset patch # User insilmaril # Date 1244461016 0 # Node ID 25e634a7e1dc260e998163b1428a1f05b9fa9e6e # Parent 6e4b586aa88a7ea9f1a77c66728bfb3c97c94adb Images basically work (again) diff -r 6e4b586aa88a -r 25e634a7e1dc branchitem.cpp --- a/branchitem.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/branchitem.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -7,7 +7,7 @@ using namespace std; -BranchItem::BranchItem(const QList &data, TreeItem *parent):TreeItem (data,parent) +BranchItem::BranchItem(const QList &data, MapItem *parent):MapItem (data,parent) { //cout << "Constr. BranchItem\n"; @@ -18,7 +18,7 @@ BranchItem::~BranchItem() { - //cout << "Destr. BranchItem "<saveToDir (tmpdir,prefix); -*/ + // Save Images + for (int i=0; isaveToDir (tmpdir,prefix); // save note if (!note.isEmpty() ) @@ -310,15 +307,19 @@ if (getBranchObj()->isInClickBox (p) && (this != excludeTI) && getBranchObj()->isVisibleObj() ) return this; -/* FIXME-2 // Search float images - for (int i=0; iisInClickBox(p) && - (floatimage.at(i) != excludeTI) && - floatimage.at(i)->getParObj()!= excludeTI && - floatimage.at(i)->isVisibleObj() - ) return floatimage.at(i)->getTreeItem(); -*/ - return NULL; + // Search images + ImageItem *ii; + for (int i=0; igetLMO(); + if (mo && mo->isInClickBox(p) && + (ii != excludeTI) && + this!= excludeTI && + mo->isVisibleObj() + ) return ii; + } + return NULL; } TreeItem* BranchItem::findID (QString sid) @@ -353,7 +354,7 @@ if (lmo) { - lmo->setParObj (parentItem->getLMO() ); + lmo->setParObj ( ((MapItem*)parentItem)->getLMO() ); } } @@ -375,9 +376,9 @@ newbo->setFrameType (FrameObj::Rectangle); } else { - newbo->setParObj(parentItem->getLMO() ); + newbo->setParObj( ((MapItem*)parentItem)->getLMO() ); // Set visibility depending on parents - if (((BranchItem*)parentItem)->scrolled || !parentItem->getLMO()->isVisibleObj() ) + if (((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() ) newbo->setVisibility (false); } newbo->setDefAttr(BranchObj::NewBranch); diff -r 6e4b586aa88a -r 25e634a7e1dc branchitem.h --- a/branchitem.h Wed Jun 03 20:37:17 2009 +0000 +++ b/branchitem.h Mon Jun 08 11:36:56 2009 +0000 @@ -1,17 +1,17 @@ #ifndef BRANCHITEM_H #define BRANCHITEM_H -#include "treeitem.h" +#include "mapitem.h" class QString; class BranchObj; class QGraphicsScene; -class BranchItem:public TreeItem +class BranchItem:public MapItem { public: - BranchItem(const QList &data, TreeItem *parent = 0); + BranchItem(const QList &data, MapItem *parent = 0); virtual ~BranchItem(); void copy (BranchItem *item); diff -r 6e4b586aa88a -r 25e634a7e1dc branchobj.cpp --- a/branchobj.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/branchobj.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -272,8 +272,12 @@ void BranchObj::move (double x, double y) { OrnamentedObj::move (x,y); - for (int i=0; ireposition(); + FloatImageObj *fio; + for (int i=0; iimageCount(); ++i ) + { + fio=treeItem->getImageObjNum(i); + if (fio) fio->reposition(); + } positionBBox(); } diff -r 6e4b586aa88a -r 25e634a7e1dc floatimageobj.cpp --- a/floatimageobj.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/floatimageobj.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -8,9 +8,6 @@ // FloatImageObj ///////////////////////////////////////////////////////////////// -uint FloatImageObj::saveCounter=0; // make instance - - FloatImageObj::FloatImageObj ():FloatObj() { // cout << "Const FloatImageObj ()\n"; @@ -20,7 +17,7 @@ FloatImageObj::FloatImageObj (QGraphicsScene* s):FloatObj(s) { - // cout << "Const FloatImageObj (s) called from MapCenterObj (s)\n"; +// cout << "Const FloatImageObj (s) called from MapCenterObj (s)\n"; setParObj (this); init(); } @@ -155,58 +152,6 @@ // TODO } -QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix) -{ - //FIXME-2 if (hidden) return ""; - - saveCounter++; - - QString useOrientAttr; - if (useOrientation) - useOrientAttr=attribut ("useOrientation","true"); - else - useOrientAttr=attribut ("useOrientation","false"); - - QString saveInMapAttr; - if (saveInMap) - saveInMapAttr=attribut ("saveInMap","true"); - else - - saveInMapAttr=attribut ("saveInMap","false"); - - QString exportAttr; - if (floatExport) - exportAttr=attribut ("floatExport","true"); - else - exportAttr=attribut ("floatExport","false"); - - QString zAttr=attribut ("zPlane",QString().setNum(zPlane)); - QString url; - - url="images/"+prefix+"image-" + QString().number(saveCounter,10) + ".png" ; - - // And really save the image - icon->save (tmpdir +"/"+ url, "PNG"); - - QString nameAttr=attribut ("orgName",originalFilename); - - return singleElement ("floatimage", - getOrnXMLAttr() - +useOrientAttr - +saveInMapAttr - +exportAttr - +zAttr - +attribut ("href",QString ("file:")+url) - +nameAttr - ); -} - -void FloatImageObj::resetSaveCounter() -{ - saveCounter=0; -} - - QRectF FloatImageObj::getTotalBBox() { return bbox; diff -r 6e4b586aa88a -r 25e634a7e1dc floatimageobj.h --- a/floatimageobj.h Wed Jun 03 20:37:17 2009 +0000 +++ b/floatimageobj.h Mon Jun 08 11:36:56 2009 +0000 @@ -33,14 +33,10 @@ virtual QRectF getTotalBBox(); // return BBox including children virtual QRectF getBBoxSizeWithChildren(); // return size of BBox including children virtual void calcBBoxSizeWithChildren(); // calc size of BBox including children recursivly - virtual QString saveToDir(const QString &,const QString&); - virtual void resetSaveCounter(); - protected: ImageObj *icon; bool saveInMap; - static uint saveCounter; // numerate the files during saveToDir QString filetype; QString filename; QString originalFilename; diff -r 6e4b586aa88a -r 25e634a7e1dc floatobj.cpp --- a/floatobj.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/floatobj.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -1,7 +1,5 @@ #include "floatobj.h" -extern QAction* actionEditToggleFloatExport; - ///////////////////////////////////////////////////////////////// // FloatObj ///////////////////////////////////////////////////////////////// @@ -98,14 +96,3 @@ return bboxTotal; } -void FloatObj::select() -{ - LinkableMapObj::select(); - LinkableMapObj::setLinkColor(parObj->getLinkColor()); -} - -void FloatObj::unselect() -{ - LinkableMapObj::unselect(); -} - diff -r 6e4b586aa88a -r 25e634a7e1dc floatobj.h --- a/floatobj.h Wed Jun 03 20:37:17 2009 +0000 +++ b/floatobj.h Mon Jun 08 11:36:56 2009 +0000 @@ -29,11 +29,6 @@ virtual QRectF getTotalBBox(); // return BBox including children virtual QRectF getBBoxSizeWithChildren(); // return size of BBox including children - virtual void resetSaveCounter()=0; - - virtual void select(); - virtual void unselect(); - protected: bool floatExport; int zPlane; diff -r 6e4b586aa88a -r 25e634a7e1dc mainwindow.cpp --- a/mainwindow.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/mainwindow.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -3448,14 +3448,11 @@ } if ( selti->getType()==TreeItem::Image) { - /* FIXME-2 - FloatObj *fo=(FloatImageObj*)selection; - actionOpenURL->setEnabled (false); actionOpenVymLink->setEnabled (false); actionDeleteVymLink->setEnabled (false); actionToggleHideExport->setEnabled (true); - actionToggleHideExport->setOn (fo->hideInExport() ); + actionToggleHideExport->setOn (selti->hideInExport() ); actionCopy->setEnabled (true); @@ -3464,11 +3461,10 @@ for (int i=0; isetEnabled(false); actionDelete->setEnabled (true); - actionFormatHideLinkUnselected->setOn - ( selection->getHideLinkUnselected()); + // FIXME-2 actionFormatHideLinkUnselected->setOn + // ( selection->getHideLinkUnselected()); actionMoveUp->setEnabled (false); actionMoveDown->setEnabled (false); - */ } //image } else diff -r 6e4b586aa88a -r 25e634a7e1dc mapeditor.cpp --- a/mapeditor.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/mapeditor.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -186,7 +186,10 @@ { if (index.isValid()) { - LinkableMapObj* lmo=(static_cast(index.internalPointer()))->getLMO(); + LinkableMapObj* lmo=NULL; + TreeItem *ti= static_cast(index.internalPointer()); + if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() ) + lmo=((MapItem*)ti)->getLMO(); if (lmo) setScrollBarPosTarget (lmo->getBBox() ); } } @@ -596,7 +599,7 @@ QPointF p = mapToScene(e->pos()); TreeItem *ti=findMapItem (p, NULL); LinkableMapObj* lmo=NULL; - if (ti) lmo=ti->getLMO(); //FIXME-2 get rid of lmo... + if (ti) lmo=((MapItem*)ti)->getLMO(); if (lmo) { // MapObj was found @@ -613,7 +616,7 @@ branchContextMenu->popup(e->globalPos() ); } else { - if (model->getSelectedFloatImage() ) + if (model->getSelectedImageItem() ) { // Context Menu on floatimage // model->updateActions(); FIXME-3 needed? @@ -680,7 +683,7 @@ QPointF p = mapToScene(e->pos()); TreeItem *ti=findMapItem (p, NULL); LinkableMapObj* lmo=NULL; - if (ti) lmo=ti->getLMO(); //FIXME-3 get rid of lmo... + if (ti) lmo=((MapItem*)ti)->getLMO(); e->accept(); @@ -750,18 +753,11 @@ /* cout << "ME::mouse pressed\n"; cout << " lmo="<getTreeItem(); - /* - cout << " lmo="<row()<<","<column()<<") = "<index( ti->row(), ti->column(), model->index (0,0,QModelIndex()) ); + // Get clicked LMO model->select (ti); // Left Button Move Branches @@ -823,8 +819,8 @@ QPointF p = mapToScene(e->pos()); TreeItem *seli=model->getSelectedItem(); LinkableMapObj* lmosel=NULL; //FIXME-2 get rid of lmosel - if (seli) - lmosel=seli->getLMO(); + if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image)) + lmosel=((MapItem*)seli)->getLMO(); // Move the selected MapObj if ( lmosel && movingObj) @@ -847,14 +843,14 @@ TreeItem *dsti=findMapItem (p, seli); LinkableMapObj* dst=NULL; if (dsti && dsti!=seli && dsti->isBranchLikeType()) - dst=dsti->getLMO(); //FIXME-2 get rid of lmo... + dst=((MapItem*)dsti)->getLMO(); else dsti=NULL; - FloatObj *fio=model->getSelectedFloatImage(); - if (fio) + if (lmosel && seli->getType()==TreeItem::Image) { + FloatObj *fio=(FloatImageObj*)lmosel; fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fio->setRelPos(); fio->updateLink(); //no need for reposition, if we update link here @@ -971,7 +967,7 @@ if (seli) dsti=findMapItem(p, seli); LinkableMapObj* dst=NULL; if (dsti && dsti->isBranchLikeType ()) - dst=dsti->getLMO(); //FIXME-2 get rid of dst... + dst=((MapItem*)dsti)->getLMO(); else dsti=NULL; @@ -1014,22 +1010,25 @@ // Have we been moving something? if ( seli && movingObj ) { - FloatImageObj *fo=model->getSelectedFloatImage(); - if(fo) + if (seli->getType()==TreeItem::Image) { - // Moved FloatObj. Maybe we need to reposition - QString pold=qpointfToString(movingObj_orgRelPos); - QString pnow=qpointfToString(fo->getRelPos()); - model->saveState( - fo->getTreeItem(), // FIXME-3 - "moveRel "+pold, - fo->getTreeItem(), // FIXME-3 - "moveRel "+pnow, - QString("Move %1 to relative position %2").arg(model->getObjectName(fo)).arg(pnow)); + FloatImageObj *fio=(FloatImageObj*)(((MapItem*)seli)->getLMO()); + if(fio) + { + // Moved FloatObj. Maybe we need to reposition + QString pold=qpointfToString(movingObj_orgRelPos); + QString pnow=qpointfToString(fio->getRelPos()); + model->saveState( + seli, + "moveRel "+pold, + seli, + "moveRel "+pnow, + QString("Move %1 to relative position %2").arg(model->getObjectName(seli)).arg(pnow)); - fo->getParObj()->requestReposition(); - model->reposition(); - } + fio->getParObj()->requestReposition(); + model->reposition(); + } + } BranchItem *bi=model->getSelectedBranchItem(); if (bi && bi->depth()==0) @@ -1051,7 +1050,7 @@ if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch ) { // A branch was moved LinkableMapObj* lmosel=NULL; //FIXME-2 get rid of lmosel - lmosel=seli->getLMO(); + lmosel=((MapItem*)seli)->getLMO(); // save the position in case we link to mapcenter QPointF savePos=QPointF (lmosel->getAbsPos() ); @@ -1095,11 +1094,11 @@ QString postSelStr=model->getSelectString(lmosel); QString postNum=QString::number (seli->num(),10); - QString undoCom="linkTo (\""+ + QString undoCom="relinkTo (\""+ preParStr+ "\"," + preNum +"," + QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+ ")"; - QString redoCom="linkTo (\""+ + QString redoCom="relinkTo (\""+ preDstParStr + "\"," + postNum + "," + QString ("%1,%2").arg(savePos.x()).arg(savePos.y())+ ")"; @@ -1270,8 +1269,20 @@ event->acceptProposedAction(); } -void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &oldsel) +void MapEditor::updateSelection(QItemSelection newsel,QItemSelection oldsel) { + // Here in MapEditor we can only select Branches and Images + QModelIndex ix; + foreach (ix,newsel.indexes() ) + { + TreeItem *ti= static_cast(ix.internalPointer()); + if (ti->getType()!=TreeItem::Branch && ti->getType()!=TreeItem::Image ) + newsel.indexes().removeOne (ix); + } + + while (newsel.indexes().count() < selboxList.count() ) + delete selboxList.takeFirst(); + // Take care to tmp scroll/unscroll if (!oldsel.isEmpty()) { @@ -1332,7 +1343,7 @@ { index=newsel.indexes().at(i); ti= static_cast(index.internalPointer()); - lmo=ti->getLMO(); + lmo=((MapItem*)ti)->getLMO(); bbox=lmo->getBBox(); sb->setRect ( bbox.x(),bbox.y(), @@ -1358,7 +1369,7 @@ if (ti->isBranchLikeType()) { - BranchObj *bo=(BranchObj*)ti->getLMO(); + BranchObj *bo=(BranchObj*) ((MapItem*)ti)->getLMO(); bo->updateData(); } diff -r 6e4b586aa88a -r 25e634a7e1dc mapeditor.h --- a/mapeditor.h Wed Jun 03 20:37:17 2009 +0000 +++ b/mapeditor.h Mon Jun 08 11:36:56 2009 +0000 @@ -132,7 +132,7 @@ QColor selectionColor; public slots: - void updateSelection(const QItemSelection &,const QItemSelection &); // update selection + void updateSelection(QItemSelection ,QItemSelection); // update selection void updateData (const QModelIndex&); // update data public: void setSelectionColor (QColor c); diff -r 6e4b586aa88a -r 25e634a7e1dc mapitem.cpp --- a/mapitem.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/mapitem.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -5,9 +5,20 @@ #include using namespace std; +#include "misc.h" //cout << QPointF MapItem::MapItem() { + init(); +} + +MapItem::MapItem(const QList &data, TreeItem *parent):TreeItem (data,parent) +{ + init(); +} + +void MapItem::init() +{ lmo=NULL; posMode=Unused; } @@ -63,23 +74,33 @@ QString MapItem::getAttr() { + QString s; + if (parentItem==rootItem) + posMode=Absolute; + else + { + if (type==TreeItem::Image ||depth()==1) + posMode=Relative; + else + posMode=Unused; + } switch (posMode) { case Relative: if (lmo) pos=lmo->getRelPos(); - return - attribut("relPosX",QString().setNum(pos.x())) + - attribut("relPosY",QString().setNum(pos.y())); + s= attribut("relPosX",QString().setNum(pos.x())) + + attribut("relPosY",QString().setNum(pos.y())); break; case Absolute: if (lmo) pos=lmo->getAbsPos(); - return - attribut("absPosX",QString().setNum(pos.x())) + - attribut("absPosY",QString().setNum(pos.y())); + s=attribut("absPosX",QString().setNum(pos.x())) + + attribut("absPosY",QString().setNum(pos.y())); break; - default: - return QString(); - break; + default: break; } + if (hideExport) + return s+attribut("hideInExport","true"); + else + return s; } diff -r 6e4b586aa88a -r 25e634a7e1dc mapitem.h --- a/mapitem.h Wed Jun 03 20:37:17 2009 +0000 +++ b/mapitem.h Mon Jun 08 11:36:56 2009 +0000 @@ -3,9 +3,11 @@ #include +#include "treeitem.h" #include "xmlobj.h" class LinkableMapObj; +class TreeItem; /*! /brief MapItem is used to store information of MapObj and inherited classes. @@ -15,7 +17,7 @@ but just a treeview instead. */ -class MapItem: public XMLObj +class MapItem:public TreeItem, public XMLObj { public: enum PositionMode {Unused,Absolute,Relative}; @@ -25,6 +27,8 @@ public: MapItem(); + MapItem (const QList &data, TreeItem *parent = 0); + void init(); /*! Used to save relative position while map is not in QGraphicsView */ virtual void setRelPos(const QPointF&); diff -r 6e4b586aa88a -r 25e634a7e1dc ornamentedobj.cpp --- a/ornamentedobj.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/ornamentedobj.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -1,11 +1,6 @@ -#include - #include "ornamentedobj.h" -#include "texteditor.h" -#include "mapeditor.h" #include "linkablemapobj.h" - -extern TextEditor *textEditor; +#include "vymmodel.h" ///////////////////////////////////////////////////////////////// // OrnamentedObj @@ -250,48 +245,8 @@ } -QString OrnamentedObj::getSystemFlagName(const QPointF &p) +QString OrnamentedObj::getSystemFlagName(const QPointF &p) //FIXME-3 { return systemFlags->getFlagName(p); } -/* FIXME-3 should move to VymView ?! void OrnamentedObj::getNoteFromTextEditor () -{ - note.setFilenameHint (textEditor->getFilename()); - note.setFontHint (textEditor->getFontHint() ); - setNote( textEditor->getText() ); -} -*/ - -QString OrnamentedObj::getOrnXMLAttr() //FIXME-2 still needed? -{ - QString posAttr; - - if (treeItem->depth()==0) - posAttr= - attribut("absPosX",QString().setNum(absPos.x())) + - attribut("absPosY",QString().setNum(absPos.y())); - else - { - /* FIXME-2 - if (treeItem->depth()==1 || typid (*this)==typid (FloatImageObj)) - { - if (relPos.x()==0 && relPos.y()==0) - setRelPos(); - posAttr= - attribut("relPosX",QString().setNum(relPos.x())) + - attribut("relPosY",QString().setNum(relPos.y())); - } else - posAttr=""; - */ - } - -/* FIXME-2 QString hideExpAttr; - if (hideExport) - hideExpAttr= attribut("hideInExport","true"); - else - hideExpAttr=""; -*/ - return posAttr +getLinkAttr() ;//+hideExpAttr; -} - diff -r 6e4b586aa88a -r 25e634a7e1dc ornamentedobj.h --- a/ornamentedobj.h Wed Jun 03 20:37:17 2009 +0000 +++ b/ornamentedobj.h Mon Jun 08 11:36:56 2009 +0000 @@ -55,9 +55,6 @@ virtual void deactivateStandardFlag(const QString &name); virtual QString getSystemFlagName (const QPointF &p); - //virtual void getNoteFromTextEditor ();// FIXME-3 should move to vymview?! - virtual QString getOrnXMLAttr(); // get attributes for saveToDir - protected: HeadingObj *heading; // Heading FlagRowObj *systemFlags; // System Flags diff -r 6e4b586aa88a -r 25e634a7e1dc treeitem.cpp --- a/treeitem.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/treeitem.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -11,7 +11,15 @@ extern FlagRow* standardFlagsMaster; -TreeItem::TreeItem(const QList &data, TreeItem *parent):MapItem() +TreeItem::TreeItem() +{ + init(); + itemData.clear(); + rootItem=this; + parentItem=NULL; +} + +TreeItem::TreeItem(const QList &data, TreeItem *parent) { //cout << "Constructor TreeItem this="<type) + { + case MapCenter: return branchOffset + branchCounter; + case Branch: return branchOffset + branchCounter; + case Image: return imageOffset + imageCounter; + default: return -1; + } +} + void TreeItem::appendChild(TreeItem *item) { - childItems.append(item); item->parentItem=this; item->rootItem=rootItem; item->setModel (model); - if (item->type == Branch || item->type ==MapCenter) + if (item->type == Image) { + childItems.insert (imageCounter,item); + // images are on top of list + if (imageCounter==0) + imageOffset=0; + imageCounter++; + branchOffset++; + } + + if (item->isBranchLikeType()) + { + // branches are on bottom of list + childItems.append(item); if (branchCounter==0) branchOffset=childItems.count()-1; branchCounter++; @@ -117,6 +148,12 @@ { if (childItems.at(row)->isBranchLikeType()) branchCounter--; + if (childItems.at(row)->type==Image) + { + imageCounter--; + if (branchOffset>0) + branchOffset--; + } childItems.removeAt (row); } } @@ -160,8 +197,7 @@ int TreeItem::imageCount() const { - int imageCounter=0; - return imageCounter; // FIXME-1 imageCounter needs to be calculated... + return imageCounter; } int TreeItem::xlinkCount() const // FIXME-2 check if xlinks are stored in a different way (global to model?) @@ -209,10 +245,9 @@ { switch (type) { - case Undefined: return -1; - case MapCenter: return parentItem->childItems.indexOf (this) - branchOffset; - case Branch: return parentItem->childItems.indexOf (this) - branchOffset; - case Image: return parentItem->childItems.indexOf (this) - imageOffset; + case MapCenter: return parentItem->childItems.indexOf (this) - parentItem->branchOffset; + case Branch: return parentItem->childItems.indexOf (this) - parentItem->branchOffset; + case Image: return parentItem->childItems.indexOf (this) - parentItem->imageOffset; default: return -1; } } @@ -220,9 +255,9 @@ int TreeItem::num (TreeItem *item) { if (!item) return -1; + if (!childItems.contains(item)) return -1; switch (item->getType()) { - case Undefined: return -1; case MapCenter: return childItems.indexOf (item) - branchOffset; case Branch: return childItems.indexOf (item) - branchOffset; case Image: return parentItem->childItems.indexOf (item) - imageOffset; @@ -348,8 +383,7 @@ systemFlags.deactivate ("system-note"); } -void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor) //FIXME-1 setNoteObj is called for every select or so??? -{ +void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor){ note=n; if (!note.isEmpty() && !systemFlags.isActive ("system-note")) systemFlags.activate ("system-note"); @@ -426,13 +460,12 @@ return &standardFlags; } -/* -void TreeItem::updateToolBar() +/* FIXME-3 void TreeItem::updateToolBar() { standardFlags.updateToolBar(); } */ -QStringList TreeItem::activeSystemFlagNames () //FIXME-1 missing: scrolled-tmp,hideInExport +QStringList TreeItem::activeSystemFlagNames () { return systemFlags.activeFlagNames(); } @@ -521,7 +554,7 @@ BranchItem* TreeItem::getBranchNum(const int &n) { - if (branchCounter>0) + if (n>=0 && n0) + if (n>=0 && nlmo); + return (BranchObj*)(getBranchNum(n)->getLMO()); } else return NULL; } @@ -552,6 +585,21 @@ return getBranchNum (lastSelectedBranchNum); } +ImageItem* TreeItem::getImageNum (const int &n) +{ + if (n>=0 && n0 ) + return (FloatImageObj*)(getImageNum(n)->getLMO()); + else + return NULL; +} void TreeItem::setHideTmp (HideTmpMode mode) { @@ -614,18 +662,14 @@ void TreeItem::setHideInExport(bool b) { - if (isBranchLikeType() ) + if (type==Branch || type==Image) { hideExport=b; - /* FIXME-1 call setVis and updateContentsSize... + // FIXME-1 call setVis and updateContentsSize... if (b) - systemFlags->activate("hideInExport"); + systemFlags.activate("hideInExport"); else - systemFlags->deactivate("hideInExport"); - calcBBoxSize(); - positionBBox(); - requestReposition(); - */ + systemFlags.deactivate("hideInExport"); } } diff -r 6e4b586aa88a -r 25e634a7e1dc treeitem.h --- a/treeitem.h Wed Jun 03 20:37:17 2009 +0000 +++ b/treeitem.h Mon Jun 08 11:36:56 2009 +0000 @@ -6,21 +6,23 @@ #include #include "flagrow.h" -#include "mapitem.h" #include "noteobj.h" #include "xmlobj.h" class LinkableMapObj; class BranchObj; class BranchItem; +class FloatImageObj; +class ImageItem; class VymModel; -class TreeItem:public MapItem +class TreeItem { public: enum Type {Undefined,MapCenter,Branch,Image}; enum HideTmpMode {HideNone, HideExport}; + TreeItem(); TreeItem(const QList &data, TreeItem *parent = 0); ~TreeItem(); void init(); @@ -29,6 +31,11 @@ virtual void setModel (VymModel *m); virtual VymModel* getModel(); + + /*! Return number of item, as it would be after it would have been appended. + This is used to notify view about layout changes before model is modified. */ + virtual int getRowNumAppend (TreeItem *child); + virtual void appendChild (TreeItem *child); virtual void removeChild (int row); virtual void removeChildBranches (); @@ -95,7 +102,8 @@ virtual void clearNote(); virtual QString getNote(); virtual bool hasEmptyNote(); - virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true); + virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true); //FIXME-1 setNoteObj is called for every select or so??? + virtual NoteObj getNoteObj(); virtual QString getNoteASCII(const QString &indent, const int &width); // returns note (ASCII) virtual QString getNoteASCII(); // returns note (ASCII) @@ -146,6 +154,8 @@ virtual void setLastSelectedBranch(int i); //! Set last selected branch directly virtual TreeItem* getLastSelectedBranch(); + virtual ImageItem* getImageNum(const int &n); + virtual FloatImageObj* getImageObjNum(const int &n); protected: bool hideExport; //! Hide this item in export public: diff -r 6e4b586aa88a -r 25e634a7e1dc treemodel.cpp --- a/treemodel.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/treemodel.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -5,6 +5,7 @@ #include "branchitem.h" #include "treeitem.h" +#include "imageitem.h" #include "treemodel.h" TreeModel::TreeModel(QObject *parent) @@ -108,6 +109,12 @@ BranchItem* TreeModel::next(BranchItem* ¤t, BranchItem* &previous, BranchItem* start) { +/*FIXME-3 cout << "TM::next \n"; + std::string ch="()"; if (current) ch=current->getHeadingStd(); + std::string ph="()"; if (previous) ph=previous->getHeadingStd(); + cout << " cur="<branchCount() >0 ) { +// cout << " yes, going deeper\n"; previous=current; current=current->getFirstBranch(); return current; } // turn around and go up again +// cout << " sorry, turn around\n"; + BranchItem *bi=current; + current=previous; + previous=bi; } +/* + cout << " coming from below\n"; + ch="()"; if (current) ch=current->getHeadingStd(); + ph="()"; if (previous) ph=previous->getHeadingStd(); + cout << " cur="<num()="<num()<getHeadingStd()<parent(); @@ -186,6 +204,9 @@ case TreeItem::Branch: delete (BranchItem*)ti; break; + case TreeItem::Image: + delete (ImageItem*)ti; + break; default: delete ti; break; diff -r 6e4b586aa88a -r 25e634a7e1dc version.h --- a/version.h Wed Jun 03 20:37:17 2009 +0000 +++ b/version.h Mon Jun 08 11:36:56 2009 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version, not for production!" -#define __VYM_BUILD_DATE "2009-06-03" +#define __VYM_BUILD_DATE "2009-06-08" bool checkVersion(const QString &); diff -r 6e4b586aa88a -r 25e634a7e1dc vym.pro --- a/vym.pro Wed Jun 03 20:37:17 2009 +0000 +++ b/vym.pro Mon Jun 08 11:36:56 2009 +0000 @@ -59,6 +59,7 @@ headingobj.h \ highlighter.h \ historywindow.h \ + imageitem.h \ imageobj.h \ imports.h \ linkablemapobj.h \ @@ -118,6 +119,7 @@ headingobj.cpp \ highlighter.cpp \ historywindow.cpp \ + imageitem.cpp \ imageobj.cpp \ imports.cpp \ linkablemapobj.cpp \ diff -r 6e4b586aa88a -r 25e634a7e1dc vymmodel.cpp --- a/vymmodel.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/vymmodel.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -234,7 +234,7 @@ // Reset the counters before saving // TODO constr. of FIO creates lots of objects, better do this in some other way... - FloatImageObj (mapScene).resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe... + ImageItem().resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe... // Build xml recursivly if (!saveSel || saveSel->getType()==TreeItem::MapCenter) @@ -260,6 +260,8 @@ xml.decIndent(); s+=xml.endElement("vymmap"); + //cout << s.toStdString() << endl; + if (writeflags) standardFlagsMaster->saveToDir (tmpdir+"/flags/","",writeflags); return s; } @@ -623,7 +625,7 @@ return err; } -void VymModel::addMapReplaceInt(const QString &undoSel, const QString &path) +void VymModel::addMapReplaceInt(const QString &undoSel, const QString &path) // FIXME-1 test e.g. with undo color subtree { QString pathDir=path.left(path.findRev("/")); QDir d(pathDir); @@ -700,15 +702,14 @@ */ } -FloatImageObj* VymModel::loadFloatImageInt (BranchItem *dst,QString fn) -{ - TreeItem *fi=createImage(dst); - if (fi) +ImageItem* VymModel::loadFloatImageInt (BranchItem *dst,QString fn) +{ + ImageItem *ii=createImage(dst); + if (ii) { - FloatImageObj *fio= ((FloatImageObj*)fi->getLMO()); - fio->load (fn); + ii->load (fn); reposition(); - return fio; + return ii; } return NULL; } @@ -735,16 +736,15 @@ // TODO loadFIO in QT4 use: lastImageDir=fd->directory(); lastImageDir=QDir (fd->dirPath()); QString s; - FloatImageObj *fio; + ImageItem *ii; for (int j=0; jselectedFiles().count(); j++) { s=fd->selectedFiles().at(j); - fio=loadFloatImageInt (selbi,s); - //FIXME-1 savestate for loadImage missing - /* - if (fio) + ii=loadFloatImageInt (selbi,s); + //FIXME-3 check savestate for loadImage + if (ii) saveState( - (LinkableMapObj*)fio, + (TreeItem*)ii, "delete ()", selbi, QString ("loadImage (%1)").arg(s ), @@ -753,7 +753,6 @@ else // TODO loadFIO error handling qWarning ("Failed to load "+s); - */ } } delete (p); @@ -761,16 +760,15 @@ } } -void VymModel::saveFloatImageInt (FloatImageObj *fio, const QString &type, const QString &fn) -{ - fio->save (fn,type); +void VymModel::saveFloatImageInt (ImageItem *ii, const QString &type, const QString &fn) +{ + ii->save (fn,type); } void VymModel::saveFloatImage () { - //FIXME-1 FloatImageObj *fio=selection.getFloatImage(); - FloatImageObj *fio=NULL; - if (fio) + ImageItem *ii=getSelectedImageItem(); + if (ii) { QFileDialog *fd=new QFileDialog( NULL); fd->setFilters (imageIO.getFilters()); @@ -808,7 +806,7 @@ break; } } - saveFloatImageInt (fio,fd->selectedFilter(),fn ); + saveFloatImageInt (ii,fd->selectedFilter(),fn ); } delete (fd); } @@ -992,40 +990,24 @@ findReset(); } -QString VymModel::getObjectName (const LinkableMapObj *lmo) // FIXME-3 should be obsolete -{ - QString s; - if (!lmo) return QString("Error: NULL has no name!"); - - TreeItem *ti=lmo->getTreeItem(); - if (ti->isBranchLikeType() ) - { - - s=lmo->getTreeItem()->getHeading(); - if (s=="") s="unnamed"; - return QString("branch (%1)").arg(s); - } - if (ti->getType()==TreeItem::Image) - return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename()); - return QString("Unknown type has no name!"); +QString VymModel::getObjectName (LinkableMapObj *lmo) // FIXME-3 should be obsolete +{ + if (!lmo || !lmo->getTreeItem() ) return QString(); + return getObjectName (lmo->getTreeItem() ); } -QString VymModel::getObjectName (const TreeItem *ti) +QString VymModel::getObjectName (TreeItem *ti) { QString s; if (!ti) return QString("Error: NULL has no name!"); - - if (ti->isBranchLikeType() ) - { - s=ti->getHeading(); - if (s=="") s="unnamed"; + s=ti->getHeading(); + if (s=="") s="unnamed"; + + if (ti->isBranchLikeType() ) //FIXME-3 shouldnt there also be mapcenter?? return QString("branch (%1)").arg(s); - } - /* FIXME-2 move floatimage to TreeModel first - if (type==TreeItem::Image) - return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename()); - */ + if (ti->getType()==TreeItem::Image) + return QString ("image (%1)").arg(ti->getHeading()); return QString("Unknown type has no name!"); } @@ -1480,7 +1462,7 @@ return QDate::currentDate().toString ("yyyy-MM-dd"); } -int VymModel::branchCount() // FIXME-2 Optimize this: use internal counter instead of going through whole map each time... +int VymModel::branchCount() // FIXME-4 Optimize this: use internal counter instead of going through whole map each time... { int c=0; BranchItem *cur=NULL; @@ -1627,9 +1609,9 @@ return urls; } -void VymModel::linkFloatImageTo(const QString &dstString) // FIXME-1 -{ - //FIXME-1 FloatImageObj *fio=selection.getFloatImage(); +void VymModel::linkFloatImageTo(const QString &dstString) // FIXME-0 +{ + //FIXME-0 FloatImageObj *fio=selection.getFloatImage(); FloatImageObj *fio=NULL; if (fio) { @@ -1640,7 +1622,7 @@ QString parString=getSelectString(dstPar); QString fioPreSelectString=getSelectString(fio); QString fioPreParentSelectString=getSelectString (fio->getParObj()); - // FIXME-1 ((BranchObj*)dst)->addFloatImage (fio); + // FIXME-0 ((BranchObj*)dst)->addFloatImage (fio); unselect(); // ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio); fio=((BranchObj*)dst)->getLastFloatImage(); @@ -1813,20 +1795,23 @@ void VymModel::setHideExport(bool b) { - BranchItem *bi=getSelectedBranchItem(); - if (bi) + MapItem *mi=(MapItem*)getSelectedItem(); + if (mi && + (mi->getType()==TreeItem::Image ||mi->isBranchLikeType())) { - bi->setHideInExport (b); + mi->setHideInExport (b); QString u= b ? "false" : "true"; QString r=!b ? "false" : "true"; saveState( - bi, + mi, QString ("setHideExport (%1)").arg(u), - bi, + mi, QString ("setHideExport (%1)").arg(r), - QString ("Set HideExport flag of %1 to %2").arg(getObjectName(bi)).arg (r) + QString ("Set HideExport flag of %1 to %2").arg(getObjectName(mi)).arg (r) ); + emitDataHasChanged(mi); + emitSelectionChanged(); updateActions(); reposition(); // emitSelectionChanged(); @@ -1836,9 +1821,9 @@ void VymModel::toggleHideExport() { - BranchItem *selbi=getSelectedBranchItem(); - if (selbi) - setHideExport ( !selbi->hideInExport() ); + TreeItem *selti=getSelectedItem(); + if (selti) + setHideExport ( !selti->hideInExport() ); } @@ -1971,31 +1956,35 @@ return NULL; } -TreeItem* VymModel::createImage(BranchItem *dst) //FIXME-1 -{ - return NULL; -/* +ImageItem* VymModel::createImage(BranchItem *dst) +{ if (dst) { - FloatImageObj *newfio=bo->addFloatImage(); // FIXME-1 VM Old model, merge with below - - // Create TreeItem + QModelIndex parix; + int n; QList cData; - cData << "VM:createImage" << "undef"<<"undef"; - TreeItem *parti=bo->getTreeItem(); - TreeItem *ti=new TreeItem (cData,parti); - ti->setLMO (newfio); - ti->setType (TreeItem::Image); - parti->appendChild (ti); - - if (newfio) - { - newfio->setTreeItem (ti); - select (newfio); // FIXME-2 VM really needed here? - return ti; - } - } -*/ + cData << "VM::createImage" << "undef"<<"undef"; + + ImageItem *newii=new ImageItem (cData); + newii->setHeading (QApplication::translate("Heading of new image in map", "new image")); + + emit (layoutAboutToBeChanged() ); + + parix=index(dst); + n=dst->getRowNumAppend(newii); + beginInsertRows (parix,n,n+1); + dst->appendChild (newii); + endInsertRows (); + + emit (layoutChanged() ); + + // save scroll state. If scrolled, automatically select + // new branch in order to tmp unscroll parent... + newii->createMapObj(mapScene); + reposition(); + return newii; + } + return NULL; } BranchItem* VymModel::addMapCenter () @@ -2065,7 +2054,7 @@ { parbi=dst; parix=index(parbi); - n=parbi->childCount(); + n=parbi->getRowNumAppend (newbi); beginInsertRows (parix,n,n+1); parbi->appendChild (newbi); endInsertRows (); @@ -2073,8 +2062,9 @@ { // insert below selection parbi=(BranchItem*)dst->parent(); - parix=index(parbi); - n=dst->childNumber()+ (3+num)/2; //-1 |-> 1;-3 |-> 0 + parix=index(parbi); + + n=dst->childNumber() + (3+num)/2; //-1 |-> 1;-3 |-> 0 beginInsertRows (parix,n,n); parbi->insertBranch(n,newbi); endInsertRows (); @@ -2201,52 +2191,39 @@ { BranchItem *selbi=getSelectedBranchItem(); - if (!selbi) return; - - TreeItem *pi=selbi->parent(); - QModelIndex parentIndex=index(pi); - - if (selbi->isBranchLikeType() ) + if (selbi && selbi->isBranchLikeType() ) { unselect(); saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi))); - emit (layoutAboutToBeChanged() ); - - int n=selbi->childNum(); - beginRemoveRows (parentIndex,n,n); - removeRows (n,1,parentIndex); - endRemoveRows(); - select (pi); - emitShowSelection(); - reposition(); - - emit (layoutChanged() ); + TreeItem *pi=deleteItem (selbi); + if (pi) + { + select (pi); + emitShowSelection(); + } return; } - //FloatImageObj *fio=selection.getFloatImage(); //FIXME-1 VM still missing - -/* - if (fio) + ImageItem *ii=getSelectedImageItem(); + if (ii) { - BranchObj* par=(BranchObj*)fio->getParObj(); + BranchItem *pi=(BranchItem*)(ii->parent()); saveStateChangingPart( - par, - fio, + pi, + ii, "delete ()", - QString("Delete %1").arg(getObjectName(fio)) + QString("Delete %1").arg(getObjectName(ii)) ); unselect(); - par->removeFloatImage(fio); - select (par); + deleteItem (ii); + select (pi); reposition(); emitShowSelection(); return; } - */ } -void VymModel::deleteKeepChildren() +void VymModel::deleteKeepChildren() //FIXME-2 does not work yet for mapcenters { BranchItem *selbi=getSelectedBranchItem(); @@ -2275,7 +2252,15 @@ QString sel=getSelectString(selbi); unselect(); - //FIXME-0 missing in VM pi->removeBranchHere(selbi); + int pos=selbi->num(); + BranchItem *bi=selbi->getFirstBranch(); + while (bi) + { + relinkBranch (bi,pi,pos); + bi=selbi->getFirstBranch(); + pos++; + } + deleteItem (selbi); reposition(); select (sel); BranchObj *bo=getSelectedBranchObj(); @@ -2311,6 +2296,27 @@ } } +TreeItem* VymModel::deleteItem (TreeItem *ti) +{ + if (ti) + { + TreeItem *pi=ti->parent(); + QModelIndex parentIndex=index(pi); + + emit (layoutAboutToBeChanged() ); + + int n=ti->childNum(); + beginRemoveRows (parentIndex,n,n); + removeRows (n,1,parentIndex); + endRemoveRows(); + reposition(); + + emit (layoutChanged() ); + if (pi->depth()>0) return pi; + } + return NULL; +} + bool VymModel::scrollBranch(BranchItem *bi) { if (bi) @@ -2430,7 +2436,7 @@ } } -void VymModel::addFloatImage (const QPixmap &img) //FIXME-2 +void VymModel::addFloatImage (const QPixmap &img) //FIXME-0 { /* BranchObj *bo=getSelectedBranch(); @@ -3010,7 +3016,7 @@ if (ok) importDirInt(s); } ///////////////////////////////////////////////////////////////////// - } else /* FIXME-2 if (com=="linkTo") + } else if (com=="relinkTo") { if (!selti) { @@ -3023,21 +3029,21 @@ // 1 num in parent (for branches) // 2,3 x,y of mainbranch or mapcenter s=parser.parString(ok,0); - LinkableMapObj *dst=findObjBySelect (s); + TreeItem *dst=findBySelectString (s); if (dst) { - if (typid(*dst) == typid(BranchObj) ) + if (dst->getType()==TreeItem::Branch) { // Get number in parent n=parser.parInt (ok,1); if (ok) { - selb->linkTo ((BranchObj*)(dst),n); + relinkBranch (selbi,(BranchItem*)dst,n); emitSelectionChanged(); } - } else if (typid(*dst) == typid(MapCenterObj) ) + } else if (dst->getType()==TreeItem::MapCenter) { - selb->linkTo ((BranchObj*)(dst),-1); + relinkBranch (selbi,(BranchItem*)dst); // Get coordinates of mainbranch x=parser.parDouble(ok,2); if (ok) @@ -3045,32 +3051,33 @@ y=parser.parDouble(ok,3); if (ok) { - selbi->move (x,y); + if (selbi->getLMO()) selbi->getLMO()->move (x,y); emitSelectionChanged(); } } } } } - } else if ( selectionType() == TreeItem::Image) + } else if ( selti->getType() == TreeItem::Image) { if (parser.checkParCount(1)) { // 0 selectstring of parent s=parser.parString(ok,0); - LinkableMapObj *dst=findObjBySelect (s); + TreeItem *dst=findBySelectString (s); if (dst) { - if (typid(*dst) == typid(BranchObj) || - typid(*dst) == typid(MapCenterObj)) + /* FIXME-0 relink img + if (dst->isBranchLikeType()) linkFloatImageTo (getSelectString(dst)); + */ } else parser.setError (Aborted,"Destination is not a branch"); } } else parser.setError (Aborted,"Type of selection is not a floatimage or branch"); ///////////////////////////////////////////////////////////////////// - } else */ if (com=="loadImage") + } else if (com=="loadImage") { if (!selti) { @@ -3235,18 +3242,17 @@ ///////////////////////////////////////////////////////////////////// } else if (com=="saveImage") { - //FIXME-2 FloatImageObj *fio=selection.getFloatImage(); - FloatImageObj* fio=NULL; - if (!fio) + ImageItem *ii=getSelectedImageItem(); + if (!ii ) { - parser.setError (Aborted,"Type of selection is not an image"); + parser.setError (Aborted,"No image selected"); } else if (parser.checkParCount(2)) { s=parser.parString(ok,0); if (ok) { t=parser.parString(ok,1); - if (ok) saveFloatImageInt (fio,t,s); + if (ok) saveFloatImageInt (ii,t,s); } } ///////////////////////////////////////////////////////////////////// @@ -4553,10 +4559,7 @@ bool VymModel::select () { - QModelIndex index=selModel->selectedIndexes().first(); // TODO no multiselections yet - - TreeItem *item = getItem (index); - return select (item->getLMO() ); + return select (selModel->selectedIndexes().first()); // TODO no multiselections yet } bool VymModel::select (const QString &s) @@ -4924,7 +4927,7 @@ TreeItem::Type type=ti->getType(); if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image) { - return ti->getLMO(); + return ((MapItem*)ti)->getLMO(); } } return NULL; @@ -4934,7 +4937,7 @@ { TreeItem *ti = getSelectedBranchItem(); if (ti) - return (BranchObj*)ti->getLMO(); + return (BranchObj*)((MapItem*)ti)->getLMO(); else return NULL; } @@ -4970,9 +4973,15 @@ return list.first(); } -FloatImageObj* VymModel::getSelectedFloatImage() -{ - //FIXME-2 return selection.getFloatImage(); +ImageItem* VymModel::getSelectedImageItem() +{ + QModelIndexList list=selModel->selectedIndexes(); + if (!list.isEmpty()) + { + TreeItem *ti=getItem (list.first()); + if (ti && ti->getType()==TreeItem::Image) + return (ImageItem*)ti; + } return NULL; } @@ -4991,8 +5000,7 @@ { QString s; if (!ti) return s; - if (ti->getType() == TreeItem::Branch || - ti->getType() == TreeItem::MapCenter) + if (ti->isBranchLikeType()) { TreeItem *par=ti->parent(); if (par) diff -r 6e4b586aa88a -r 25e634a7e1dc vymmodel.h --- a/vymmodel.h Wed Jun 03 20:37:17 2009 +0000 +++ b/vymmodel.h Mon Jun 08 11:36:56 2009 +0000 @@ -5,7 +5,7 @@ #include #include "file.h" -#include "floatimageobj.h" +#include "imageitem.h" #include "mapeditor.h" #include "parser.h" #include "treeitem.h" @@ -107,8 +107,8 @@ void addMapReplaceInt(const QString & undoSel, const QString & path); void addMapInsertInt (const QString & path, int pos); - FloatImageObj* loadFloatImageInt (BranchItem *dst,QString); - void saveFloatImageInt (FloatImageObj*, const QString &, const QString &); + ImageItem* loadFloatImageInt (BranchItem *dst,QString); + void saveFloatImageInt (ImageItem*, const QString &, const QString &); public: void loadFloatImage (); void saveFloatImage (); @@ -151,8 +151,8 @@ Returns heading of a branch or name of an object for use in comment of undo/redo history */ - QString getObjectName(const LinkableMapObj*); - QString getObjectName(const TreeItem*); + QString getObjectName(LinkableMapObj*); + QString getObjectName(TreeItem*); void redo(); //!< Redo last action bool isRedoAvailable(); //!< True, if redo is available @@ -282,7 +282,7 @@ // The create methods are used to quickly parse a XML file BranchItem* createMapCenter(); //!< Create MapCenter BranchItem* createBranch(BranchItem *dst); //!< Create Branch - TreeItem* createImage(BranchItem *dst); //!< Create image + ImageItem* createImage(BranchItem *dst); //!< Create image /*! \brief Add new mapcenter @@ -323,11 +323,12 @@ */ bool relinkBranch (BranchItem* branch, BranchItem* dst, int pos =-1); - void deleteSelection(); //!< Delete selection - void deleteKeepChildren(); //!< remove branch, but keep children - void deleteChildren(); //!< keep branch, but remove children + void deleteSelection(); //!< Delete selection + void deleteKeepChildren(); //!< remove branch, but keep children + void deleteChildren(); //!< keep branch, but remove children private: + TreeItem* deleteItem(TreeItem*); //!< Delete item and return parent (if parent!= rootItem) bool scrollBranch(BranchItem *); bool unscrollBranch(BranchItem *); public: @@ -578,11 +579,11 @@ public: TreeItem::Type selectionType(); LinkableMapObj* getSelectedLMO(); - BranchObj* getSelectedBranchObj(); // FIXME-2 replace by item... + BranchObj* getSelectedBranchObj(); // FIXME-3 replace by item... BranchItem* getSelectedBranchItem(); TreeItem* getSelectedItem(); QModelIndex getSelectedIndex(); - FloatImageObj* getSelectedFloatImage(); + ImageItem* getSelectedImageItem(); QString getSelectString (); QString getSelectString (LinkableMapObj *lmo); QString getSelectString (TreeItem *item); diff -r 6e4b586aa88a -r 25e634a7e1dc xml-freemind.cpp --- a/xml-freemind.cpp Wed Jun 03 20:37:17 2009 +0000 +++ b/xml-freemind.cpp Mon Jun 08 11:36:56 2009 +0000 @@ -70,10 +70,7 @@ //FIXME-3 TreeItem *ti=model->first(); // this will be NULL !!! TreeItem *ti=NULL; - BranchObj *bo; - if (ti->getType()==TreeItem::MapCenter) - bo=(BranchObj*)(ti->getLMO()); - else + if (ti->getType()!=TreeItem::MapCenter) qWarning ("parseFreeMindHandler::startElement no mapCenter!!"); //cout <<"model="<clear(); - lastBranchItem=NULL; + lastBranch=NULL; if (!atts.value( "author").isEmpty() ) model->setAuthor(atts.value( "author" ) ); @@ -140,7 +140,7 @@ { // Really use the found mapcenter as MCO in a new map - lastBranchItem=(BranchItem*)model->createMapCenter(); + lastBranch=model->createMapCenter(); } else { // Treat the found mapcenter as a branch @@ -148,10 +148,10 @@ BranchItem *bi=model->getSelectedBranchItem(); if (bi) { - lastBranchItem=bi; + lastBranch=bi; if (loadMode==ImportAdd) { - lastBranchItem=model->createBranch(lastBranchItem); + lastBranch=model->createBranch(lastBranch); } //else //FIXME-3 lastBranch->clear(); } else @@ -170,7 +170,7 @@ if (!atts.value( "textColor").isEmpty() ) { col.setNamedColor(atts.value("textColor")); - lastBranchItem->setHeadingColor(col ); + lastBranch->setHeadingColor(col ); } } else if ( eName == "note" && (state == StateMapCenter ||state==StateBranch)) @@ -184,10 +184,9 @@ } else if ( eName == "floatimage" && (state == StateMapCenter ||state==StateBranch)) { - state=StateFloatImage; - //FIXME-2 lastBranch->addFloatImage(); - //FIXME-2 lastFloat=lastBranch->getLastFloatImage(); - if (!readFloatImageAttr(atts)) return false; + state=StateImage; + lastImage=model->createImage(lastBranch); + if (!readImageAttr(atts)) return false; } else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) { // This is used in vymparts, which have no mapcenter! @@ -205,29 +204,28 @@ } if (ti && ti->isBranchLikeType() ) { - lastBranchItem=(BranchItem*)ti; + lastBranch=(BranchItem*)ti; if (eName=="branch") { state=StateBranch; if (loadMode==ImportAdd) { - lastBranchItem=model->createBranch(lastBranchItem); + lastBranch=model->createBranch(lastBranch); } else //FIXME-2 lastBranch->clear(); readBranchAttr (atts); } else if (eName=="floatimage") { - state=StateFloatImage; - //FIXME-2 lastBranch->addFloatImage(); - //FIXME-2 lastFloat=lastBranch->getLastFloatImage(); - if (!readFloatImageAttr(atts)) return false; + state=StateImage; + lastImage=model->createImage (lastBranch); + if (!readImageAttr(atts)) return false; } else return false; } else return false; } else if ( eName == "branch" && state == StateMapCenter) { state=StateBranch; - lastBranchItem=model->createBranch(lastBranchItem); + lastBranch=model->createBranch(lastBranch); readBranchAttr (atts); } else if ( eName == "htmlnote" && state == StateBranch) { @@ -247,7 +245,7 @@ if (!readXLinkAttr (atts)) return false; } else if ( eName == "branch" && state == StateBranch ) { - lastBranchItem=model->createBranch(lastBranchItem); + lastBranch=model->createBranch(lastBranch); readBranchAttr (atts); } else if ( eName == "html" && state == StateHtmlNote ) { @@ -282,15 +280,15 @@ break; case StateMapCenter: model->selectParent(); - model->emitDataHasChanged (lastBranchItem); - lastBranchItem=(BranchItem*)(lastBranchItem->parent()); - lastBranchItem->setLastSelectedBranch (0); // Reset last selected to first child branch + model->emitDataHasChanged (lastBranch); + lastBranch=(BranchItem*)(lastBranch->parent()); + lastBranch->setLastSelectedBranch (0); // Reset last selected to first child branch break; case StateBranch: model->selectParent(); - model->emitDataHasChanged (lastBranchItem); - lastBranchItem=(BranchItem*)(lastBranchItem->parent()); - lastBranchItem->setLastSelectedBranch (0); // Reset last selected to first child branch + model->emitDataHasChanged (lastBranch); + lastBranch=(BranchItem*)(lastBranch->parent()); + lastBranch->setLastSelectedBranch (0); // Reset last selected to first child branch break; case StateHtml: htmldata+=""; @@ -299,7 +297,7 @@ state=StateHtmlNote; htmldata.replace ("

","
"); no.setNote (htmldata); - lastBranchItem->setNoteObj (no); + lastBranch->setNoteObj (no); } break; default: @@ -327,19 +325,19 @@ case StateMapSetting:break; case StateMapCenter: break; case StateNote: - lastBranchItem->setNote(ch_simplified); + lastBranch->setNote(ch_simplified); break; case StateBranch: break; case StateStandardFlag: - lastBranchItem->activateStandardFlag(ch_simplified); + lastBranch->activateStandardFlag(ch_simplified); break; - case StateFloatImage: break; + case StateImage: break; case StateHtmlNote: break; case StateHtml: htmldata+=ch_org; break; case StateHeading: - lastBranchItem->setHeading(ch_simplified); + lastBranch->setHeading(ch_simplified); break; default: return false; @@ -356,10 +354,12 @@ { mainWindow->setProgressValue (branchesCurrent++); + lastMI=lastBranch; + if (!readOOAttr(a)) return false; if (!a.value( "scrolled").isEmpty() ) - lastBranchItem->toggleScroll(); + lastBranch->toggleScroll(); /* if (!a.value( "frameType").isEmpty() ) lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1 @@ -386,7 +386,7 @@ { bool ok; int x; - if (lastOO) + /* FIXME-2 if (lastOO) { if (!a.value( "frameType").isEmpty() ) lastOO->setFrameType (a.value("frameType")); @@ -405,12 +405,13 @@ if (ok) lastOO->setFrameBorderWidth(x); } } + */ return true; } bool parseVYMHandler::readOOAttr (const QXmlAttributes& a) { - if (lastBranchItem) + if (lastMI) { bool okx,oky; float x,y; @@ -421,7 +422,7 @@ x=a.value("relPosX").toFloat (&okx); y=a.value("relPosY").toFloat (&oky); if (okx && oky ) - lastBranchItem->setRelPos (QPointF(x,y)); + lastBranch->setRelPos (QPointF(x,y)); else return false; // Couldn't read relPos } @@ -433,21 +434,21 @@ x=a.value("absPosX").toFloat (&okx); y=a.value("absPosY").toFloat (&oky); if (okx && oky ) - lastBranchItem->setAbsPos (QPointF(x,y)); + lastBranch->setAbsPos (QPointF(x,y)); else return false; // Couldn't read absPos } } //if (!a.value( "id").isEmpty() ) - // lastBranchItem->setID (a.value ("id")); + // lastBranch->setID (a.value ("id")); if (!a.value( "url").isEmpty() ) - lastBranchItem->setURL (a.value ("url")); + lastBranch->setURL (a.value ("url")); if (!a.value( "vymLink").isEmpty() ) - lastBranchItem->setVymLink (a.value ("vymLink")); + lastBranch->setVymLink (a.value ("vymLink")); if (!a.value( "hideInExport").isEmpty() ) if (a.value("hideInExport")=="true") - lastBranchItem->setHideInExport(true); + lastBranch->setHideInExport(true); /* FIXME-2 if (!a.value( "hideLink").isEmpty()) @@ -490,46 +491,39 @@ } if (!a.value( "fonthint").isEmpty() ) no.setFontHint(a.value ("fonthint") ); - lastBranchItem->setNoteObj(no); + lastBranch->setNoteObj(no); return true; } -bool parseVYMHandler::readFloatImageAttr (const QXmlAttributes& a) +bool parseVYMHandler::readImageAttr (const QXmlAttributes& a) { - lastOO=lastFloat; + lastMI=lastImage; //if (!readOOAttr(a)) return false; - if (!a.value( "useOrientation").isEmpty() ) + /* FIXME-1 if (!a.value( "useOrientation").isEmpty() ) { if (a.value ("useOrientation") =="true") - lastFloat->setUseOrientation (true); + lastImage->setUseOrientation (true); else - lastFloat->setUseOrientation (false); + lastImage->setUseOrientation (false); } + */ if (!a.value( "href").isEmpty() ) { - // Load FloatImage - if (!lastFloat->load (parseHREF(a.value ("href") ) )) + // Load Image + if (!lastImage->load (parseHREF(a.value ("href") ) )) { QMessageBox::warning( 0, "Warning: " , - "Couldn't load float image\n"+parseHREF(a.value ("href") )); - //FIXME-2 lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat))); - lastFloat=NULL; + "Couldn't load image\n"+parseHREF(a.value ("href") )); + //FIXME-0 lastBranch->removeFloatImage(((FloatImageObj*)(lastFloat))); + lastImage=NULL; return true; } } - if (!a.value( "floatExport").isEmpty() ) - { - // Only for compatibility. THis is not used since 1.7.11 - if (a.value ("floatExport") =="true") - lastFloat->setFloatExport(true); - else - lastFloat->setFloatExport (false); - } if (!a.value( "zPlane").isEmpty() ) - lastFloat->setZValue (a.value("zPlane").toInt ()); + lastImage->setZValue (a.value("zPlane").toInt ()); float x,y; bool okx,oky; if (!a.value( "relPosX").isEmpty() ) @@ -542,9 +536,9 @@ if (okx && oky) { - lastFloat->setRelPos (QPointF (x,y) ); + lastImage->setRelPos (QPointF (x,y) ); // make sure floats in mapcenter are repositioned to relative pos - //FIXME-2 if (lastBranchItem->depth()==0) lastBranch->positionContents(); + //FIXME-0 if (lastBranch->depth()==0) lastBranch->positionContents(); } else // Couldn't read relPos @@ -554,9 +548,9 @@ if (!readOOAttr(a)) return false; - if (!a.value ("orgName").isEmpty() ) + if (!a.value ("originalName").isEmpty() ) { - ((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName")); + lastImage->setOriginalFilename (a.value("originalName")); } return true; } diff -r 6e4b586aa88a -r 25e634a7e1dc xml-vym.h --- a/xml-vym.h Wed Jun 03 20:37:17 2009 +0000 +++ b/xml-vym.h Mon Jun 08 11:36:56 2009 +0000 @@ -20,7 +20,7 @@ bool readFrameAttr (const QXmlAttributes&); bool readOOAttr (const QXmlAttributes&); bool readNoteAttr (const QXmlAttributes&); - bool readFloatImageAttr (const QXmlAttributes&); + bool readImageAttr (const QXmlAttributes&); bool readXLinkAttr (const QXmlAttributes&); bool readHtmlAttr (const QXmlAttributes&); bool readSettingAttr (const QXmlAttributes&); @@ -40,7 +40,7 @@ StateFrame, StateStandardFlag, StateNote, - StateFloatImage, + StateImage, StateHeading }; @@ -53,6 +53,7 @@ QString htmldata; NoteObj no; - BranchItem* lastBranchItem; + BranchItem* lastBranch; + ImageItem* lastImage; }; #endif