# 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="<<lmo<<endl; + cout << " h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl; // Select the clicked object - model->selectInt (lmo); + // FIXME VM use index & signal below instead of lmo + // model->selectInt (lmo); + + // FIXME VM better let "find" return an index instead of lmo... + // Get index of clicked LMO + TreeItem *ti=lmo->getTreeItem(); + cout << " lmo="<<lmo<<" lmo(ti)="<<ti->getLMO()<<endl; + cout << " ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl; + //QModelIndex ix=model->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<TreeItem*>(ixsel.internalPointer()); + ; + cout << " ti="<<ti<<" tisel="<<tisel<<endl; + if (ti!=tisel) int i=1/0; + } + else + cout <<"MapEditor::mousePressed No selection!!!\n"; + */ + // Left Button Move Branches if (e->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<TreeItem*>(index.internalPointer()); - LinkableMapObj *lmo=item->getLMO(); + TreeItem *ti= static_cast<TreeItem*>(index.internalPointer()); + LinkableMapObj *lmo=ti->getLMO(); + cout << " newsel.count="<<newsel.indexes().count()<<" lmo="<<lmo<<endl; + cout << " h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl; + cout << " ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl; +/* int w=0; // FIXME what for? if (lmo) { @@ -1080,8 +1117,20 @@ selboxList.first()->setPen (selectionColor); selboxList.first()->setBrush (selectionColor); } - +*/ +} +void MapEditor::updateCurrent (const QModelIndex &newsel,const QModelIndex &) +{ + cout << "ME::updateCurrent\n"; + +/* + + TreeItem *item = static_cast<TreeItem*>(newsel.internalPointer()); + LinkableMapObj *lmo=item->getLMO(); + cout << " lmo="<<lmo<<endl; + cout << " h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl; + */ } diff -r a8a98a94899a -r 7ddbe3fa34a1 mapeditor.h --- a/mapeditor.h Tue Nov 04 12:09:10 2008 +0000 +++ b/mapeditor.h Mon Dec 08 16:57:33 2008 +0000 @@ -93,7 +93,7 @@ //////////// Selection related signals: - void selectionChanged(); // Emitted when selection or its represantion changes + void selectionChanged(const QItemSelection &, const QItemSelection &); private: QItemSelectionModel* selModel; // we treat MapEditor as View here... @@ -102,6 +102,7 @@ public slots: void updateSelection(const QItemSelection &,const QItemSelection &); // update selection + void updateCurrent (const QModelIndex&,const QModelIndex&); // update selection public: void updateSelectionGeometry(); // update geometry of selection void setSelectionColor (QColor c); diff -r a8a98a94899a -r 7ddbe3fa34a1 selection.cpp --- a/selection.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/selection.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -36,23 +36,23 @@ lastSelectList.clear(); } -void Selection::update() // TODO this needs to be adapted to several views + +void Selection::update() // FIXME VM emit signal in VM instead { +/* QRectF bbox; //int w=0; for (int i=0; i< selectList.count(); ++i) { bbox=selectList.at(i)->getBBox(); - /* FIXME VM move to MapEditor selboxList.at(i)->setRect ( bbox.x()-w,bbox.y()-w, bbox.width()+2*w, bbox.height()+2*w); selboxList.at(i)->setPen (color); selboxList.at(i)->setBrush (color); - */ } +*/ } - bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet { if (!selectList.isEmpty()) unselect(); @@ -203,7 +203,8 @@ return NULL; } -QString Selection::getSelectString()// TODO no multiselections yet +QString Selection::getSelectString() // FIXME VM this is also in VM ?! clean up here... +// TODO no multiselections yet { if (selectList.count()==1) { diff -r a8a98a94899a -r 7ddbe3fa34a1 selection.h --- a/selection.h Tue Nov 04 12:09:10 2008 +0000 +++ b/selection.h Mon Dec 08 16:57:33 2008 +0000 @@ -24,7 +24,7 @@ void copy(const Selection&); void clear(); void setModel (VymModel *); - void update(); + void update(); bool select (LinkableMapObj*); bool select (const QString &); bool reselect (); diff -r a8a98a94899a -r 7ddbe3fa34a1 settings.cpp --- a/settings.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/settings.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -3,8 +3,6 @@ #include "settings.h" #include "file.h" -using namespace std; - ///////////////////////////////////////////////////////////////// // SimpleSettings ///////////////////////////////////////////////////////////////// diff -r a8a98a94899a -r 7ddbe3fa34a1 tex/vym.changelog --- a/tex/vym.changelog Tue Nov 04 12:09:10 2008 +0000 +++ b/tex/vym.changelog Mon Dec 08 16:57:33 2008 +0000 @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Dec 1 17:43:30 CET 2008 - uwedr@suse.de + +- Bugfix: After inserting XML, still write as zipped vym again + ------------------------------------------------------------------- Mon Oct 6 11:16:48 CEST 2008 - uwedr@suse.de diff -r a8a98a94899a -r 7ddbe3fa34a1 texteditor.cpp --- a/texteditor.cpp Tue Nov 04 12:09:10 2008 +0000 +++ b/texteditor.cpp Mon Dec 08 16:57:33 2008 +0000 @@ -157,6 +157,7 @@ void TextEditor::setFilename(const QString &fn) { if (state==filledEditor) + { if (fn.isEmpty() ) { filename=""; @@ -167,6 +168,7 @@ filename=fn; statusBar()->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 <QRegExp> + 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="<<lmo<<" d="<<lmo->getDepth()<<" s="<<s.toStdString()<<" h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl; // Branch, call myself recursively s= getSelectString(par) + ",bo:" + QString("%1").arg(((BranchObj*)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());