1.1 --- a/branchitem.cpp Thu Sep 03 08:52:00 2009 +0000
1.2 +++ b/branchitem.cpp Mon Sep 07 15:36:57 2009 +0000
1.3 @@ -12,6 +12,8 @@
1.4 {
1.5 //cout << "Constr. BranchItem\n";
1.6
1.7 + // Set type if parent is known yet
1.8 + // if not, type is set in insertBranch or TreeItem::appendChild
1.9 if (parent==rootItem)
1.10 setType (MapCenter);
1.11 else
1.12 @@ -49,7 +51,13 @@
1.13 if (pos>branchCounter) pos=branchCounter;
1.14 childItems.insert(pos+branchOffset,branch);
1.15 branch->parentItem=this;
1.16 + branch->rootItem=rootItem;
1.17 branch->setModel (model);
1.18 + if (parentItem==rootItem)
1.19 + setType (MapCenter);
1.20 + else
1.21 + setType (Branch);
1.22 +
1.23
1.24 if (branchCounter==0)
1.25 branchOffset=childItems.count()-1;
1.26 @@ -425,7 +433,8 @@
1.27 {
1.28 newbo->setParObj( ((MapItem*)parentItem)->getLMO() );
1.29 // Set visibility depending on parents
1.30 - if (((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() )
1.31 + if (parentItem!=rootItem &&
1.32 + ( ((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() ) )
1.33 newbo->setVisibility (false);
1.34 }
1.35 newbo->setDefAttr(BranchObj::NewBranch);
2.1 --- a/exports.cpp Thu Sep 03 08:52:00 2009 +0000
2.2 +++ b/exports.cpp Mon Sep 07 15:36:57 2009 +0000
2.3 @@ -106,11 +106,11 @@
2.4 return cancelFlag;
2.5 }
2.6
2.7 -QString ExportBase::getSectionString(BranchObj *bostart)
2.8 +QString ExportBase::getSectionString(TreeItem *start)
2.9 {
2.10 // Make prefix like "2.5.3" for "bo:2,bo:5,bo:3"
2.11 QString r;
2.12 - TreeItem *ti=bostart->getTreeItem();
2.13 + TreeItem *ti=start;
2.14 int depth=ti->depth();
2.15 while (depth>0)
2.16 {
2.17 @@ -148,21 +148,18 @@
2.18 BranchItem *cur=NULL;
2.19 BranchItem *prev=NULL;
2.20
2.21 - BranchObj *bo; //FIXME-3 still needed?
2.22 cur=model->next (cur,prev);
2.23 while (cur)
2.24 {
2.25 if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
2.26 {
2.27 - bo=(BranchObj*)(cur->getLMO());
2.28 - std::cout << "ExportASCII:: "<<cur->getHeading().toStdString()<<std::endl;
2.29 -
2.30 // Make indentstring
2.31 curIndent="";
2.32 for (i=0;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
2.33
2.34 if (!cur->hasHiddenExportParent() )
2.35 {
2.36 + //std::cout << "ExportASCII:: "<<curIndent.toStdString()<<cur->getHeading().toStdString()<<std::endl;
2.37 switch (cur->depth())
2.38 {
2.39 case 0:
2.40 @@ -171,7 +168,7 @@
2.41 break;
2.42 case 1:
2.43 ts << "\n";
2.44 - ts << (underline (getSectionString(bo) + cur->getHeading(), QString("-") ) );
2.45 + ts << (underline (getSectionString(cur) + cur->getHeading(), QString("-") ) );
2.46 ts << "\n";
2.47 break;
2.48 case 2:
3.1 --- a/exports.h Thu Sep 03 08:52:00 2009 +0000
3.2 +++ b/exports.h Mon Sep 07 15:36:57 2009 +0000
3.3 @@ -29,7 +29,7 @@
3.4 virtual bool canceled();
3.5 protected:
3.6 VymModel *model;
3.7 - virtual QString getSectionString (BranchObj*);
3.8 + virtual QString getSectionString (TreeItem*);
3.9
3.10 QDir tmpDir;
3.11 QDir outDir;
4.1 --- a/imageitem.cpp Thu Sep 03 08:52:00 2009 +0000
4.2 +++ b/imageitem.cpp Mon Sep 07 15:36:57 2009 +0000
4.3 @@ -38,6 +38,12 @@
4.4 return imageType;
4.5 }
4.6
4.7 +void ImageItem::load(const QPixmap &pm)
4.8 +{
4.9 + pixmap=pm;
4.10 + if (lmo) ((FloatImageObj*)lmo)->load (pixmap);
4.11 +}
4.12 +
4.13 bool ImageItem::load(const QString &fname)
4.14 {
4.15 bool ok=pixmap.load (fname);
5.1 --- a/imageitem.h Thu Sep 03 08:52:00 2009 +0000
5.2 +++ b/imageitem.h Mon Sep 07 15:36:57 2009 +0000
5.3 @@ -19,7 +19,7 @@
5.4 ImageItem();
5.5 ImageItem(const QList<QVariant> &data, TreeItem *parent = 0);
5.6
5.7 - ~ImageItem();
5.8 + virtual ~ImageItem();
5.9
5.10 protected:
5.11 void init();
5.12 @@ -27,6 +27,7 @@
5.13 public:
5.14 virtual ImageType getImageType();
5.15
5.16 + virtual void load (const QPixmap &pm);
5.17 virtual bool load (const QString &fname);
5.18 virtual FloatImageObj* createMapObj(QGraphicsScene *scene); //! Create classic object in GraphicsView
5.19
6.1 --- a/linkablemapobj.cpp Thu Sep 03 08:52:00 2009 +0000
6.2 +++ b/linkablemapobj.cpp Mon Sep 07 15:36:57 2009 +0000
6.3 @@ -32,6 +32,7 @@
6.4
6.5 LinkableMapObj::~LinkableMapObj()
6.6 {
6.7 + //cout << "Destructor LMO\n";
6.8 delete (bottomline);
6.9 delLink();
6.10 }
7.1 --- a/linkablemapobj.h Thu Sep 03 08:52:00 2009 +0000
7.2 +++ b/linkablemapobj.h Mon Sep 07 15:36:57 2009 +0000
7.3 @@ -16,8 +16,7 @@
7.4 The links are connecting the branches (BranchObj) and images (FloatImageObj) in the map.
7.5 */
7.6
7.7 -class LinkableMapObj:public QObject, public MapObj {
7.8 - Q_OBJECT // FIXME-3 really needed here?
7.9 +class LinkableMapObj:public MapObj {
7.10 public:
7.11 /*! Orientation of an object depends on the position relative to the parent */
7.12 enum Orientation {
7.13 @@ -50,7 +49,7 @@
7.14 LinkableMapObj ();
7.15 LinkableMapObj (QGraphicsScene*, TreeItem *ti=NULL);
7.16 LinkableMapObj (LinkableMapObj*);
7.17 - ~LinkableMapObj ();
7.18 + virtual ~LinkableMapObj ();
7.19 virtual void delLink();
7.20 virtual void init ();
7.21 virtual void copy (LinkableMapObj*);
8.1 --- a/mainwindow.cpp Thu Sep 03 08:52:00 2009 +0000
8.2 +++ b/mainwindow.cpp Mon Sep 07 15:36:57 2009 +0000
8.3 @@ -23,6 +23,8 @@
8.4 #include "warningdialog.h"
8.5 #include "xlinkitem.h"
8.6
8.7 +#include <modeltest.h> // FIXME-3
8.8 +
8.9 #if defined(Q_OS_WIN32)
8.10 // Define only this structure as opposed to
8.11 // including full 'windows.h'. FindWindow
8.12 @@ -1707,13 +1709,18 @@
8.13 {
8.14 VymModel *vm=new VymModel;
8.15
8.16 +new ModelTest(vm, this); //FIXME-3
8.17 +
8.18 +
8.19 VymView *vv=new VymView (vm);
8.20 vymViews.append (vv);
8.21 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
8.22 tabWidget->setCurrentIndex (vymViews.count() );
8.23 vv->initFocus();
8.24
8.25 -
8.26 + // Create MapCenter for empty map
8.27 + //vm->createMapCenter();
8.28 +
8.29 // For the very first map we do not have flagrows yet...
8.30 vm->select("mc:");
8.31 }
8.32 @@ -2797,6 +2804,7 @@
8.33 || actionSettingsAutoEditNewBranch->isOn())
8.34 {
8.35 m->select (bi);
8.36 + cout << "Main::editNewBranch prevSel="<<prevSelection.toStdString()<<endl;
8.37 if (actionSettingsAutoEditNewBranch->isOn())
8.38 currentMapEditor()->editHeading();
8.39 }
9.1 --- a/mapeditor.cpp Thu Sep 03 08:52:00 2009 +0000
9.2 +++ b/mapeditor.cpp Mon Sep 07 15:36:57 2009 +0000
9.3 @@ -520,7 +520,7 @@
9.4 animation->start();
9.5 */
9.6
9.7 -/* TODO Hide hidden stuff temporary, maybe add this as regular function somewhere
9.8 +/* FIXME-4 Hide hidden stuff temporary, maybe add this as regular function somewhere
9.9 if (hidemode==HideNone)
9.10 {
9.11 setHideTmpMode (HideExport);
9.12 @@ -809,21 +809,18 @@
9.13 if (model->getSelectedBranchObj() )
9.14 {
9.15 // Context Menu on branch or mapcenter
9.16 - //FIXME-3 model->updateActions(); needed?
9.17 branchContextMenu->popup(e->globalPos() );
9.18 } else
9.19 {
9.20 if (model->getSelectedImage() )
9.21 {
9.22 // Context Menu on floatimage
9.23 - // model->updateActions(); FIXME-3 needed?
9.24 floatimageContextMenu->popup(e->globalPos() );
9.25 }
9.26 }
9.27 } else
9.28 { // No MapObj found, we are on the Canvas itself
9.29 // Context Menu on scene
9.30 - // model->updateActions(); FIXME-3 needed?
9.31
9.32 // Open context menu synchronously to position new mapcenter
9.33 model->setContextPos (p);
10.1 --- a/mapitem.h Thu Sep 03 08:52:00 2009 +0000
10.2 +++ b/mapitem.h Mon Sep 07 15:36:57 2009 +0000
10.3 @@ -3,7 +3,6 @@
10.4
10.5 #include <QPointF>
10.6
10.7 -//#include "xmlobj.h"
10.8 #include "treeitem.h"
10.9
10.10 class LinkableMapObj;
10.11 @@ -12,7 +11,7 @@
10.12 classes.
10.13
10.14 This is done even while no QGraphicsView is availabe. This is useful
10.15 - if e.g. on a small device like a cellphone te full map is not used,
10.16 + if e.g. on a small device like a cellphone the full map is not used,
10.17 but just a treeview instead.
10.18 */
10.19
11.1 --- a/ornamentedobj.h Thu Sep 03 08:52:00 2009 +0000
11.2 +++ b/ornamentedobj.h Mon Sep 07 15:36:57 2009 +0000
11.3 @@ -23,7 +23,7 @@
11.4 public:
11.5 OrnamentedObj (QGraphicsScene*, TreeItem *ti=NULL);
11.6 OrnamentedObj (OrnamentedObj*);
11.7 - ~OrnamentedObj ();
11.8 + virtual ~OrnamentedObj ();
11.9 virtual void init ();
11.10 virtual void copy (OrnamentedObj*);
11.11
12.1 --- a/treeeditor.cpp Thu Sep 03 08:52:00 2009 +0000
12.2 +++ b/treeeditor.cpp Mon Sep 07 15:36:57 2009 +0000
12.3 @@ -18,7 +18,7 @@
12.4 model=m;
12.5
12.6 /*
12.7 -// MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this); // FIXME-0 trying to use proxy...
12.8 +// MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this); // FIXME-1 trying to use proxy...
12.9 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel (this);
12.10
12.11 proxyModel->setSourceModel(model);
13.1 --- a/treeitem.cpp Thu Sep 03 08:52:00 2009 +0000
13.2 +++ b/treeitem.cpp Mon Sep 07 15:36:57 2009 +0000
13.3 @@ -15,7 +15,7 @@
13.4
13.5 TreeItem::TreeItem()
13.6 {
13.7 - //cout << "Constr. TI this="<<this<<endl;
13.8 + cout << "Constr. TI this="<<this<<endl;
13.9 init();
13.10 itemData.clear();
13.11 rootItem=this;
13.12 @@ -41,27 +41,7 @@
13.13 while (!childItems.isEmpty())
13.14 {
13.15 ti=childItems.takeFirst();
13.16 - switch (ti->getType() )
13.17 - {
13.18 - case TreeItem::MapCenter:
13.19 - delete (BranchItem*)ti;
13.20 - break;
13.21 - case TreeItem::Branch:
13.22 - delete (BranchItem*)ti;
13.23 - break;
13.24 - case TreeItem::Image:
13.25 - delete (ImageItem*)ti;
13.26 - break;
13.27 - case TreeItem::Attribute:
13.28 - delete (AttributeItem*)ti;
13.29 - break;
13.30 - case TreeItem::XLink:
13.31 - delete (XLinkItem*)ti;
13.32 - break;
13.33 - default:
13.34 - delete ti;
13.35 - break;
13.36 - }
13.37 + delete ti;
13.38 }
13.39 }
13.40
13.41 @@ -96,17 +76,6 @@
13.42 }
13.43
13.44
13.45 -/*
13.46 -void TreeItem::copy (OrnamentedObj* other) //FIXME-3 probably need deep copy of branches and data!
13.47 -
13.48 -{
13.49 - note.copy (other->note);
13.50 - model=other->model;
13.51 - hideExport=officially
13.52 - other->hideExport;
13.53 -}
13.54 -*/
13.55 -
13.56 void TreeItem::setModel (VymModel *m)
13.57 {
13.58 model=m;
13.59 @@ -238,7 +207,7 @@
13.60
13.61 int TreeItem::columnCount() const
13.62 {
13.63 - return itemData.count();
13.64 + return 1;
13.65 }
13.66
13.67 int TreeItem::branchCount() const
13.68 @@ -270,11 +239,6 @@
13.69 return 0;
13.70 }
13.71
13.72 -int TreeItem::column() const
13.73 -{
13.74 - return 0;
13.75 -}
13.76 -
13.77 int TreeItem::depth()
13.78 {
13.79 // Rootitem d=-1
13.80 @@ -291,6 +255,7 @@
13.81
13.82 TreeItem *TreeItem::parent()
13.83 {
13.84 + //cout << "TI::parent of "<<getHeadingStd()<<" is "<<parentItem<<endl;
13.85 return parentItem;
13.86 }
13.87
13.88 @@ -301,15 +266,8 @@
13.89
13.90 int TreeItem::num()
13.91 {
13.92 - switch (type)
13.93 - {
13.94 - case MapCenter: return parentItem->childItems.indexOf (this) - parentItem->branchOffset;
13.95 - case Branch: return parentItem->childItems.indexOf (this) - parentItem->branchOffset;
13.96 - case Image: return parentItem->childItems.indexOf (this) - parentItem->imageOffset;
13.97 - case Attribute: return parentItem->childItems.indexOf (this) - parentItem->attributeOffset;
13.98 - case XLink: return parentItem->childItems.indexOf (this) - parentItem->xlinkOffset;
13.99 - default: return -1;
13.100 - }
13.101 + if (!parentItem) return -1;
13.102 + return parentItem->num (this);
13.103 }
13.104
13.105 int TreeItem::num (TreeItem *item)
13.106 @@ -334,7 +292,7 @@
13.107
13.108 TreeItem::Type TreeItem::getType()
13.109 {
13.110 - if (type==Branch && depth()==0) return MapCenter; //FIXME-2 should not be necesssary
13.111 + if (type==Branch && depth()==0) return MapCenter; //FIXME-3 should not be necesssary
13.112 return type;
13.113 }
13.114
13.115 @@ -439,7 +397,7 @@
13.116 {
13.117 NoteObj n;
13.118 n.setNote(s);
13.119 - setNoteObj (n,false);
13.120 + setNoteObj (n);
13.121 }
13.122
13.123 void TreeItem::clearNote()
13.124 @@ -448,7 +406,7 @@
13.125 systemFlags.deactivate ("system-note");
13.126 }
13.127
13.128 -void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor){
13.129 +void TreeItem::setNoteObj(const NoteObj &n){
13.130 note=n;
13.131 if (!note.isEmpty() && !systemFlags.isActive ("system-note"))
13.132 systemFlags.activate ("system-note");
13.133 @@ -525,11 +483,6 @@
13.134 return &standardFlags;
13.135 }
13.136
13.137 -/* FIXME-3 void TreeItem::updateToolBar()
13.138 -{
13.139 - standardFlags.updateToolBar();
13.140 -}
13.141 -*/
13.142 QStringList TreeItem::activeSystemFlagNames ()
13.143 {
13.144 return systemFlags.activeFlagNames();
13.145 @@ -676,49 +629,45 @@
13.146 }
13.147
13.148
13.149 -void TreeItem::setHideTmp (HideTmpMode mode) //FIXME-2
13.150 +void TreeItem::setHideTmp (HideTmpMode mode) //FIXME-2 update visibility in derived objects...
13.151 {
13.152 - if (isBranchLikeType() )
13.153 - ((BranchItem*)this)->updateVisibility();
13.154 /*
13.155 if (type==Image)
13.156 - //updateVisibility();
13.157 - */
13.158 -
13.159 -/*
13.160 + ((ImageItem*)this)->updateVisibility();
13.161 + */
13.162
13.163 if (mode==HideExport && (hideExport || hasHiddenExportParent() ) )
13.164 {
13.165 // Hide stuff according to hideExport flag and parents
13.166 - //setVisibility (false);
13.167 - updateVisibility();
13.168 - //FIXME-2 hidden=true;
13.169 + // if (lmo) lmo->setVisibility (false);
13.170 + hidden=true;
13.171 }else
13.172 {
13.173 // Do not hide, but still take care of scrolled status
13.174 -
13.175 -
13.176 + hidden=false;
13.177 +/*
13.178 XXXXXXXX treeItem should be THIS
13.179
13.180 move visible to TreeItem???
13.181
13.182 BranchObj now has updateContents
13.183 -
13.184 - maybe also start "bool TreeItem::branchlikeType"
13.185 -
13.186 -
13.187 +*/
13.188 +/*
13.189 + if (isBranchLikeType() )
13.190 + ((BranchItem*)this)->updateVisibility();
13.191
13.192 if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem))
13.193 setVisibility (false);
13.194 else
13.195 setVisibility (true);
13.196 - //FIXME-2 hidden=false;
13.197 +*/
13.198 }
13.199
13.200 -*/
13.201 +/*
13.202 // And take care of my children
13.203 for (int i=0; i<branchCount(); ++i)
13.204 - getBranchNum(i)->setHideTmp (mode);
13.205 + getBranchNum(i)->setHideTmp (mode); // FIXME-4 maybe also consider images and other types
13.206 +*/
13.207 }
13.208
13.209 bool TreeItem::hasHiddenExportParent()
13.210 @@ -752,6 +701,11 @@
13.211 return hideExport;
13.212 }
13.213
13.214 +void TreeItem::updateVisibility()
13.215 +{
13.216 + // overloaded in derived objects
13.217 +}
13.218 +
13.219 bool TreeItem::isHidden()
13.220 {
13.221 return hidden;
14.1 --- a/treeitem.h Thu Sep 03 08:52:00 2009 +0000
14.2 +++ b/treeitem.h Mon Sep 07 15:36:57 2009 +0000
14.3 @@ -26,7 +26,7 @@
14.4
14.5 TreeItem();
14.6 TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
14.7 - ~TreeItem();
14.8 + virtual ~TreeItem();
14.9 void init();
14.10
14.11 // General housekeeping
14.12 @@ -52,7 +52,6 @@
14.13 virtual int attributeCount() const;
14.14
14.15 virtual int row() const;
14.16 - virtual int column() const;
14.17 virtual int depth() ;
14.18 virtual TreeItem *parent();
14.19
14.20 @@ -105,7 +104,7 @@
14.21 virtual void clearNote();
14.22 virtual QString getNote();
14.23 virtual bool hasEmptyNote();
14.24 - virtual void setNoteObj(const NoteObj &, bool updateNoteEditor=true); //FIXME-1 setNoteObj is called for every select or so???
14.25 + virtual void setNoteObj(const NoteObj &); //FIXME-3 setNoteObj is called for every select or so???
14.26
14.27 virtual NoteObj getNoteObj();
14.28 virtual QString getNoteASCII(const QString &indent, const int &width); // returns note (ASCII)
14.29 @@ -160,13 +159,15 @@
14.30 virtual XLinkObj* getXLinkObjNum(const int &n);
14.31
14.32 protected:
14.33 - bool hideExport; //! Hide this item in export
14.34 + bool hideExport; //! Hide this item in export
14.35 + bool hidden; //! Hidden in export if true
14.36 public:
14.37 virtual void setHideTmp (HideTmpMode);
14.38 virtual bool hasHiddenExportParent ();
14.39 virtual void setHideInExport(bool); // set export of object (and children)
14.40 virtual bool hideInExport();
14.41 virtual bool isHidden ();
14.42 + virtual void updateVisibility(); //! Sets visibility in LinkableMapObj, if existing
14.43
14.44 virtual QString getGeneralAttr();
14.45
14.46 @@ -192,7 +193,6 @@
14.47 int xlinkOffset;
14.48 int xlinkCounter;
14.49
14.50 - bool hidden; //! Hidden in export if true
14.51 };
14.52
14.53 #endif
15.1 --- a/treemodel.cpp Thu Sep 03 08:52:00 2009 +0000
15.2 +++ b/treemodel.cpp Mon Sep 07 15:36:57 2009 +0000
15.3 @@ -15,7 +15,7 @@
15.4 {
15.5 QList<QVariant> rootData;
15.6 rootData << "Heading" << "Type";
15.7 - rootItem = new TreeItem(rootData);
15.8 + rootItem = new BranchItem(rootData);
15.9 }
15.10
15.11 TreeModel::~TreeModel()
15.12 @@ -39,7 +39,7 @@
15.13 Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
15.14 {
15.15 if (!index.isValid())
15.16 - return Qt::ItemIsEnabled;
15.17 + return Qt::NoItemFlags;
15.18
15.19 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
15.20 }
15.21 @@ -58,23 +58,26 @@
15.22 if (!ti->parent())
15.23 return QModelIndex();
15.24 else
15.25 - return createIndex (ti->row(),ti->column(),ti);
15.26 + return createIndex (ti->row(),0,ti);
15.27 }
15.28
15.29 QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
15.30 const
15.31 {
15.32 + // Make sure to return invalid index for invalid values (see modeltest)
15.33 + if (row<0 || column<0) return QModelIndex();
15.34 + if (column!=0) return QModelIndex();
15.35 +
15.36 TreeItem *parentItem;
15.37
15.38 if (!parent.isValid())
15.39 - { //FIXME-3 left here for testing only, seems to work now...
15.40 + {
15.41 parentItem = rootItem;
15.42 /*
15.43 cout << "TM::index() no parent?! xxx\n";
15.44 cout << " row="<<row<<" col="<<column<<endl;
15.45 cout << " parent.internal="<< parent.internalPointer()<<endl;
15.46 */
15.47 - //return QModelIndex(); //FIXME-3 this line is new (testing)
15.48 // Somehow index is requested where parentIndex is invalid.
15.49 // what's happening here...?
15.50 // Check if Qt examples also return index of rootIem then...
15.51 @@ -84,6 +87,7 @@
15.52 parentItem = getItem (parent);
15.53
15.54 TreeItem *childItem = parentItem->child(row);
15.55 + //cout << "TM::index parentItem="<<parentItem<<" childItem="<<childItem<<" row="<<row<<" col="<<column<<endl;
15.56 if (childItem)
15.57 return createIndex(row, column, childItem);
15.58 else
15.59 @@ -106,10 +110,11 @@
15.60 if (parentItem == rootItem)
15.61 return QModelIndex();
15.62
15.63 +/*
15.64 if (!parentItem)
15.65 return QModelIndex(); // FIXME-3 do this to avoid segfault, but why?
15.66 // see also my question on qt-interest in march
15.67 -
15.68 +*/
15.69 return createIndex(parentItem->childNumber(), 0, parentItem);
15.70 }
15.71
15.72 @@ -127,13 +132,21 @@
15.73
15.74 int TreeModel::columnCount(const QModelIndex &parent) const
15.75 {
15.76 + int c;
15.77 if (parent.isValid())
15.78 - return getItem (parent)->columnCount();
15.79 + {
15.80 + c= getItem (parent)->columnCount();
15.81 + //cout << "TM::colCount c="<<c<<" parent="<<getItem (parent)<<endl;
15.82 + }
15.83 else
15.84 - return rootItem->columnCount();
15.85 + {
15.86 + c= rootItem->columnCount();
15.87 + //cout << "TM::colCount c="<<c<<" parent=invalid"<<endl;
15.88 + }
15.89 + return c;
15.90 }
15.91
15.92 -BranchItem* TreeModel::next(BranchItem* ¤t, BranchItem* &previous, BranchItem* start)
15.93 +BranchItem* TreeModel::next(BranchItem* ¤t, BranchItem* &previous, BranchItem* start) // FIXME-3 change this to nextBranch and use "next" for all TIs
15.94 {
15.95 /*FIXME-3 cout << "TM::next \n";
15.96 std::string ch="()"; if (current) ch=current->getHeadingStd();
15.97 @@ -224,6 +237,8 @@
15.98 ti=pi->getChildNum (row);
15.99 cout << " pi="<<pi<<" ti="<<ti<<endl;
15.100 pi->removeChild (row); // does not delete object!
15.101 + delete ti;
15.102 + /* FIXME-3
15.103 switch (ti->getType())
15.104 {
15.105 case TreeItem::MapCenter:
15.106 @@ -245,6 +260,7 @@
15.107 delete ti;
15.108 break;
15.109 }
15.110 + */
15.111 }
15.112 return true;
15.113 }
15.114 @@ -258,7 +274,7 @@
15.115 // cout << " item="<<item<<endl;
15.116 if (item) return item;
15.117 }
15.118 - return rootItem;
15.119 + return NULL;
15.120 }
15.121
15.122 TreeItem *TreeModel::getRootItem()
16.1 --- a/version.h Thu Sep 03 08:52:00 2009 +0000
16.2 +++ b/version.h Mon Sep 07 15:36:57 2009 +0000
16.3 @@ -7,7 +7,7 @@
16.4 #define __VYM_VERSION "1.13.0"
16.5 //#define __VYM_CODENAME "Codename: RC-1"
16.6 #define __VYM_CODENAME "Codename: development version, not for production!"
16.7 -#define __VYM_BUILD_DATE "2009-09-01"
16.8 +#define __VYM_BUILD_DATE "2009-09-07"
16.9
16.10
16.11 bool checkVersion(const QString &);
17.1 --- a/vym.pro Thu Sep 03 08:52:00 2009 +0000
17.2 +++ b/vym.pro Mon Sep 07 15:36:57 2009 +0000
17.3 @@ -215,3 +215,4 @@
17.4 INSTALLS += doc
17.5 DEFINES += VYM_DOCDIR=\\\"$${DOCDIR}\\\"
17.6
17.7 +include(test/modeltest/modeltest.pri)
18.1 --- a/vymmodel.cpp Thu Sep 03 08:52:00 2009 +0000
18.2 +++ b/vymmodel.cpp Mon Sep 07 15:36:57 2009 +0000
18.3 @@ -77,9 +77,6 @@
18.4
18.5 void VymModel::init ()
18.6 {
18.7 - // We should have at least one map center to start with
18.8 - // addMapCenter(); FIXME-2 VM create this in MapEditor as long as model is part of that
18.9 -
18.10 // No MapEditor yet
18.11 mapEditor=NULL;
18.12
18.13 @@ -844,11 +841,11 @@
18.14 }
18.15
18.16
18.17 -void VymModel::importDirInt(BranchObj *dst, QDir d)
18.18 -{
18.19 -/* FIXME-2 importDirInt not ported yet
18.20 - BranchObj *bo=getSelectedBranch();
18.21 - if (bo)
18.22 +void VymModel::importDirInt(BranchItem *dst, QDir d)
18.23 +{
18.24 + BranchItem *selbi=getSelectedBranch();
18.25 + BranchItem *bi;
18.26 + if (selbi)
18.27 {
18.28 // Traverse directories
18.29 d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
18.30 @@ -860,18 +857,16 @@
18.31 fi=list.at(i);
18.32 if (fi.fileName() != "." && fi.fileName() != ".." )
18.33 {
18.34 - dst->addBranch();
18.35 - bo=dst->getLastBranch();
18.36 - BranchItem *bi=(BranchItem*)(bo->getTreeItem());
18.37 + bi=addNewBranchInt(dst,-2);
18.38 bi->setHeading (fi.fileName() ); // FIXME-3 check this
18.39 - bo->setColor (QColor("blue"));
18.40 + bi->setHeadingColor (QColor("blue"));
18.41 bi->toggleScroll();
18.42 if ( !d.cd(fi.fileName()) )
18.43 QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi.fileName()));
18.44 else
18.45 {
18.46 // Recursively add subdirs
18.47 - importDirInt (bo,d);
18.48 + importDirInt (bi,d);
18.49 d.cdUp();
18.50 }
18.51 }
18.52 @@ -883,36 +878,31 @@
18.53 for (int i = 0; i < list.size(); ++i)
18.54 {
18.55 fi=list.at(i);
18.56 - dst->addBranch();
18.57 - bo=dst->getLastBranch();
18.58 - bo->setHeading (fi.fileName() );
18.59 - bo->setColor (QColor("black"));
18.60 + bi=addNewBranchInt (dst,-2);
18.61 + bi->setHeading (fi.fileName() );
18.62 + bi->setHeadingColor (QColor("black"));
18.63 if (fi.fileName().right(4) == ".vym" )
18.64 - bo->setVymLink (fi.filePath());
18.65 + bi->setVymLink (fi.filePath());
18.66 }
18.67 }
18.68 -*/
18.69 }
18.70
18.71 -void VymModel::importDirInt (const QString &s) // FIXME-2
18.72 -{
18.73 -/*
18.74 - BranchObj *bo=getSelectedBranch();
18.75 - if (bo)
18.76 +void VymModel::importDirInt (const QString &s)
18.77 +{
18.78 + BranchItem *selbi=getSelectedBranch();
18.79 + if (selbi)
18.80 {
18.81 - saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
18.82 + saveStateChangingPart (selbi,selbi,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
18.83
18.84 QDir d(s);
18.85 - importDirInt (bo,d);
18.86 + importDirInt (selbi,d);
18.87 }
18.88 -*/
18.89 }
18.90
18.91 -void VymModel::importDir() //FIXME-2
18.92 -{
18.93 -/*
18.94 - BranchObj *bo=getSelectedBranch();
18.95 - if (bo)
18.96 +void VymModel::importDir() //FIXME-3 check me... (not tested yet)
18.97 +{
18.98 + BranchItem *selbi=getSelectedBranch();
18.99 + if (selbi)
18.100 {
18.101 QStringList filters;
18.102 filters <<"VYM map (*.vym)";
18.103 @@ -930,7 +920,6 @@
18.104 //FIXME-3 VM needed? scene()->update();
18.105 }
18.106 }
18.107 -*/
18.108 }
18.109
18.110
18.111 @@ -1435,11 +1424,12 @@
18.112 parts.removeFirst();
18.113 if (typ=="mc" || typ=="bo")
18.114 ti=ti->getBranchNum (n);
18.115 - /* FIXME-2
18.116 + /* FIXME-2 add other types to getSelectionString and findBy...
18.117 else
18.118 if (typ="fi")
18.119 ti=ti->getImageNum (n);
18.120 */
18.121 + if(!ti) return NULL;
18.122 }
18.123 return ti;
18.124 }
18.125 @@ -1923,7 +1913,7 @@
18.126 }
18.127 }
18.128
18.129 -void VymModel::moveUp()
18.130 +void VymModel::moveUp() //FIXME-2 crashes if trying to move MCO
18.131 {
18.132 BranchItem *selbi=getSelectedBranch();
18.133 if (selbi)
18.134 @@ -1996,8 +1986,9 @@
18.135 emit (layoutAboutToBeChanged() );
18.136
18.137 parix=index(dst);
18.138 + if (!parix.isValid()) cout << "VM::createII invalid index\n";
18.139 n=dst->getRowNumAppend(newii);
18.140 - beginInsertRows (parix,n,n+1);
18.141 + beginInsertRows (parix,n,n);
18.142 dst->appendChild (newii);
18.143 endInsertRows ();
18.144
18.145 @@ -2023,12 +2014,13 @@
18.146 cData << "new xLink"<<"undef";
18.147
18.148 XLinkItem *newxli=new XLinkItem(cData) ;
18.149 + newxli->setBegin (bi);
18.150
18.151 emit (layoutAboutToBeChanged() );
18.152
18.153 parix=index(bi);
18.154 n=bi->getRowNumAppend(newxli);
18.155 - beginInsertRows (parix,n,n+1);
18.156 + beginInsertRows (parix,n,n);
18.157 bi->appendChild (newxli);
18.158 endInsertRows ();
18.159
18.160 @@ -2036,7 +2028,6 @@
18.161
18.162 // save scroll state. If scrolled, automatically select
18.163 // new branch in order to tmp unscroll parent...
18.164 - newxli->setBegin (bi);
18.165 if (createMO)
18.166 {
18.167 newxli->createMapObj(mapScene);
18.168 @@ -2060,7 +2051,7 @@
18.169
18.170 QModelIndex parix=index(selbi);
18.171 int n=selbi->getRowNumAppend (a);
18.172 - beginInsertRows (parix,n,n+1);
18.173 + beginInsertRows (parix,n,n);
18.174 selbi->appendChild (a);
18.175 endInsertRows ();
18.176
18.177 @@ -2087,22 +2078,22 @@
18.178 return bi;
18.179 }
18.180
18.181 -BranchItem* VymModel::addMapCenter(QPointF absPos) //FIXME-2 absPos not used in context menu?!
18.182 +BranchItem* VymModel::addMapCenter(QPointF absPos)
18.183 // createMapCenter could then probably be merged with createBranch
18.184 {
18.185
18.186 // Create TreeItem
18.187 QModelIndex parix=index(rootItem);
18.188
18.189 - int n=rootItem->branchCount();
18.190 -
18.191 - emit (layoutAboutToBeChanged() );
18.192 - beginInsertRows (parix,n,n+1);
18.193 -
18.194 QList<QVariant> cData;
18.195 cData << "VM:addMapCenter" << "undef";
18.196 BranchItem *newbi=new BranchItem (cData,rootItem);
18.197 newbi->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
18.198 + int n=rootItem->getRowNumAppend (newbi);
18.199 +
18.200 + emit (layoutAboutToBeChanged() );
18.201 + beginInsertRows (parix,n,n);
18.202 +
18.203 rootItem->appendChild (newbi);
18.204
18.205 endInsertRows();
18.206 @@ -2110,12 +2101,13 @@
18.207
18.208 // Create MapObj
18.209 newbi->setPositionMode (MapItem::Absolute);
18.210 - newbi->createMapObj(mapScene);
18.211 + BranchObj *bo=newbi->createMapObj(mapScene);
18.212 + if (bo) bo->move (absPos);
18.213
18.214 return newbi;
18.215 }
18.216
18.217 -BranchItem* VymModel::addNewBranchInt(BranchItem *dst,int num)
18.218 +BranchItem* VymModel::addNewBranchInt(BranchItem *dst,int num)
18.219 {
18.220 // Depending on pos:
18.221 // -3 insert in children of parent above selection
18.222 @@ -2140,7 +2132,7 @@
18.223 parbi=dst;
18.224 parix=index(parbi);
18.225 n=parbi->getRowNumAppend (newbi);
18.226 - beginInsertRows (parix,n,n+1);
18.227 + beginInsertRows (parix,n,n);
18.228 parbi->appendChild (newbi);
18.229 endInsertRows ();
18.230 }else if (num==-1 || num==-3)
18.231 @@ -2350,7 +2342,7 @@
18.232 QString("Delete %1").arg(getObjectName(ti))
18.233 );
18.234 }
18.235 - // FIXME-0 savestate missing for deletion of other times
18.236 + // FIXME-1 savestate missing for deletion of other types than above
18.237 unselect();
18.238 deleteItem (ti);
18.239 emitDataHasChanged (pi);
18.240 @@ -2576,22 +2568,20 @@
18.241 }
18.242 }
18.243
18.244 -void VymModel::addFloatImage (const QPixmap &img) //FIXME-2 drag & drop
18.245 -{
18.246 -/*
18.247 - BranchObj *bo=getSelectedBranch();
18.248 - if (bo)
18.249 - {
18.250 - FloatImageObj *fio=bo->addFloatImage();
18.251 - fio->load(img);
18.252 - fio->setOriginalFilename("No original filename (image added by dropevent)");
18.253 - QString s=getSelectString(bo);
18.254 - saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio );
18.255 - saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image");
18.256 - reposition();
18.257 - // FIXME-3 VM needed? scene()->update();
18.258 - }
18.259 -*/
18.260 +void VymModel::addFloatImage (const QPixmap &img)
18.261 +{
18.262 + BranchItem *selbi=getSelectedBranch();
18.263 + if (selbi)
18.264 + {
18.265 + ImageItem *ii=createImage (selbi);
18.266 + ii->load(img);
18.267 + ii->setOriginalFilename("No original filename (image added by dropevent)");
18.268 + QString s=getSelectString(selbi);
18.269 + saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",ii );
18.270 + saveState (ii,"delete ()", selbi,QString("paste(%1)").arg(curStep),"Pasting dropped image");
18.271 + reposition();
18.272 + // FIXME-3 VM needed? scene()->update();
18.273 + }
18.274 }
18.275
18.276
18.277 @@ -3815,7 +3805,6 @@
18.278
18.279 void VymModel::exportImage(QString fname, bool askName, QString format)
18.280 {
18.281 -/* FIXME-2 export as image, but directly from mapEditor?!
18.282 if (fname=="")
18.283 {
18.284 fname=getMapName()+".png";
18.285 @@ -3842,7 +3831,6 @@
18.286 QPixmap pix (mapEditor->getPixmap());
18.287 pix.save(fname, format);
18.288 setExportMode (false);
18.289 -*/
18.290 }
18.291
18.292
18.293 @@ -4596,23 +4584,6 @@
18.294 mapEditor->setSelectionColor (col);
18.295 }
18.296
18.297 -/*
18.298 -void VymModel::changeSelection (const QItemSelection &newsel,const QItemSelection &oldsel)
18.299 -{
18.300 - cout << "VymModel::changeSelection (";
18.301 - if (!newsel.indexes().isEmpty() )
18.302 - cout << getItem(newsel.indexes().first() )->getHeading().toStdString();
18.303 - cout << ",";
18.304 - if (!oldsel.indexes().isEmpty() )
18.305 - cout << getItem(oldsel.indexes().first() )->getHeading().toStdString();
18.306 - cout << ")\n";
18.307 -}
18.308 -*/
18.309 -
18.310 -void VymModel::updateSelection (const QItemSelection &newsel,const QItemSelection &oldsel) //FIXME-4 connected but not used so far
18.311 -{
18.312 -}
18.313 -
18.314 void VymModel::emitSelectionChanged(const QItemSelection &newsel)
18.315 {
18.316 emit (selectionChanged(newsel,newsel)); // needed e.g. to update geometry in editor
18.317 @@ -4914,13 +4885,13 @@
18.318 return getSelectString (getSelectedItem());
18.319 }
18.320
18.321 -QString VymModel::getSelectString (LinkableMapObj *lmo) // FIXME-2 VM needs to use TreeModel. Port all calls to this funtion to the one using TreeItem below...
18.322 +QString VymModel::getSelectString (LinkableMapObj *lmo) // only for convenience. Used in MapEditor
18.323 {
18.324 if (!lmo) return QString();
18.325 return getSelectString (lmo->getTreeItem() );
18.326 }
18.327
18.328 -QString VymModel::getSelectString (TreeItem *ti) //FIXME-1 does not return "mc:"
18.329 +QString VymModel::getSelectString (TreeItem *ti)
18.330 {
18.331 QString s;
18.332 if (!ti) return s;
19.1 --- a/vymmodel.h Thu Sep 03 08:52:00 2009 +0000
19.2 +++ b/vymmodel.h Mon Sep 07 15:36:57 2009 +0000
19.3 @@ -122,7 +122,7 @@
19.4 void saveFloatImage ();
19.5
19.6 private:
19.7 - void importDirInt(BranchObj *,QDir);
19.8 + void importDirInt(BranchItem *,QDir);
19.9 void importDirInt(const QString&);
19.10 public:
19.11 void importDir();
19.12 @@ -598,9 +598,6 @@
19.13 signals:
19.14 void selectionChanged(const QItemSelection &newsel, const QItemSelection &oldsel);
19.15
19.16 -public slots:
19.17 - void updateSelection (const QItemSelection &newSel, const QItemSelection &delSel);
19.18 -
19.19 public:
19.20 void emitSelectionChanged(const QItemSelection &oldsel);
19.21 void emitSelectionChanged();
20.1 --- a/vymview.cpp Thu Sep 03 08:52:00 2009 +0000
20.2 +++ b/vymview.cpp Mon Sep 07 15:36:57 2009 +0000
20.3 @@ -37,10 +37,6 @@
20.4 mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
20.5
20.6 connect (
20.7 - selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)),
20.8 - model,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
20.9 -
20.10 - connect (
20.11 model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)),
20.12 mapEditor,SLOT (updateData(const QModelIndex &) ) );
20.13
21.1 --- a/xlinkobj.h Thu Sep 03 08:52:00 2009 +0000
21.2 +++ b/xlinkobj.h Mon Sep 07 15:36:57 2009 +0000
21.3 @@ -12,7 +12,7 @@
21.4 class XLinkObj:public MapObj {
21.5 public:
21.6 XLinkObj (QGraphicsScene* scene, TreeItem* ti);
21.7 - ~XLinkObj ();
21.8 + virtual ~XLinkObj ();
21.9 virtual void init ();
21.10 virtual void setEnd (QPointF);
21.11 void updateXLink();
22.1 --- a/xmlobj.cpp Thu Sep 03 08:52:00 2009 +0000
22.2 +++ b/xmlobj.cpp Mon Sep 07 15:36:57 2009 +0000
22.3 @@ -28,6 +28,10 @@
22.4 indentwidth=4;
22.5 }
22.6
22.7 +XMLObj::~XMLObj()
22.8 +{
22.9 +}
22.10 +
22.11
22.12 // returns <s at />
22.13 QString XMLObj::singleElement(QString s, QString at)
23.1 --- a/xmlobj.h Thu Sep 03 08:52:00 2009 +0000
23.2 +++ b/xmlobj.h Mon Sep 07 15:36:57 2009 +0000
23.3 @@ -10,6 +10,7 @@
23.4 {
23.5 public:
23.6 XMLObj();
23.7 + virtual ~XMLObj();
23.8 QString singleElement(QString,QString); // name,attr
23.9 QString beginElement(QString,QString); // name,attr
23.10 QString beginElement(QString); // name