# HG changeset patch # User insilmaril # Date 1228755453 0 # Node ID 7ddbe3fa34a10609dadd191e763f158778e91298 # Parent a8a98a94899ac6d7e8d04f4da45bdce3db587b4f More fixes for selections diff -r a8a98a94899a -r 7ddbe3fa34a1 mapcenterobj.cpp --- a/mapcenterobj.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/mapcenterobj.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -174,7 +174,10 @@ // Save frame s+=frame->saveToDir (); - // add link to file in s + // Update of note is usually done while unselecting a branch + if (isNoteInEditor) getNoteFromTextEditor(); + + // save note if (!note.isEmpty() ) s+=note.saveToDir(); diff -r a8a98a94899a -r 7ddbe3fa34a1 mapeditor.cpp --- a/mapeditor.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/mapeditor.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -538,8 +538,34 @@ if (lmo) { + cout << "ME::mouse pressed\n"; + cout << " lmo="<getTreeItem(); + cout << " lmo="<row()<<","<column()<<") = "<index( ti->row(), ti->column(), model->index (0,0,QModelIndex()) ); + QModelIndex ix=model->index(ti); + selModel->select (ix,QItemSelectionModel::ClearAndSelect ); + /* + if (selModel->hasSelection() ) + { + QModelIndex ixsel=selModel->selectedIndexes().first(); + TreeItem *tisel= static_cast(ixsel.internalPointer()); + ; + cout << " ti="<button() == Qt::LeftButton ) @@ -1044,6 +1070,7 @@ QGraphicsRectItem *sb; +/* // Check if selection is empty if (newsel.indexes().isEmpty() ) { @@ -1055,6 +1082,7 @@ if (selboxList.isEmpty()) { + sb = mapScene->addRect( QRectF(0,0,0,0), QPen(selectionColor), @@ -1064,12 +1092,21 @@ selboxList.append (sb); } else sb=selboxList.first(); - +*/ + if (newsel.isEmpty() ) + { + cout << " newsel=empty!\n"; + return; + } QModelIndex index=newsel.indexes().first(); // TODO no multiselections yet - TreeItem *item = static_cast(index.internalPointer()); - LinkableMapObj *lmo=item->getLMO(); + TreeItem *ti= static_cast(index.internalPointer()); + LinkableMapObj *lmo=ti->getLMO(); + cout << " newsel.count="<row()<<","<column()<<") = "<setPen (selectionColor); selboxList.first()->setBrush (selectionColor); } - +*/ +} +void MapEditor::updateCurrent (const QModelIndex &newsel,const QModelIndex &) +{ + cout << "ME::updateCurrent\n"; + +/* + + TreeItem *item = static_cast(newsel.internalPointer()); + LinkableMapObj *lmo=item->getLMO(); + cout << " lmo="<message( tr(QString( "Current filename is %1" ).arg( filename ),"Statusbar message"), statusbarTime ); } + } } QString TextEditor::getFilename() diff -r a8a98a94899a -r 7ddbe3fa34a1 treemodel.h --- a/treemodel.h Tue Nov 04 12:09:10 2008 +0000 +++ b/treemodel.h Mon Dec 08 16:57:33 2008 +0000 @@ -33,9 +33,9 @@ bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() ); -protected: QModelIndex index (TreeItem* ti); +protected: TreeItem *rootItem; static TreeItem* itFirst; static TreeItem* itCur; diff -r a8a98a94899a -r 7ddbe3fa34a1 version.cpp --- a/version.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/version.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -1,71 +1,56 @@ #include "version.h" +#include + bool checkVersion (const QString &v) { // returns true, if vym is able to read file regarding // the version set with setVersion return checkVersion (v,__VYM_VERSION); - /* - QString s1=v.section (".",0,0); - QString s2=v.section (".",1,1); - QString s3=v.section (".",2,2); - bool ok; - int vv1 =QString(__VYM_VERSION).section (".",0,0).toInt(&ok,10); - int vv2 =QString(__VYM_VERSION).section (".",1,1).toInt(&ok,10); - int vv3 =QString(__VYM_VERSION).section (".",2,2).toInt(&ok,10); - int mv1=0; - int mv2=0; - int mv3=0; - if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10); - if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10); - if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10); - - if (vv1 > mv1) - return true; - if (vv1 < mv1) - return false; - if (vv2 > mv2) - return true; - if (vv2 < mv2) - return false; - if (vv3 > mv3) - return true; - if (vv3 < mv3) - return false; - return true; -*/ } + bool checkVersion (const QString &v, const QString &d) { - QString v1=v.section (".",0,0); - QString v2=v.section (".",1,1); - QString v3=v.section (".",2,2); - QString d1=d.section (".",0,0); - QString d2=d.section (".",1,1); - QString d3=d.section (".",2,2); bool ok; - int d1i=d1.toInt(&ok,10); - int d2i=d2.toInt(&ok,10); - int d3i=d3.toInt(&ok,10); - int v1i=0; - int v2i=0; - int v3i=0; - if (!v1.isEmpty() ) v1i=v1.toInt(&ok,10); - if (!v2.isEmpty() ) v2i=v2.toInt(&ok,10); - if (!v3.isEmpty() ) v3i=v3.toInt(&ok,10); + int v1; + int v2; + int v3; + int d1; + int d2; + int d3; + + QRegExp rx("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})"); + int pos=rx.indexIn (v); + if (pos>-1) + { + v1=rx.cap(1).toInt(&ok); + v2=rx.cap(2).toInt(&ok); + v3=rx.cap(3).toInt(&ok); + } else + qWarning (QString ("Warning: Checking version failed for v=%1").arg(v)); + + pos=rx.indexIn (d); + if (pos>-1) + { + d1=rx.cap(1).toInt(&ok); + d2=rx.cap(2).toInt(&ok); + d3=rx.cap(3).toInt(&ok); + } else + qWarning (QString ("Warning: Checking version failed for d=%1").arg(d)); + - if (d1i > v1i) + if (d1 > v1) return true; - if (d1i < v1i) + if (d1 < v1) return false; - if (d2i > v2i) + if (d2 > v2) return true; - if (d2i < v2i) + if (d2 < v2) return false; - if (d3i > v3i) + if (d3 > v3) return true; - if (d3i < v3i) + if (d3 < v3) return false; return true; diff -r a8a98a94899a -r 7ddbe3fa34a1 version.h --- a/version.h Tue Nov 04 12:09:10 2008 +0000 +++ b/version.h Mon Dec 08 16:57:33 2008 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version" -#define __VYM_BUILD_DATE "2008-11-04" +#define __VYM_BUILD_DATE "2008-12-01" bool checkVersion(const QString &); diff -r a8a98a94899a -r 7ddbe3fa34a1 vymmodel.cpp --- a/vymmodel.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/vymmodel.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -338,6 +338,9 @@ "Unknown FileType in VymModel::load()"); return aborted; } + + bool zipped_org=zipped; + if (lmode==NewMap) { selection.clear(); @@ -480,6 +483,9 @@ // Delete tmpZipDir removeDir (QDir(tmpZipDir)); + // Restore original zip state + zipped=zipped_org; + updateActions(); return err; } @@ -4442,8 +4448,8 @@ { if (selection.select(lmo)) { - selection.update(); - sendSelection (); + //selection.update(); + sendSelection (); // FIXME VM use signal } } @@ -4838,7 +4844,7 @@ return selection.getSelectString(); } -QString VymModel::getSelectString (LinkableMapObj *lmo) +QString VymModel::getSelectString (LinkableMapObj *lmo) // FIXME VM needs to use TreeModel { QString s; if (!lmo) return s; @@ -4852,8 +4858,11 @@ // Mainbranch, return s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum()); else + { + //cout << "VM::getSelectString lmo="<getNum()); + } } else { // MapCenter diff -r a8a98a94899a -r 7ddbe3fa34a1 vymview.cpp --- a/vymview.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/vymview.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -24,12 +24,16 @@ connect ( selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); + connect ( + selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)), + me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &))); // VymModel may want to update selection, e.g. during animation + /* connect ( model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); - + */ //me->viewport()->setFocus(); //FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());