1.1 --- a/vymmodel.cpp Wed Oct 29 17:42:34 2008 +0000
1.2 +++ b/vymmodel.cpp Tue Nov 04 12:09:10 2008 +0000
1.3 @@ -86,6 +86,9 @@
1.4 // No MapEditor yet
1.5 mapEditor=NULL;
1.6
1.7 + // Also no scene yet (should not be needed anyway) FIXME VM
1.8 + mapScene=NULL;
1.9 +
1.10 // History
1.11 mapNum++;
1.12 mapChanged=false;
1.13 @@ -120,6 +123,7 @@
1.14
1.15
1.16 // selections
1.17 + selModel=NULL;
1.18 selection.setModel (this);
1.19 selection.unselect();
1.20
1.21 @@ -223,7 +227,7 @@
1.22 xml.attribut("comment",comment) +
1.23 xml.attribut("date",getDate()) +
1.24 xml.attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
1.25 - xml.attribut("selectionColor", selection.getColor().name() ) +
1.26 + xml.attribut("selectionColor", mapEditor->getSelectionColor().name() ) +
1.27 xml.attribut("linkStyle", ls ) +
1.28 xml.attribut("linkColor", defLinkColor.name() ) +
1.29 xml.attribut("defXLinkColor", defXLinkColor.name() ) +
1.30 @@ -1589,8 +1593,9 @@
1.31
1.32 void VymModel::setScene (QGraphicsScene *s)
1.33 {
1.34 - mapScene=s;
1.35 - init(); // Here we have a mapScene set,
1.36 + cout << "VM::setscene scene="<<s<<endl;
1.37 + mapScene=s; // FIXME VM should not be necessary anymore, move all occurences to MapEditor
1.38 + //init(); // Here we have a mapScene set,
1.39 // which is (still) needed to create MapCenters
1.40 }
1.41
1.42 @@ -2000,6 +2005,7 @@
1.43 MapCenterObj* VymModel::addMapCenter ()
1.44 {
1.45 MapCenterObj *mco=addMapCenter (contextPos);
1.46 + cout <<"VM::addMCO () mapScene="<<mapScene<<endl;
1.47 selection.select (mco);
1.48 updateActions();
1.49 ensureSelectionVisible();
1.50 @@ -2164,6 +2170,7 @@
1.51 void VymModel::deleteSelection()
1.52 {
1.53 BranchObj *bo = selection.getBranch();
1.54 +
1.55 if (bo && selection.type()==Selection::MapCenter)
1.56 {
1.57 // BranchObj* par=(BranchObj*)(bo->getParObj());
1.58 @@ -2183,10 +2190,11 @@
1.59 }
1.60 if (bo && selection.type()==Selection::Branch)
1.61 {
1.62 - //FIXME need to check if any animObj is part of Branch, remove from animated obj list then
1.63 -
1.64 - // missing!!!!
1.65 -
1.66 + QModelIndex ix=selection.getBranchIndex();
1.67 + if (ix.isValid())
1.68 + {
1.69 + cout << "VM::deleteSelection\n";
1.70 + }
1.71
1.72 BranchObj* par=(BranchObj*)bo->getParObj();
1.73 selection.unselect();
1.74 @@ -4131,7 +4139,7 @@
1.75 bo->reposition();
1.76 i++;
1.77 }
1.78 - mapEditor->updateSelection();
1.79 + emit (selectionChanged(selModel->selection(), selModel->selection()) );
1.80 mapScene->update();
1.81 if (!animObjList.isEmpty()) animationTimer->start();
1.82 }
1.83 @@ -4305,12 +4313,12 @@
1.84 {
1.85 if ( !col.isValid() ) return;
1.86 saveState (
1.87 - QString("setSelectionColor (%1)").arg(selection.getColor().name()),
1.88 + QString("setSelectionColor (%1)").arg(mapEditor->getSelectionColor().name()),
1.89 QString("setSelectionColor (%1)").arg(col.name()),
1.90 QString("Set color of selection box to %1").arg(col.name())
1.91 );
1.92
1.93 - selection.setColor (col);
1.94 + mapEditor->setSelectionColor (col);
1.95 }
1.96
1.97 void VymModel::updateSelection()
1.98 @@ -4322,7 +4330,7 @@
1.99 {
1.100 if ( !col.isValid() ) return;
1.101 saveState (
1.102 - QString("setSelectionColor (%1)").arg(selection.getColor().name()),
1.103 + QString("setSelectionColor (%1)").arg(mapEditor->getSelectionColor().name()),
1.104 QString("setSelectionColor (%1)").arg(col.name()),
1.105 QString("Set color of selection box to %1").arg(col.name())
1.106 );
1.107 @@ -4331,7 +4339,7 @@
1.108
1.109 QColor VymModel::getSelectionColor()
1.110 {
1.111 - return selection.getColor();
1.112 + return mapEditor->getSelectionColor();
1.113 }
1.114
1.115 void VymModel::setHideTmpMode (HideTmpMode mode)
1.116 @@ -4359,6 +4367,12 @@
1.117 void VymModel::setSelectionModel (QItemSelectionModel *sm)
1.118 {
1.119 selModel=sm;
1.120 + cout << "VM::setSelModel selModel="<<selModel<<endl;
1.121 +}
1.122 +
1.123 +QItemSelectionModel* VymModel::getSelectionModel()
1.124 +{
1.125 + return selModel;
1.126 }
1.127
1.128 void VymModel::setSelectionBlocked (bool b)