treeeditor.cpp
author insilmaril
Tue, 08 Sep 2009 12:15:39 +0000
changeset 792 7d67be709091
parent 791 f1006de05c54
child 800 959bd133cd1a
permissions -rw-r--r--
First results in moving colliding MapCenters apart
     1 #include "treeeditor.h"
     2 
     3 #include <QAction>
     4 #include <QSortFilterProxyModel>
     5 #include <QRegExp>
     6 
     7 #include <iostream>
     8 using namespace std;
     9 
    10 #include "vymmodel.h"
    11 
    12 #include "mysortfilterproxymodel.h"
    13 
    14 ///////////////////////////////////////////////////////////////////////
    15 ///////////////////////////////////////////////////////////////////////
    16 TreeEditor::TreeEditor(VymModel *m)
    17 {
    18 	model=m;
    19 
    20 /*
    21 //	MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this);	// FIXME-1 trying to use proxy...
    22 	QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel (this);
    23 
    24 	proxyModel->setSourceModel(model);
    25 
    26 	proxyModel->setFilterRegExp(QRegExp("x", Qt::CaseInsensitive));
    27 	proxyModel->setFilterKeyColumn(0);
    28 	proxyModel->setDynamicSortFilter (true);
    29 //	setModel(proxyModel);
    30 */
    31 	setModel(model);
    32 
    33 	QAction *a;
    34 	// Shortcuts for navigating with cursor:
    35     a = new QAction(tr( "Select upper object","Tree Editor" ), this);
    36 	a->setStatusTip ( tr( "Select upper object" ));
    37 	a->setShortcut (Qt::Key_Up );
    38 	a->setShortcutContext (Qt::WidgetShortcut);
    39 	addAction (a);
    40     connect( a, SIGNAL( triggered() ), this, SLOT( cursorUp() ) );
    41 
    42     a = new QAction( tr( "Select lower object","Tree Editor" ),this);
    43 	a->setStatusTip (tr( "Select lower object" ));
    44 	a->setShortcut ( Qt::Key_Down );
    45 	a->setShortcutContext (Qt::WidgetShortcut);
    46 	addAction (a);
    47     connect( a, SIGNAL( triggered() ), this, SLOT( cursorDown() ) );
    48 }
    49 
    50 TreeEditor::~TreeEditor()
    51 {
    52 	//cout <<"Destructor TreeEditor for "<<model->getMapName().toStdString()<<endl;
    53 }
    54 
    55 void TreeEditor::cursorUp()
    56 {
    57 	model->select (indexAbove (model->getSelectedIndex() ));
    58 }
    59 
    60 void TreeEditor::cursorDown()
    61 {
    62 	model->select (indexBelow (model->getSelectedIndex() ));
    63 }
    64