vymview.cpp
author insilmaril
Thu, 19 Mar 2009 11:45:28 +0000
changeset 744 94ed4372ef08
parent 742 54d44ecd6097
child 745 2d4cc445a86a
permissions -rw-r--r--
ProgressBar during load and more fixes
     1 #include "vymview.h"
     2 
     3 #include <iostream>
     4 using namespace std;
     5 
     6 #include "mainwindow.h"
     7 #include "mapeditor.h"
     8 
     9 extern Main *mainWindow;
    10 
    11 
    12 VymView::VymView(VymModel *m)
    13 {
    14 	model=m;
    15 
    16 	// Create TreeView
    17 	treeview=new QTreeView;
    18 	treeview->setModel ((QAbstractItemModel*)model);
    19 	treeview->setMinimumWidth (350);
    20 	treeview->setColumnWidth (0,350);
    21 
    22 	selModel=treeview->selectionModel();
    23 	model->setSelectionModel (selModel);
    24 	connect (
    25 		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    26 		this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &)));
    27 
    28 	// Create good old MapEditor
    29 	MapEditor* me=model->getMapEditor();
    30 	if (!me) me=new MapEditor (model);
    31 	connect (
    32 		selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    33 		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    34 	connect (
    35 		selModel, SIGNAL (currentChanged(const QModelIndex &, const QModelIndex &)), 
    36 		me,SLOT (updateCurrent(const QModelIndex &,const QModelIndex &)));
    37 
    38 	// VymModel may want to update selection, e.g. during animation
    39 	connect (
    40 		model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), 
    41 		me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &)));
    42 
    43 	//me->viewport()->setFocus();	//FIXME needed?
    44 	me->setAntiAlias (mainWindow->isAliased());
    45 	me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
    46 
    47 	addWidget (treeview);
    48 	addWidget (me);
    49 
    50 	// Set geometry
    51 	QList <int> sizes;
    52 	sizes.append (120);
    53 	sizes.append (600);
    54 	setSizes (sizes);
    55 }
    56 
    57 QItemSelectionModel* VymView::selectionModel() 
    58 {
    59 	if (treeview) 
    60 		return selModel;
    61 	else 
    62 		std::cout <<"VymView::selectionModel: hey, no treeview so far???\n";
    63 	return NULL;
    64 }
    65 
    66 
    67 void VymView::changeSelection (const QItemSelection &, const QItemSelection &)
    68 {
    69 	cout << "VymView::changeSelection (newsel,delsel)\n";
    70 	//treeview->expandAll();	//FIXME only for testing
    71 
    72 	//((VymModel*)treeview->model())->select ();
    73 
    74 	// Show URL and link in statusbar
    75 	QString status;
    76 	QString s=model->getURL();
    77 	if (!s.isEmpty() ) status+="URL: "+s+"  ";
    78 	s=model->getVymLink();
    79 	if (!s.isEmpty() ) status+="Link: "+s;
    80 	if (!status.isEmpty() ) mainWindow->statusMessage (status);
    81 
    82 /* FIXME, was so far in BranchObj
    83 	// Update Toolbar
    84 	//updateFlagsToolbar();
    85 
    86 */
    87 
    88 	// Update actions
    89 	mainWindow->updateActions();
    90 }
    91