vymview.cpp
author insilmaril
Tue, 09 Dec 2008 16:44:54 +0000
changeset 730 0594d7b7099d
parent 729 7ddbe3fa34a1
child 731 c8b1a3564c74
permissions -rw-r--r--
Bugfix for still visible images in scrolled branches
insilmaril@726
     1
#include "vymview.h"
insilmaril@726
     2
insilmaril@727
     3
#include <iostream>
insilmaril@727
     4
insilmaril@726
     5
#include "mapeditor.h"
insilmaril@726
     6
insilmaril@726
     7
VymView::VymView(VymModel *model)
insilmaril@726
     8
{
insilmaril@726
     9
	// Create TreeView
insilmaril@727
    10
	treeview=new QTreeView;
insilmaril@726
    11
	treeview->setModel ((QAbstractItemModel*)model);
insilmaril@726
    12
	treeview->setMinimumWidth (350);
insilmaril@726
    13
	treeview->setColumnWidth (0,350);
insilmaril@726
    14
insilmaril@727
    15
	selModel=treeview->selectionModel();
insilmaril@728
    16
	model->setSelectionModel (selModel);
insilmaril@727
    17
	connect (
insilmaril@727
    18
		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
insilmaril@727
    19
		this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
insilmaril@727
    20
insilmaril@726
    21
	// Create good old MapEditor
insilmaril@726
    22
	MapEditor* me=model->getMapEditor();
insilmaril@726
    23
	if (!me) me=new MapEditor (model);
insilmaril@728
    24
	connect (
insilmaril@728
    25
		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
insilmaril@728
    26
		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
insilmaril@729
    27
	connect (
insilmaril@729
    28
		selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)), 
insilmaril@729
    29
		me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
insilmaril@726
    30
insilmaril@728
    31
	// VymModel may want to update selection, e.g. during animation
insilmaril@729
    32
	/*
insilmaril@728
    33
	connect (
insilmaril@728
    34
		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
insilmaril@728
    35
		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
insilmaril@729
    36
	*/
insilmaril@726
    37
insilmaril@726
    38
	//me->viewport()->setFocus();
insilmaril@726
    39
	//FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());
insilmaril@726
    40
	//FIXME me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
insilmaril@726
    41
insilmaril@726
    42
	addWidget (treeview);
insilmaril@726
    43
	addWidget (me);
insilmaril@726
    44
insilmaril@726
    45
	// Set geometry
insilmaril@726
    46
	QList <int> sizes;
insilmaril@726
    47
	sizes.append (150);
insilmaril@726
    48
	sizes.append (600);
insilmaril@726
    49
	setSizes (sizes);
insilmaril@726
    50
}
insilmaril@726
    51
insilmaril@726
    52
QItemSelectionModel* VymView::selectionModel() 
insilmaril@726
    53
{
insilmaril@728
    54
	if (treeview) 
insilmaril@728
    55
		return selModel;
insilmaril@728
    56
	else 
insilmaril@728
    57
		std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
insilmaril@726
    58
	return NULL;
insilmaril@726
    59
}
insilmaril@726
    60
insilmaril@726
    61
insilmaril@727
    62
void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
insilmaril@727
    63
{
insilmaril@727
    64
	// FIXME Currently this works only from treeview->ME
insilmaril@727
    65
	treeview->expandAll();	//FIXME only for testing
insilmaril@727
    66
insilmaril@727
    67
	((VymModel*)treeview->model())->select ();
insilmaril@727
    68
}
insilmaril@727
    69