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