selection.cpp
author insilmaril
Tue, 23 Jan 2007 11:50:56 +0000
changeset 423 7019762f8701
parent 421 5522d1da7e37
child 424 d886c77ac0fe
permissions -rw-r--r--
1.8.65 Various fixes
     1 #include "selection.h"
     2 
     3 
     4 Selection::Selection()
     5 {
     6 }
     7 
     8 Selection::~Selection()
     9 {
    10 }
    11 
    12 void Selection::setMapCenter(MapCenterObj *mco)
    13 {
    14 	mapCenter=mco;
    15 }
    16 
    17 void Selection::copy(const Selection &other)
    18 {
    19 	mapCenter=other.mapCenter;
    20 	selectList=other.selectList;
    21 	lastSelectList=other.lastSelectList;
    22 }
    23 
    24 void Selection::clear()
    25 {
    26 	selectList.clear();
    27 	lastSelectList.clear();
    28 }
    29 
    30 bool Selection::select(LinkableMapObj *lmo)	// TODO no multiselections yet
    31 {
    32 	clear();
    33 	selectList.append (lmo);
    34 	return false;
    35 }
    36 
    37 bool Selection::select (const QString &s)	// TODO no multiselections yet
    38 {
    39 	LinkableMapObj *lmo=mapCenter->findObjBySelect(s);
    40 
    41 	// Finally select the found object
    42 	if (lmo)
    43 	{
    44 		clear();
    45 		select (lmo);
    46 		return true;
    47 	} 
    48 	return false;
    49 
    50 }
    51 
    52 bool Selection::reselect ()	// TODO no multiselections yet
    53 {
    54 	if (!lastSelectList.isEmpty())
    55 	{
    56 		select (lastSelectList.first());
    57 		return true;
    58 	}
    59 	return false;
    60 
    61 }
    62 
    63 void Selection::unselect()
    64 {
    65 	lastSelectList=selectList;
    66 	selectList.clear();
    67 }
    68 
    69 bool Selection::isEmpty()
    70 {
    71 	return selectList.isEmpty();
    72 }
    73 
    74 uint Selection::count()
    75 {
    76 	return selectList.count();
    77 }
    78 
    79 SelectionType Selection::type() // TODO no multiselections yet
    80 {
    81 	if (!selectList.isEmpty())
    82 	{
    83 		LinkableMapObj *sel=selectList.first();
    84 		if (typeid (*sel)==typeid (BranchObj)) return Branch;
    85 		if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
    86 		if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
    87 	}
    88 	return Undefined;
    89 }
    90 
    91 QString Selection::getSelectString()// TODO no multiselections yet
    92 {
    93 	if (selectList.count()==1)
    94 		return selectList.first()->getSelectString();
    95 	else
    96 		return"";
    97 }
    98 
    99