treeeditor.cpp
changeset 804 14f2b1b15242
parent 802 f076fdec767d
child 822 c2ce9944148c
     1.1 --- a/treeeditor.cpp	Fri Oct 02 14:31:03 2009 +0000
     1.2 +++ b/treeeditor.cpp	Fri Nov 13 08:32:03 2009 +0000
     1.3 @@ -8,19 +8,17 @@
     1.4  
     1.5  #include "vymmodel.h"
     1.6  
     1.7 -#include "mysortfilterproxymodel.h"
     1.8 -
     1.9  ///////////////////////////////////////////////////////////////////////
    1.10  ///////////////////////////////////////////////////////////////////////
    1.11  TreeEditor::TreeEditor(VymModel *m)
    1.12  {
    1.13  	model=m;
    1.14  
    1.15 -//	MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this);	// FIXME-1 trying to use proxy...
    1.16 -	proxyModel = new QSortFilterProxyModel (this);
    1.17 -
    1.18 -	setModel(proxyModel);
    1.19 -	proxyModel->setSourceModel(model);
    1.20 +	// FIXME-2 use proxmodel
    1.21 +	//proxyModel = new MySortFilterProxyModel(this);	
    1.22 +	//setModel(proxyModel);
    1.23 +	setModel(m);
    1.24 +	//proxyModel->setSourceModel(model);
    1.25  
    1.26  	QAction *a;
    1.27  	// Shortcuts for navigating with cursor:
    1.28 @@ -44,14 +42,23 @@
    1.29  	//cout <<"Destructor TreeEditor for "<<model->getMapName().toStdString()<<endl;
    1.30  }
    1.31  
    1.32 -QSortFilterProxyModel* TreeEditor::getProxyModel()
    1.33 +MySortFilterProxyModel* TreeEditor::getProxyModel()
    1.34  {
    1.35  	return proxyModel;
    1.36  }
    1.37  
    1.38 +QModelIndex TreeEditor::getSelectedIndex()
    1.39 +{
    1.40 +	QModelIndexList list=selectionModel()->selectedIndexes();
    1.41 +	if (list.isEmpty() )
    1.42 +		return QModelIndex();
    1.43 +	else
    1.44 +		return list.first();
    1.45 +}
    1.46 +
    1.47 +
    1.48  void TreeEditor::setSortFilter(QString s)
    1.49  {
    1.50 -	cout << "TE::setting sortFilter to "<<s.toStdString()<<endl;
    1.51  	proxyModel->setFilterRegExp(QRegExp(s, Qt::CaseInsensitive));
    1.52  	proxyModel->setFilterKeyColumn(0);
    1.53  	proxyModel->setDynamicSortFilter (true);
    1.54 @@ -59,11 +66,19 @@
    1.55  
    1.56  void TreeEditor::cursorUp()
    1.57  {
    1.58 -	model->select (indexAbove (model->getSelectedIndex() ));
    1.59 +	QModelIndex ix=getSelectedIndex();
    1.60 +	// FIXME-2 useproxymodel ix=proxyModel->mapToSource (indexAbove(ix));
    1.61 +	ix=indexAbove (ix);
    1.62 +	if (ix.isValid())
    1.63 +		model->select (ix );
    1.64  }
    1.65  
    1.66  void TreeEditor::cursorDown()
    1.67  {
    1.68 -	model->select (indexBelow (model->getSelectedIndex() ));
    1.69 +	QModelIndex ix=getSelectedIndex();
    1.70 +	//FIXME-2 useProxymodel ix=proxyModel->mapToSource (indexBelow(ix));
    1.71 +	ix=indexBelow (ix);
    1.72 +	if (ix.isValid())
    1.73 +		model->select (ix );
    1.74  }
    1.75