1.1 --- a/vymmodel.cpp Fri Mar 06 15:02:58 2009 +0000
1.2 +++ b/vymmodel.cpp Thu Mar 19 11:45:28 2009 +0000
1.3 @@ -66,7 +66,6 @@
1.4
1.5 void VymModel::clear()
1.6 {
1.7 - cout << "VymModel::clear rows="<<rowCount(index(rootItem))<<endl;
1.8 selModel->clearSelection();
1.9
1.10 // Remove stuff
1.11 @@ -147,8 +146,6 @@
1.12
1.13 hidemode=HideNone;
1.14
1.15 -
1.16 -
1.17 // Network
1.18 netstate=Offline;
1.19
1.20 @@ -179,6 +176,7 @@
1.21
1.22 void VymModel::updateActions() // FIXME maybe don't update if blockReposition is set
1.23 {
1.24 + cout << "VymModel::updateActions \n";
1.25 // Tell mainwindow to update states of actions
1.26 mainWindow->updateActions();
1.27 }
1.28 @@ -224,6 +222,7 @@
1.29 mapAttr+= xml.attribut("author",author) +
1.30 xml.attribut("comment",comment) +
1.31 xml.attribut("date",getDate()) +
1.32 + xml.attribut("countBranches", QString().number(countBranches())) +
1.33 xml.attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
1.34 xml.attribut("selectionColor", mapEditor->getSelectionColor().name() ) +
1.35 xml.attribut("linkStyle", ls ) +
1.36 @@ -889,6 +888,12 @@
1.37
1.38 void VymModel::autosave()
1.39 {
1.40 + if (filePath=="")
1.41 + {
1.42 + if (debug)
1.43 + cout << "VymModel::autosave rejected due to missing filePath\n";
1.44 + }
1.45 +
1.46 QDateTime now=QDateTime().currentDateTime();
1.47
1.48 // Disable autosave, while we have gone back in history
1.49 @@ -899,7 +904,7 @@
1.50 if (filePath.isEmpty()) return;
1.51
1.52
1.53 - if (mapUnsaved &&mapChanged && settings.value ("/autosave/use",true).toBool() )
1.54 + if (mapUnsaved &&mapChanged && settings.value ("/mainwindow/autosave/use",true).toBool() )
1.55 {
1.56 if (QFileInfo(filePath).lastModified()<=fileChangedTime)
1.57 mainWindow->fileSave (this);
1.58 @@ -959,8 +964,12 @@
1.59
1.60 void VymModel::setChanged()
1.61 {
1.62 + cout << "VM::setChanged()\n";
1.63 if (!mapChanged)
1.64 - autosaveTimer->start(settings.value("/autosave/ms/",300000).toInt());
1.65 + {
1.66 + autosaveTimer->start(settings.value("/mainwindow/autosave/ms/",300000).toInt());
1.67 + cout <<" timer started with "<<settings.value("/mainwindow/autosave/ms/",300000).toInt()<<endl;
1.68 + }
1.69 mapChanged=true;
1.70 mapDefault=false;
1.71 mapUnsaved=true;
1.72 @@ -1454,6 +1463,22 @@
1.73 return QDate::currentDate().toString ("yyyy-MM-dd");
1.74 }
1.75
1.76 +int VymModel::countBranches() // FIXME Optimize this: use internal counter instead of going through whole map each time...
1.77 +{
1.78 + int c=0;
1.79 + TreeItem *cur=NULL;
1.80 + TreeItem *prev=NULL;
1.81 + int d;
1.82 + next(cur,prev,d);
1.83 + while (cur)
1.84 + {
1.85 + c++;
1.86 + next(cur,prev,d);
1.87 + }
1.88 + return c;
1.89 +
1.90 +}
1.91 +
1.92 void VymModel::setHeading(const QString &s)
1.93 {
1.94 BranchObj *sel=getSelectedBranch();
1.95 @@ -4341,19 +4366,9 @@
1.96 updateSelection (newsel);
1.97 }
1.98
1.99 -void VymModel::updateSelection(const QItemSelection &)
1.100 +void VymModel::updateSelection(const QItemSelection &newsel)
1.101 {
1.102 - QItemSelection newsel=selModel->selection();
1.103 - /*
1.104 - cout << "VM::updateSelection new=";
1.105 - if (!newsel.indexes().isEmpty() )
1.106 - cout << newsel.indexes().first().row()<<"," << newsel.indexes().first().column();
1.107 - cout << " old=";
1.108 - if (!oldsel.indexes().isEmpty() )
1.109 - cout << oldsel.indexes().first().row()<<"," << oldsel.indexes().first().column();
1.110 - cout <<endl;
1.111 - */
1.112 - //emit (selectionChanged(newsel,oldsel)); // FIXME needed?
1.113 + emit (selectionChanged(newsel,newsel)); // needed e.g. to update geometry in editor
1.114 ensureSelectionVisible();
1.115 sendSelection();
1.116 }
1.117 @@ -4596,9 +4611,6 @@
1.118 num=QString ("%1").arg(n);
1.119 s=s+num;
1.120
1.121 - cout <<"SP:: s0="<<s.toStdString()<<endl;
1.122 -
1.123 -
1.124 // Try to select this one
1.125 if (n>=0 && select (s)) return;
1.126
1.127 @@ -4634,7 +4646,6 @@
1.128 s=typ+num;
1.129 }
1.130
1.131 - cout <<"SP:: si="<<s.toStdString()<<endl;
1.132 if (select(s))
1.133 // pad to oldDepth, select the last branch for each depth
1.134 for (i=d;i<oldDepth;i++)