treeeditor.cpp
changeset 769 a6931cd6309a
child 788 78ba80b54bc4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/treeeditor.cpp	Fri May 15 15:22:15 2009 +0000
     1.3 @@ -0,0 +1,52 @@
     1.4 +#include "treeeditor.h"
     1.5 +
     1.6 +#include <QAction>
     1.7 +#include <iostream>
     1.8 +using namespace std;
     1.9 +
    1.10 +#include "vymmodel.h"
    1.11 +
    1.12 +///////////////////////////////////////////////////////////////////////
    1.13 +///////////////////////////////////////////////////////////////////////
    1.14 +TreeEditor::TreeEditor(VymModel *m)
    1.15 +{
    1.16 +	//cout << "Constructor TreeEditor "<<this<<endl;
    1.17 +	
    1.18 +	model=m;
    1.19 +
    1.20 +	QAction *a;
    1.21 +	// Shortcuts for navigating with cursor:
    1.22 +    a = new QAction(tr( "Select upper object","Tree Editor" ), this);
    1.23 +	a->setStatusTip ( tr( "Select upper object" ));
    1.24 +	a->setShortcut (Qt::Key_Up );
    1.25 +//	a->setShortcutContext (Qt::WindowShortcut);
    1.26 +	a->setShortcutContext (Qt::WidgetShortcut);
    1.27 +//	a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
    1.28 +	addAction (a);
    1.29 +    connect( a, SIGNAL( triggered() ), this, SLOT( cursorUp() ) );
    1.30 +
    1.31 +    a = new QAction( tr( "Select lower object","Tree Editor" ),this);
    1.32 +	a->setStatusTip (tr( "Select lower object" ));
    1.33 +	a->setShortcut ( Qt::Key_Down );
    1.34 +//	a->setShortcutContext (Qt::WindowShortcut);
    1.35 +//	a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
    1.36 +	a->setShortcutContext (Qt::WidgetShortcut);
    1.37 +	addAction (a);
    1.38 +    connect( a, SIGNAL( triggered() ), this, SLOT( cursorDown() ) );
    1.39 +}
    1.40 +
    1.41 +TreeEditor::~TreeEditor()
    1.42 +{
    1.43 +	//cout <<"Destructor TreeEditor for "<<model->getMapName().toStdString()<<endl;
    1.44 +}
    1.45 +
    1.46 +void TreeEditor::cursorUp()
    1.47 +{
    1.48 +	model->select (indexAbove (model->getSelectedIndex() ));
    1.49 +}
    1.50 +
    1.51 +void TreeEditor::cursorDown()
    1.52 +{
    1.53 +	model->select (indexBelow (model->getSelectedIndex() ));
    1.54 +}
    1.55 +