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