treeeditor.cpp
author insilmaril
Fri, 02 Oct 2009 14:31:03 +0000
changeset 803 338ebdc9b947
parent 802 f076fdec767d
child 804 14f2b1b15242
permissions -rw-r--r--
Re-added support for Bugzilla URL and fixed missing autocolor of new branch
     1 #include "treeeditor.h"
     2 
     3 #include <QAction>
     4 #include <QRegExp>
     5 
     6 #include <iostream>
     7 using namespace std;
     8 
     9 #include "vymmodel.h"
    10 
    11 #include "mysortfilterproxymodel.h"
    12 
    13 ///////////////////////////////////////////////////////////////////////
    14 ///////////////////////////////////////////////////////////////////////
    15 TreeEditor::TreeEditor(VymModel *m)
    16 {
    17 	model=m;
    18 
    19 //	MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this);	// FIXME-1 trying to use proxy...
    20 	proxyModel = new QSortFilterProxyModel (this);
    21 
    22 	setModel(proxyModel);
    23 	proxyModel->setSourceModel(model);
    24 
    25 	QAction *a;
    26 	// Shortcuts for navigating with cursor:
    27     a = new QAction(tr( "Select upper object","Tree Editor" ), this);
    28 	a->setStatusTip ( tr( "Select upper object" ));
    29 	a->setShortcut (Qt::Key_Up );
    30 	a->setShortcutContext (Qt::WidgetShortcut);
    31 	addAction (a);
    32     connect( a, SIGNAL( triggered() ), this, SLOT( cursorUp() ) );
    33 
    34     a = new QAction( tr( "Select lower object","Tree Editor" ),this);
    35 	a->setStatusTip (tr( "Select lower object" ));
    36 	a->setShortcut ( Qt::Key_Down );
    37 	a->setShortcutContext (Qt::WidgetShortcut);
    38 	addAction (a);
    39     connect( a, SIGNAL( triggered() ), this, SLOT( cursorDown() ) );
    40 }
    41 
    42 TreeEditor::~TreeEditor()
    43 {
    44 	//cout <<"Destructor TreeEditor for "<<model->getMapName().toStdString()<<endl;
    45 }
    46 
    47 QSortFilterProxyModel* TreeEditor::getProxyModel()
    48 {
    49 	return proxyModel;
    50 }
    51 
    52 void TreeEditor::setSortFilter(QString s)
    53 {
    54 	cout << "TE::setting sortFilter to "<<s.toStdString()<<endl;
    55 	proxyModel->setFilterRegExp(QRegExp(s, Qt::CaseInsensitive));
    56 	proxyModel->setFilterKeyColumn(0);
    57 	proxyModel->setDynamicSortFilter (true);
    58 }
    59 
    60 void TreeEditor::cursorUp()
    61 {
    62 	model->select (indexAbove (model->getSelectedIndex() ));
    63 }
    64 
    65 void TreeEditor::cursorDown()
    66 {
    67 	model->select (indexBelow (model->getSelectedIndex() ));
    68 }
    69