vymview.cpp
author insilmaril
Tue, 04 Nov 2008 12:09:10 +0000
changeset 728 a8a98a94899a
parent 727 96402b172173
child 729 7ddbe3fa34a1
permissions -rw-r--r--
Selections work (a little bit)
     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 
    28 	// VymModel may want to update selection, e.g. during animation
    29 	connect (
    30 		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    31 		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    32 
    33 
    34 	//me->viewport()->setFocus();
    35 	//FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());
    36 	//FIXME me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
    37 
    38 	addWidget (treeview);
    39 	addWidget (me);
    40 
    41 	// Set geometry
    42 	QList <int> sizes;
    43 	sizes.append (150);
    44 	sizes.append (600);
    45 	setSizes (sizes);
    46 }
    47 
    48 QItemSelectionModel* VymView::selectionModel() 
    49 {
    50 	if (treeview) 
    51 		return selModel;
    52 	else 
    53 		std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
    54 	return NULL;
    55 }
    56 
    57 
    58 void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
    59 {
    60 	// FIXME Currently this works only from treeview->ME
    61 	treeview->expandAll();	//FIXME only for testing
    62 
    63 	((VymModel*)treeview->model())->select ();
    64 }
    65