vymview.cpp
author insilmaril
Wed, 29 Oct 2008 17:42:34 +0000
changeset 727 96402b172173
parent 726 7f43b93242aa
child 728 a8a98a94899a
permissions -rw-r--r--
subtrees can be deleted now
     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 	// ItemSelectionModel
    16 	selModel=treeview->selectionModel();
    17 	connect (
    18 		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    19 		this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
    20 	model->setSelectionModel (selModel);
    21 
    22 	// Create good old MapEditor
    23 	MapEditor* me=model->getMapEditor();
    24 	if (!me) me=new MapEditor (model);
    25 
    26 	me->setSelectionModel (selModel);
    27 
    28 	//me->viewport()->setFocus();
    29 	//FIXME me->setAntiAlias (actionViewToggleAntiAlias->isOn());
    30 	//FIXME me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
    31 
    32 	addWidget (treeview);
    33 	addWidget (me);
    34 
    35 	// Set geometry
    36 	QList <int> sizes;
    37 	sizes.append (150);
    38 	sizes.append (600);
    39 	setSizes (sizes);
    40 }
    41 
    42 QItemSelectionModel* VymView::selectionModel() 
    43 {
    44 	if (treeview) return selModel;
    45 	else std::cout <<"hey, no treeview so far???\n";
    46 	return NULL;
    47 }
    48 
    49 
    50 void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
    51 {
    52 	// FIXME Currently this works only from treeview->ME
    53 	treeview->expandAll();	//FIXME only for testing
    54 
    55 	((VymModel*)treeview->model())->select ();
    56 }
    57