History

keep debuging the seelction highlight

samcake committed 8 years ago

Commit e0740b31 parent 76cface5 files · +67 −34Browse files

Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 5 files). Show all

Unified · Split

interface/src/scripting/SelectionScriptingInterface.cpp+44−32
@@ -73,12 +73,11 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis · 72 unmodified lines
7373
7474 bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) {
7575 _selectedItemsListMap.insert(listName, GameplayObjects());
76− emit selectedItemsListChanged(listName);
76+ onSelectedItemsListChanged(listName);
7777 return true;
7878 }
7979
8080 bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {
81− bool doSetupHandler = false;
8281
8382 auto highlightStyle = _highlightedListMap.find(listName);
8483 if (highlightStyle == _highlightedListMap.end()) {
@@ -90,18 +89,14 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c · 5 unmodified lines
9089 auto currentList = _selectedItemsListMap.find(listName);
9190 if (currentList == _selectedItemsListMap.end()) {
9291 _selectedItemsListMap.insert(listName, GameplayObjects());
93− setupHandler(listName);
94− // doSetupHandler = true;
9592 }
93+ setupHandler(listName);
94+
9695 (*highlightStyle).setBoundToList(true);
9796 }
9897
9998 (*highlightStyle).fromVariantMap(highlightStyleValues);
10099
101−/* if (doSetupHandler) {
102− setupHandler(listName);
103− }*/
104−
105100 auto mainScene = qApp->getMain3DScene();
106101 if (mainScene) {
107102 render::Transaction transaction;
@@ -139,7 +134,12 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) · 31 unmodified lines
139134 }
140135
141136 QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const {
142− return QVariantMap();
137+ auto highlightStyle = _highlightedListMap.find(listName);
138+ if (highlightStyle == _highlightedListMap.end()) {
139+ return QVariantMap();
140+ } else {
141+ return (*highlightStyle).toVariantMap();
142+ }
143143 }
144144
145145 render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const {
@@ -156,7 +156,7 @@ template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const · 10 unmodified lines
156156 currentList.addToGameplayObjects(idToAdd);
157157 _selectedItemsListMap.insert(listName, currentList);
158158
159− emit selectedItemsListChanged(listName);
159+ onSelectedItemsListChanged(listName);
160160 return true;
161161 }
162162 template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {
@@ -165,7 +165,7 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c · 2 unmodified lines
165165 currentList.removeFromGameplayObjects(idToRemove);
166166 _selectedItemsListMap.insert(listName, currentList);
167167
168− emit selectedItemsListChanged(listName);
168+ onSelectedItemsListChanged(listName);
169169 return true;
170170 } else {
171171 return false;
@@ -180,34 +180,40 @@ GameplayObjects SelectionScriptingInterface::getList(const QString& listName) { · 8 unmodified lines
180180 }
181181
182182 void SelectionScriptingInterface::printList(const QString& listName) {
183− GameplayObjects currentList = _selectedItemsListMap.value(listName);
184− if (currentList.getContainsData()) {
183+ auto currentList = _selectedItemsListMap.find(listName);
184+ if (currentList != _selectedItemsListMap.end()) {
185+ if ((*currentList).getContainsData()) {
186+
187+ qDebug() << "List named " << listName << ":";
188+ qDebug() << "Avatar IDs:";
189+ for (auto i : (*currentList).getAvatarIDs()) {
190+ qDebug() << i << ';';
191+ }
192+ qDebug() << "";
185193
186− qDebug() << "Avatar IDs:";
187− for (auto i : currentList.getAvatarIDs()) {
188− qDebug() << i << ';';
189− }
190− qDebug() << "";
194+ qDebug() << "Entity IDs:";
195+ for (auto j : (*currentList).getEntityIDs()) {
196+ qDebug() << j << ';';
197+ }
198+ qDebug() << "";
191199
192− qDebug() << "Entity IDs:";
193− for (auto j : currentList.getEntityIDs()) {
194− qDebug() << j << ';';
200+ qDebug() << "Overlay IDs:";
201+ for (auto k : (*currentList).getOverlayIDs()) {
202+ qDebug() << k << ';';
203+ }
204+ qDebug() << "";
195205 }
196− qDebug() << "";
197−
198− qDebug() << "Overlay IDs:";
199− for (auto k : currentList.getOverlayIDs()) {
200− qDebug() << k << ';';
206+ else {
207+ qDebug() << "List named " << listName << " empty";
201208 }
202− qDebug() << "";
203209 } else {
204− qDebug() << "List named" << listName << "doesn't exist.";
210+ qDebug() << "List named " << listName << " doesn't exist.";
205211 }
206212 }
207213
208214 bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
209215 if (_selectedItemsListMap.remove(listName)) {
210− emit selectedItemsListChanged(listName);
216+ onSelectedItemsListChanged(listName);
211217 return true;
212218 } else {
213219 return false;
@@ -222,7 +228,15 @@ void SelectionScriptingInterface::setupHandler(const QString& selectionName) { · 8 unmodified lines
222228
223229
224230 (*handler)->initialize(selectionName);
231+ // connect(this, &SelectionScriptingInterface::selectedItemsListChanged, handler.value(), &SelectionToSceneHandler::selectedItemsListChanged);
232+
233+}
225234
235+void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) {
236+ auto handler = _handlerMap.find(listName);
237+ if (handler != _handlerMap.end()) {
238+ (*handler)->updateSceneFromSelectedList();
239+ }
226240 }
227241
228242
@@ -232,10 +246,8 @@ SelectionToSceneHandler::SelectionToSceneHandler() { · 3 unmodified lines
232246 void SelectionToSceneHandler::initialize(const QString& listName) {
233247 _listName = listName;
234248
235− connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged);
236− // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged);
237− // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved);
238249
250+ updateSceneFromSelectedList();
239251 }
240252
241253 void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) {