vymview.cpp
author insilmaril
Mon, 08 Dec 2008 16:57:33 +0000
changeset 729 7ddbe3fa34a1
parent 728 a8a98a94899a
child 731 c8b1a3564c74
permissions -rw-r--r--
More fixes for selections
     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 	/*
    33 	connect (
    34 		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    35 		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    36 	*/
    37 
    38 	//me->viewport()->setFocus();
    39 	//FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());
    40 	//FIXME me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
    41 
    42 	addWidget (treeview);
    43 	addWidget (me);
    44 
    45 	// Set geometry
    46 	QList <int> sizes;
    47 	sizes.append (150);
    48 	sizes.append (600);
    49 	setSizes (sizes);
    50 }
    51 
    52 QItemSelectionModel* VymView::selectionModel() 
    53 {
    54 	if (treeview) 
    55 		return selModel;
    56 	else 
    57 		std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
    58 	return NULL;
    59 }
    60 
    61 
    62 void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
    63 {
    64 	// FIXME Currently this works only from treeview->ME
    65 	treeview->expandAll();	//FIXME only for testing
    66 
    67 	((VymModel*)treeview->model())->select ();
    68 }
    69