More fixes for selections
authorinsilmaril
Mon Dec 08 16:57:33 2008 +0000 (2008-12-08)
changeset 7297ddbe3fa34a1
parent 728 a8a98a94899a
child 730 0594d7b7099d
More fixes for selections
mapcenterobj.cpp
mapeditor.cpp
mapeditor.h
selection.cpp
selection.h
settings.cpp
tex/vym.changelog
texteditor.cpp
treemodel.h
version.cpp
version.h
vymmodel.cpp
vymview.cpp
     1.1 --- a/mapcenterobj.cpp	Tue Nov 04 12:09:10 2008 +0000
     1.2 +++ b/mapcenterobj.cpp	Mon Dec 08 16:57:33 2008 +0000
     1.3 @@ -174,7 +174,10 @@
     1.4  	// Save frame
     1.5  	s+=frame->saveToDir ();
     1.6  
     1.7 -	// add link to file in s
     1.8 +	// Update of note is usually done while unselecting a branch
     1.9 +	if (isNoteInEditor) getNoteFromTextEditor();
    1.10 +
    1.11 +	// save note
    1.12  	if (!note.isEmpty() )
    1.13  		s+=note.saveToDir();
    1.14  	
     2.1 --- a/mapeditor.cpp	Tue Nov 04 12:09:10 2008 +0000
     2.2 +++ b/mapeditor.cpp	Mon Dec 08 16:57:33 2008 +0000
     2.3 @@ -538,8 +538,34 @@
     2.4  
     2.5      if (lmo) 
     2.6  	{	
     2.7 +		cout << "ME::mouse pressed\n";
     2.8 +		cout << "  lmo="<<lmo<<endl;
     2.9 +		cout << "  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
    2.10  		// Select the clicked object
    2.11 -		model->selectInt (lmo);
    2.12 +		// FIXME VM use index & signal below instead of lmo   
    2.13 +		// model->selectInt (lmo);
    2.14 +
    2.15 +		// FIXME VM better let "find" return an index instead of lmo...
    2.16 +		// Get index of clicked LMO
    2.17 +		TreeItem *ti=lmo->getTreeItem();
    2.18 +		cout << "  lmo="<<lmo<<"    lmo(ti)="<<ti->getLMO()<<endl;
    2.19 +		cout << "  ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl;
    2.20 +		//QModelIndex ix=model->index( ti->row(), ti->column(), model->index (0,0,QModelIndex()) );
    2.21 +		QModelIndex ix=model->index(ti);
    2.22 +		selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
    2.23 +		/*
    2.24 +		if (selModel->hasSelection() ) 
    2.25 +		{
    2.26 +			QModelIndex ixsel=selModel->selectedIndexes().first();
    2.27 +			TreeItem *tisel= static_cast<TreeItem*>(ixsel.internalPointer());
    2.28 +	;
    2.29 +			cout << "  ti="<<ti<<"  tisel="<<tisel<<endl;
    2.30 +			if (ti!=tisel) int i=1/0;
    2.31 +		}
    2.32 +		else
    2.33 +			cout <<"MapEditor::mousePressed  No selection!!!\n";
    2.34 +		*/
    2.35 +
    2.36  
    2.37  		// Left Button	    Move Branches
    2.38  		if (e->button() == Qt::LeftButton )
    2.39 @@ -1044,6 +1070,7 @@
    2.40  
    2.41  	QGraphicsRectItem *sb;
    2.42  
    2.43 +/*
    2.44  	// Check if selection is empty
    2.45  	if (newsel.indexes().isEmpty() )
    2.46  	{
    2.47 @@ -1055,6 +1082,7 @@
    2.48  
    2.49  	if (selboxList.isEmpty())
    2.50  	{
    2.51 +
    2.52  		sb = mapScene->addRect(
    2.53  			QRectF(0,0,0,0), 
    2.54  			QPen(selectionColor),
    2.55 @@ -1064,12 +1092,21 @@
    2.56  		selboxList.append (sb);
    2.57  	} else
    2.58  		sb=selboxList.first();
    2.59 -		
    2.60 +*/		
    2.61 +	if (newsel.isEmpty() )
    2.62 +	{
    2.63 +		cout << "   newsel=empty!\n";
    2.64 +		return;
    2.65 +	}	
    2.66  	QModelIndex index=newsel.indexes().first();	// TODO no multiselections yet
    2.67  
    2.68 -	TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
    2.69 -	LinkableMapObj *lmo=item->getLMO();
    2.70 +	TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
    2.71 +	LinkableMapObj *lmo=ti->getLMO();
    2.72 +	cout << "   newsel.count="<<newsel.indexes().count()<<"  lmo="<<lmo<<endl;
    2.73 +	cout << "   h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
    2.74 +	cout << "   ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl;
    2.75  
    2.76 +/*
    2.77  	int w=0;	// FIXME what for?
    2.78  	if (lmo)
    2.79  	{
    2.80 @@ -1080,8 +1117,20 @@
    2.81  		selboxList.first()->setPen (selectionColor);	
    2.82  		selboxList.first()->setBrush (selectionColor);	
    2.83  	}
    2.84 -	
    2.85 +*/	
    2.86 +}
    2.87  
    2.88 +void MapEditor::updateCurrent (const QModelIndex &newsel,const QModelIndex &)
    2.89 +{
    2.90 +	cout << "ME::updateCurrent\n";
    2.91 +
    2.92 +/*
    2.93 +
    2.94 +	TreeItem *item = static_cast<TreeItem*>(newsel.internalPointer());
    2.95 +	LinkableMapObj *lmo=item->getLMO();
    2.96 +	cout << "  lmo="<<lmo<<endl;
    2.97 +	cout << "  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
    2.98 +	*/
    2.99  
   2.100  }
   2.101  
     3.1 --- a/mapeditor.h	Tue Nov 04 12:09:10 2008 +0000
     3.2 +++ b/mapeditor.h	Mon Dec 08 16:57:33 2008 +0000
     3.3 @@ -93,7 +93,7 @@
     3.4  
     3.5  //////////// Selection related
     3.6  signals:
     3.7 -	void selectionChanged();			// Emitted when selection or its represantion changes
     3.8 +	void selectionChanged(const QItemSelection &, const QItemSelection &);
     3.9  
    3.10  private:	
    3.11      QItemSelectionModel* selModel;	// we treat MapEditor as View here...
    3.12 @@ -102,6 +102,7 @@
    3.13  
    3.14  public slots:
    3.15  	void updateSelection(const QItemSelection &,const QItemSelection &); // update selection
    3.16 +	void updateCurrent (const QModelIndex&,const QModelIndex&); // update selection
    3.17  public:
    3.18  	void updateSelectionGeometry();	// update geometry of selection
    3.19  	void setSelectionColor (QColor c);
     4.1 --- a/selection.cpp	Tue Nov 04 12:09:10 2008 +0000
     4.2 +++ b/selection.cpp	Mon Dec 08 16:57:33 2008 +0000
     4.3 @@ -36,23 +36,23 @@
     4.4  	lastSelectList.clear();
     4.5  }
     4.6  
     4.7 -void Selection::update() // TODO this needs to be adapted to several views
     4.8 +
     4.9 +void Selection::update() // FIXME VM emit signal in VM instead
    4.10  {
    4.11 +/*
    4.12  	QRectF bbox;
    4.13  	//int w=0;
    4.14  	for (int i=0; i< selectList.count(); ++i) 
    4.15  	{
    4.16  		bbox=selectList.at(i)->getBBox();
    4.17 -		/* FIXME VM move to MapEditor
    4.18  		selboxList.at(i)->setRect (
    4.19  			bbox.x()-w,bbox.y()-w, 
    4.20  			bbox.width()+2*w, bbox.height()+2*w);
    4.21  		selboxList.at(i)->setPen (color);	
    4.22  		selboxList.at(i)->setBrush (color);	
    4.23 -		*/
    4.24  	}	
    4.25 +*/
    4.26  }
    4.27 -
    4.28  bool Selection::select(LinkableMapObj *lmo)	// TODO no multiselections yet
    4.29  {
    4.30  	if (!selectList.isEmpty()) unselect();
    4.31 @@ -203,7 +203,8 @@
    4.32  		return NULL;
    4.33  }
    4.34  
    4.35 -QString Selection::getSelectString()// TODO no multiselections yet
    4.36 +QString Selection::getSelectString() // FIXME VM this is also in VM ?! clean up here...
    4.37 +// TODO no multiselections yet
    4.38  {
    4.39  	if (selectList.count()==1)
    4.40  	{
     5.1 --- a/selection.h	Tue Nov 04 12:09:10 2008 +0000
     5.2 +++ b/selection.h	Mon Dec 08 16:57:33 2008 +0000
     5.3 @@ -24,7 +24,7 @@
     5.4  	void copy(const Selection&);
     5.5  	void clear();
     5.6  	void setModel (VymModel *);
     5.7 -	void update();
     5.8 +	void update();      
     5.9  	bool select (LinkableMapObj*);
    5.10  	bool select (const QString &);
    5.11  	bool reselect ();
     6.1 --- a/settings.cpp	Tue Nov 04 12:09:10 2008 +0000
     6.2 +++ b/settings.cpp	Mon Dec 08 16:57:33 2008 +0000
     6.3 @@ -3,8 +3,6 @@
     6.4  #include "settings.h"
     6.5  #include "file.h"
     6.6  
     6.7 -using namespace std;
     6.8 -
     6.9  /////////////////////////////////////////////////////////////////
    6.10  // SimpleSettings
    6.11  /////////////////////////////////////////////////////////////////
     7.1 --- a/tex/vym.changelog	Tue Nov 04 12:09:10 2008 +0000
     7.2 +++ b/tex/vym.changelog	Mon Dec 08 16:57:33 2008 +0000
     7.3 @@ -1,3 +1,8 @@
     7.4 +-------------------------------------------------------------------
     7.5 +Mon Dec  1 17:43:30 CET 2008 - uwedr@suse.de
     7.6 +
     7.7 +- Bugfix: After inserting XML, still write as zipped vym again 
     7.8 +
     7.9  -------------------------------------------------------------------
    7.10  Mon Oct  6 11:16:48 CEST 2008 - uwedr@suse.de
    7.11  
     8.1 --- a/texteditor.cpp	Tue Nov 04 12:09:10 2008 +0000
     8.2 +++ b/texteditor.cpp	Mon Dec 08 16:57:33 2008 +0000
     8.3 @@ -157,6 +157,7 @@
     8.4  void TextEditor::setFilename(const QString &fn)
     8.5  {
     8.6  	if (state==filledEditor)
     8.7 +	{
     8.8  		if (fn.isEmpty() )
     8.9  		{
    8.10  			filename="";
    8.11 @@ -167,6 +168,7 @@
    8.12  			filename=fn;
    8.13  			statusBar()->message( tr(QString( "Current filename is %1" ).arg( filename ),"Statusbar message"), statusbarTime );
    8.14  		}	
    8.15 +	}
    8.16  }
    8.17  
    8.18  QString TextEditor::getFilename()
     9.1 --- a/treemodel.h	Tue Nov 04 12:09:10 2008 +0000
     9.2 +++ b/treemodel.h	Mon Dec 08 16:57:33 2008 +0000
     9.3 @@ -33,9 +33,9 @@
     9.4  	bool removeRows ( int row, int count, 
     9.5  				const QModelIndex & parent = QModelIndex() ); 
     9.6  
     9.7 -protected:
     9.8  	QModelIndex index (TreeItem* ti);
     9.9  
    9.10 +protected:
    9.11      TreeItem *rootItem;
    9.12  	static TreeItem* itFirst;
    9.13  	static TreeItem* itCur;
    10.1 --- a/version.cpp	Tue Nov 04 12:09:10 2008 +0000
    10.2 +++ b/version.cpp	Mon Dec 08 16:57:33 2008 +0000
    10.3 @@ -1,71 +1,56 @@
    10.4  #include "version.h"
    10.5  
    10.6 +#include <QRegExp>
    10.7 +
    10.8  bool checkVersion (const QString &v)
    10.9  {
   10.10  	// returns true, if vym is able to read file regarding 
   10.11  	// the version set with setVersion
   10.12  	return checkVersion (v,__VYM_VERSION);
   10.13 -	/*
   10.14 -	QString s1=v.section (".",0,0);
   10.15 -	QString s2=v.section (".",1,1);
   10.16 -	QString s3=v.section (".",2,2);
   10.17 -	bool ok;
   10.18 -	int vv1 =QString(__VYM_VERSION).section (".",0,0).toInt(&ok,10);
   10.19 -	int vv2 =QString(__VYM_VERSION).section (".",1,1).toInt(&ok,10);
   10.20 -	int vv3 =QString(__VYM_VERSION).section (".",2,2).toInt(&ok,10);
   10.21 -	int mv1=0;
   10.22 -	int mv2=0;
   10.23 -	int mv3=0;
   10.24 -	if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10);
   10.25 -	if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10);
   10.26 -	if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10);
   10.27 -	
   10.28 -	if (vv1 > mv1)
   10.29 -		return true;
   10.30 -	if (vv1 < mv1)
   10.31 -		return false;
   10.32 -	if (vv2 > mv2)
   10.33 -		return true;
   10.34 -	if (vv2 < mv2)
   10.35 -		return false;
   10.36 -	if (vv3 > mv3)
   10.37 -		return true;
   10.38 -	if (vv3 < mv3)
   10.39 -		return false;
   10.40 -	return true;	
   10.41 -*/
   10.42  }
   10.43  
   10.44 +
   10.45  bool checkVersion (const QString &v, const QString &d)
   10.46  {
   10.47 -	QString v1=v.section (".",0,0);
   10.48 -	QString v2=v.section (".",1,1);
   10.49 -	QString v3=v.section (".",2,2);
   10.50 -	QString d1=d.section (".",0,0);
   10.51 -	QString d2=d.section (".",1,1);
   10.52 -	QString d3=d.section (".",2,2);
   10.53  	bool ok;
   10.54 -	int d1i=d1.toInt(&ok,10);
   10.55 -	int d2i=d2.toInt(&ok,10);
   10.56 -	int d3i=d3.toInt(&ok,10);
   10.57 -	int v1i=0;
   10.58 -	int v2i=0;
   10.59 -	int v3i=0;
   10.60 -	if (!v1.isEmpty() ) v1i=v1.toInt(&ok,10);
   10.61 -	if (!v2.isEmpty() ) v2i=v2.toInt(&ok,10);
   10.62 -	if (!v3.isEmpty() ) v3i=v3.toInt(&ok,10);
   10.63 +	int v1;
   10.64 +	int v2;
   10.65 +	int v3;
   10.66 +	int d1;
   10.67 +	int d2;
   10.68 +	int d3;
   10.69 +
   10.70 +	QRegExp rx("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})");
   10.71 +	int pos=rx.indexIn (v);
   10.72 +	if (pos>-1)
   10.73 +	{
   10.74 +		v1=rx.cap(1).toInt(&ok);
   10.75 +		v2=rx.cap(2).toInt(&ok);
   10.76 +		v3=rx.cap(3).toInt(&ok);
   10.77 +	} else
   10.78 +		qWarning (QString ("Warning: Checking version failed for v=%1").arg(v));
   10.79 +
   10.80 +	pos=rx.indexIn (d);
   10.81 +	if (pos>-1)
   10.82 +	{
   10.83 +		d1=rx.cap(1).toInt(&ok);
   10.84 +		d2=rx.cap(2).toInt(&ok);
   10.85 +		d3=rx.cap(3).toInt(&ok);
   10.86 +	} else
   10.87 +		qWarning (QString ("Warning: Checking version failed for d=%1").arg(d));
   10.88 +
   10.89  	
   10.90 -	if (d1i > v1i)
   10.91 +	if (d1 > v1)
   10.92  		return true;
   10.93 -	if (d1i < v1i)
   10.94 +	if (d1 < v1)
   10.95  		return false;
   10.96 -	if (d2i > v2i)
   10.97 +	if (d2 > v2)
   10.98  		return true;
   10.99 -	if (d2i < v2i)
  10.100 +	if (d2 < v2)
  10.101  		return false;
  10.102 -	if (d3i > v3i)
  10.103 +	if (d3 > v3)
  10.104  		return true;
  10.105 -	if (d3i < v3i)
  10.106 +	if (d3 < v3)
  10.107  		return false;
  10.108  	return true;	
  10.109  
    11.1 --- a/version.h	Tue Nov 04 12:09:10 2008 +0000
    11.2 +++ b/version.h	Mon Dec 08 16:57:33 2008 +0000
    11.3 @@ -7,7 +7,7 @@
    11.4  #define __VYM_VERSION "1.13.0"
    11.5  //#define __VYM_CODENAME "Codename: RC-1"
    11.6  #define __VYM_CODENAME "Codename: development version"
    11.7 -#define __VYM_BUILD_DATE "2008-11-04"
    11.8 +#define __VYM_BUILD_DATE "2008-12-01"
    11.9  
   11.10  
   11.11  bool checkVersion(const QString &);
    12.1 --- a/vymmodel.cpp	Tue Nov 04 12:09:10 2008 +0000
    12.2 +++ b/vymmodel.cpp	Mon Dec 08 16:57:33 2008 +0000
    12.3 @@ -338,6 +338,9 @@
    12.4  				   "Unknown FileType in VymModel::load()");
    12.5  		return aborted;	
    12.6  	}
    12.7 +
    12.8 +	bool zipped_org=zipped;
    12.9 +
   12.10  	if (lmode==NewMap)
   12.11  	{
   12.12  		selection.clear();
   12.13 @@ -480,6 +483,9 @@
   12.14  	// Delete tmpZipDir
   12.15  	removeDir (QDir(tmpZipDir));
   12.16  
   12.17 +	// Restore original zip state
   12.18 +	zipped=zipped_org;
   12.19 +
   12.20  	updateActions();
   12.21  	return err;
   12.22  }
   12.23 @@ -4442,8 +4448,8 @@
   12.24  {
   12.25  	if (selection.select(lmo))
   12.26  	{
   12.27 -		selection.update();
   12.28 -		sendSelection ();
   12.29 +		//selection.update();
   12.30 +		sendSelection ();	// FIXME VM use signal
   12.31  	}
   12.32  }
   12.33  
   12.34 @@ -4838,7 +4844,7 @@
   12.35  	return selection.getSelectString();
   12.36  }
   12.37  
   12.38 -QString VymModel::getSelectString (LinkableMapObj *lmo)
   12.39 +QString VymModel::getSelectString (LinkableMapObj *lmo)	// FIXME VM needs to use TreeModel
   12.40  {
   12.41  	QString s;
   12.42  	if (!lmo) return s;
   12.43 @@ -4852,8 +4858,11 @@
   12.44  				// Mainbranch, return 
   12.45  				s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
   12.46  			else	
   12.47 +			{
   12.48 +				//cout << "VM::getSelectString  lmo="<<lmo<<"  d="<<lmo->getDepth()<<"  s="<<s.toStdString()<<"  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
   12.49  				// Branch, call myself recursively
   12.50  				s= getSelectString(par) + ",bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
   12.51 +			}
   12.52  		} else
   12.53  		{
   12.54  			// MapCenter
    13.1 --- a/vymview.cpp	Tue Nov 04 12:09:10 2008 +0000
    13.2 +++ b/vymview.cpp	Mon Dec 08 16:57:33 2008 +0000
    13.3 @@ -24,12 +24,16 @@
    13.4  	connect (
    13.5  		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    13.6  		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    13.7 +	connect (
    13.8 +		selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)), 
    13.9 +		me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
   13.10  
   13.11  	// VymModel may want to update selection, e.g. during animation
   13.12 +	/*
   13.13  	connect (
   13.14  		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
   13.15  		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
   13.16 -
   13.17 +	*/
   13.18  
   13.19  	//me->viewport()->setFocus();
   13.20  	//FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());