selection.cpp
author insilmaril
Tue, 05 Sep 2006 09:47:13 +0000
changeset 364 7b74fa3772bf
parent 16 41c3d7f9f532
child 421 5522d1da7e37
permissions -rw-r--r--
Moved the qt4-port branch to HEAD
insilmaril@0
     1
#include "selection.h"
insilmaril@0
     2
insilmaril@0
     3
insilmaril@0
     4
Selection::Selection()
insilmaril@0
     5
{
insilmaril@0
     6
}
insilmaril@0
     7
insilmaril@0
     8
Selection::~Selection()
insilmaril@0
     9
{
insilmaril@0
    10
}
insilmaril@0
    11
insilmaril@16
    12
void Selection::setMapCenter(MapCenterObj *mco)
insilmaril@0
    13
{
insilmaril@16
    14
	mapCenter=mco;
insilmaril@0
    15
}
insilmaril@0
    16
insilmaril@0
    17
void Selection::copy(const Selection &other)
insilmaril@0
    18
{
insilmaril@16
    19
	mapCenter=other.mapCenter;
insilmaril@16
    20
	selectList=other.selectList;
insilmaril@0
    21
}
insilmaril@0
    22
insilmaril@0
    23
void Selection::clear()
insilmaril@0
    24
{
insilmaril@0
    25
	selectList.clear();
insilmaril@0
    26
}
insilmaril@0
    27
insilmaril@0
    28
bool Selection::select(LinkableMapObj *lmo)
insilmaril@0
    29
{
insilmaril@16
    30
	clear();
insilmaril@16
    31
	selectList.append (lmo);
insilmaril@0
    32
	return false;
insilmaril@0
    33
}
insilmaril@0
    34
insilmaril@16
    35
bool Selection::select (const QString &s)
insilmaril@0
    36
{
insilmaril@16
    37
	LinkableMapObj *lmo=mapCenter->findObjBySelect(s);
insilmaril@16
    38
insilmaril@16
    39
	// Finally select the found object
insilmaril@16
    40
	if (lmo)
insilmaril@16
    41
	{
insilmaril@16
    42
		clear();
insilmaril@16
    43
		select (lmo);
insilmaril@16
    44
		return true;
insilmaril@16
    45
	} 
insilmaril@16
    46
	return false;
insilmaril@16
    47
insilmaril@16
    48
}
insilmaril@16
    49
insilmaril@16
    50
void Selection::unselect()
insilmaril@16
    51
{
insilmaril@16
    52
	clear();
insilmaril@0
    53
}
insilmaril@0
    54
insilmaril@0
    55
bool Selection::isEmpty()
insilmaril@0
    56
{
insilmaril@0
    57
	return selectList.isEmpty();
insilmaril@0
    58
}
insilmaril@0
    59
insilmaril@0
    60
uint Selection::count()
insilmaril@0
    61
{
insilmaril@0
    62
	return selectList.count();
insilmaril@0
    63
}
insilmaril@16
    64
insilmaril@16
    65
QString Selection::getSelectString()
insilmaril@16
    66
{
insilmaril@16
    67
	// TODO multiselection (maybe separated by ";")
insilmaril@16
    68
	if (selectList.count()==1)
insilmaril@16
    69
		return selectList.first()->getSelectString();
insilmaril@16
    70
	else
insilmaril@16
    71
		return"";
insilmaril@16
    72
}
insilmaril@16
    73
insilmaril@16
    74