selection.cpp
changeset 773 340bc29da9a0
parent 772 e3f722759c7e
child 774 2f002657dada
     1.1 --- a/selection.cpp	Wed May 20 15:40:14 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,189 +0,0 @@
     1.4 -#include <typeinfo>
     1.5 -#include <iostream>
     1.6 -using namespace std;
     1.7 -
     1.8 -#include "selection.h"
     1.9 -
    1.10 -#include "mainwindow.h"
    1.11 -#include "vymmodel.h"
    1.12 -
    1.13 -
    1.14 -
    1.15 -extern Main *mainWindow;
    1.16 -
    1.17 -Selection::Selection()
    1.18 -{
    1.19 -	blocked=false;
    1.20 -	model=NULL;
    1.21 -}
    1.22 -
    1.23 -Selection::~Selection()
    1.24 -{
    1.25 -}
    1.26 -
    1.27 -void Selection::setModel (VymModel *m)
    1.28 -{
    1.29 -	model=m;
    1.30 -}
    1.31 -
    1.32 -void Selection::update() // FIXME-2 VM emit signal in VM instead and get rid of this
    1.33 -{
    1.34 -/*
    1.35 -	QRectF bbox;
    1.36 -	//int w=0;
    1.37 -	for (int i=0; i< selectList.count(); ++i) 
    1.38 -	{
    1.39 -		bbox=selectList.at(i)->getBBox();
    1.40 -		selboxList.at(i)->setRect (
    1.41 -			bbox.x()-w,bbox.y()-w, 
    1.42 -			bbox.width()+2*w, bbox.height()+2*w);
    1.43 -		selboxList.at(i)->setPen (color);	
    1.44 -		selboxList.at(i)->setBrush (color);	
    1.45 -	}	
    1.46 -*/
    1.47 -}
    1.48 -bool Selection::select(LinkableMapObj *lmo)// FIXME-2 VM emit signal in VM instead and get rid of this
    1.49 -
    1.50 -{
    1.51 -	return model->select (lmo);
    1.52 -	/*
    1.53 -	if (!selectList.isEmpty()) unselect();
    1.54 -	selectList.append (lmo);
    1.55 -	lmo->select();
    1.56 -	update();
    1.57 -	mainWindow->updateSatellites (model);	
    1.58 -	cout << "Sel::select lmo e\n";
    1.59 -	return true;
    1.60 -	*/
    1.61 -}
    1.62 -
    1.63 -bool Selection::select (const QString &s)// FIXME-2 VM emit signal in VM instead and get rid of this
    1.64 -
    1.65 -{
    1.66 -	return model->select (s);
    1.67 -	/*
    1.68 -	cout << "Sel::select s=\n";
    1.69 -	LinkableMapObj *lmo=model->findObjBySelect(s);
    1.70 -
    1.71 -	// Finally select the found object
    1.72 -	if (lmo)
    1.73 -	{
    1.74 -		unselect();
    1.75 -		select (lmo);
    1.76 -		return true;
    1.77 -	} 
    1.78 -	return false;
    1.79 -	*/
    1.80 -}
    1.81 -
    1.82 -bool Selection::reselect ()	// TODO no multiselections yet
    1.83 -{
    1.84 -	if (!lastSelectList.isEmpty())
    1.85 -	{
    1.86 -		select (lastSelectList.first());
    1.87 -		return true;
    1.88 -	}
    1.89 -	return false;
    1.90 -
    1.91 -}
    1.92 -
    1.93 -void Selection::unselect()
    1.94 -{
    1.95 -	model->unselect();
    1.96 -}
    1.97 -
    1.98 -bool Selection::isBlocked()
    1.99 -{
   1.100 -	return blocked;
   1.101 -}
   1.102 -
   1.103 -void Selection::block()
   1.104 -{
   1.105 -	blocked=true;
   1.106 -}
   1.107 -
   1.108 -void Selection::unblock()
   1.109 -{
   1.110 -	blocked=false;
   1.111 -}
   1.112 -
   1.113 -bool Selection::isEmpty()
   1.114 -{
   1.115 -	return selectList.isEmpty();
   1.116 -}
   1.117 -
   1.118 -/*
   1.119 -uint Selection::count()
   1.120 -{
   1.121 -	return selectList.count();
   1.122 -}
   1.123 -*/
   1.124 -
   1.125 -/*
   1.126 -Selection::Type Selection::type() // TODO no multiselections yet
   1.127 -{
   1.128 -	if (!selectList.isEmpty())
   1.129 -	{
   1.130 -		LinkableMapObj *sel=selectList.first();
   1.131 -		if (typeid (*sel)==typeid (BranchObj)) return Branch;
   1.132 -		if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
   1.133 -		if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
   1.134 -	}
   1.135 -	return Undefined;
   1.136 -}
   1.137 -*/
   1.138 -
   1.139 -/*
   1.140 -LinkableMapObj* Selection::first()
   1.141 -{
   1.142 -	if (!selectList.isEmpty())
   1.143 -		return selectList.first();
   1.144 -	else	
   1.145 -		return NULL;
   1.146 -}
   1.147 -
   1.148 -LinkableMapObj* Selection::single()
   1.149 -{
   1.150 -	if (selectList.count() == 1)
   1.151 -		return selectList.first();
   1.152 -	else	
   1.153 -		return NULL;
   1.154 -}
   1.155 -
   1.156 -TreeItem* Selection::getBranchItem()
   1.157 -{
   1.158 -	BranchObj* bo=getBranch();
   1.159 -	if (bo) return bo->getTreeItem(); //  VM get directly from treemodl
   1.160 -	return NULL;
   1.161 -}
   1.162 -
   1.163 -QModelIndex Selection::getBranchIndex()
   1.164 -{
   1.165 -	return model->getSelectionModel()->selectedIndexes().first();	// TODO no multiselections yet
   1.166 -
   1.167 -}
   1.168 -*/
   1.169 -
   1.170 -FloatImageObj* Selection::getFloatImage()
   1.171 -{
   1.172 -	if (!selectList.isEmpty())
   1.173 -	{
   1.174 -		LinkableMapObj *sel=selectList.first();
   1.175 -		if (typeid (*sel)==typeid (FloatImageObj)) 
   1.176 -			return (FloatImageObj*)sel;
   1.177 -	}
   1.178 -		return NULL;
   1.179 -}
   1.180 -
   1.181 -QString Selection::getSelectString() // FIXME-2 VM this is also in VM ?! clean up here...
   1.182 -// TODO no multiselections yet
   1.183 -{
   1.184 -	if (selectList.count()==1)
   1.185 -	{
   1.186 -		return model->getSelectString (selectList.first() );
   1.187 -	}
   1.188 -	else
   1.189 -		return"";
   1.190 -}
   1.191 -
   1.192 -