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