glc_movercontroller.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00027 #include "glc_movercontroller.h"
00028
00029
00030 GLC_MoverController::GLC_MoverController()
00031 : m_ActiveMoverId(0)
00032 , m_MoverHash()
00033 {
00034
00035
00036 }
00037
00038
00039 GLC_MoverController::GLC_MoverController(const GLC_MoverController& controller)
00040 : m_ActiveMoverId(controller.m_ActiveMoverId)
00041 , m_MoverHash()
00042 {
00043 MoverHash::const_iterator iMover= controller.m_MoverHash.constBegin();
00044 while (iMover != controller.m_MoverHash.constEnd())
00045 {
00046 m_MoverHash.insert(iMover.key(), iMover.value()->clone());
00047 ++iMover;
00048 }
00049 }
00050
00051
00052 GLC_MoverController::~GLC_MoverController()
00053 {
00054 MoverHash::iterator iMover= m_MoverHash.begin();
00055 while (iMover != m_MoverHash.constEnd())
00056 {
00057 delete iMover.value();
00058
00059 ++iMover;
00060 }
00061 }
00062
00064
00066
00068 GLC_MoverController& GLC_MoverController::operator = (const GLC_MoverController& controller)
00069 {
00070 if (&controller != this)
00071 {
00072 m_ActiveMoverId= controller.m_ActiveMoverId;
00073
00074
00075 {
00076 MoverHash::iterator iMover= m_MoverHash.begin();
00077 while (iMover != m_MoverHash.constEnd())
00078 {
00079 delete iMover.value();
00080
00081 ++iMover;
00082 }
00083 m_MoverHash.clear();
00084 }
00085
00086 MoverHash::const_iterator iMover= controller.m_MoverHash.constBegin();
00087 while (iMover != controller.m_MoverHash.constEnd())
00088 {
00089 m_MoverHash.insert(iMover.key(), iMover.value()->clone());
00090 ++iMover;
00091 }
00092 }
00093 return *this;
00094 }
00095
00096
00097 void GLC_MoverController::addMover(GLC_Mover* pMover, const int id)
00098 {
00099 Q_ASSERT(!m_MoverHash.contains(id));
00100 m_MoverHash.insert(id, pMover);
00101 }
00102
00103
00104 void GLC_MoverController::removeMover(const int id)
00105 {
00106 Q_ASSERT(m_MoverHash.contains(id));
00107 m_MoverHash.remove(id);
00108 if (id == m_ActiveMoverId)
00109 {
00110 m_ActiveMoverId= 0;
00111 }
00112 }
00113
00114 void GLC_MoverController::setActiveMover(const int id, QMouseEvent * e)
00115 {
00116 Q_ASSERT(m_MoverHash.contains(id));
00117 m_ActiveMoverId= id;
00118 connect(m_MoverHash.value(m_ActiveMoverId), SIGNAL(updated()), this, SIGNAL(repaintNeeded()));
00119 m_MoverHash.value(m_ActiveMoverId)->init(e);
00120 }
00121
00122 void GLC_MoverController::setNoMover()
00123 {
00124 if (0 != m_ActiveMoverId)
00125 {
00126 m_MoverHash.value(m_ActiveMoverId)->ends();
00127 disconnect(m_MoverHash.value(m_ActiveMoverId), SIGNAL(updated()), this, SIGNAL(repaintNeeded()));
00128 m_ActiveMoverId= 0;
00129 }
00130 }
00131