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