History

It's working!

Zach Fox committed 9 years ago

Commit 56950e41 parent baad5f13 files · +10 −22Browse files

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

Unified · Split

interface/src/scripting/SelectionScriptingInterface.cpp+7−17
@@ -72,22 +72,15 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis · 71 unmodified lines
72}72}
73 73
74template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) {74template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) {
75 QWriteLocker writeLock(&_mapLock);75 GameplayObjects currentList = _selectedItemsListMap.value(listName);
76 auto currentList = _selectedItemsListMap.value(listName);76 currentList.addToGameplayObjects(idToAdd);
77 if (currentList.getContainsData()) {77 _selectedItemsListMap.insert(listName, currentList);
78 currentList.addToGameplayObjects(idToAdd);
79 _selectedItemsListMap.insert(listName, currentList);
80 78
81 emit selectedItemsListChanged(listName);79 emit selectedItemsListChanged(listName);
82 return true;80 return true;
83 } else {
84 _selectedItemsListMap.insert(listName, GameplayObjects());
85 return addToGameplayObjects(listName, idToAdd);
86 }
87}81}
88template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {82template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {
89 QWriteLocker writeLock(&_mapLock);83 GameplayObjects currentList = _selectedItemsListMap.value(listName);
90 auto currentList = _selectedItemsListMap.value(listName);
91 if (currentList.getContainsData()) {84 if (currentList.getContainsData()) {
92 currentList.removeFromGameplayObjects(idToRemove);85 currentList.removeFromGameplayObjects(idToRemove);
93 _selectedItemsListMap.insert(listName, currentList);86 _selectedItemsListMap.insert(listName, currentList);
@@ -103,13 +96,11 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c · 9 unmodified lines
103//96//
104 97
105GameplayObjects SelectionScriptingInterface::getList(const QString& listName) {98GameplayObjects SelectionScriptingInterface::getList(const QString& listName) {
106 QReadLocker readLock(&_mapLock);
107 return _selectedItemsListMap.value(listName);99 return _selectedItemsListMap.value(listName);
108}100}
109 101
110void SelectionScriptingInterface::printList(const QString& listName) {102void SelectionScriptingInterface::printList(const QString& listName) {
111 QReadLocker readLock(&_mapLock);103 GameplayObjects currentList = _selectedItemsListMap.value(listName);
112 auto currentList = _selectedItemsListMap.value(listName);
113 if (currentList.getContainsData()) {104 if (currentList.getContainsData()) {
114 105
115 qDebug() << "Avatar IDs:";106 qDebug() << "Avatar IDs:";
@@ -135,7 +126,6 @@ void SelectionScriptingInterface::printList(const QString& listName) { · 19 unmodified lines
135}126}
136 127
137bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {128bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
138 QWriteLocker writeLock(&_mapLock);
139 if (_selectedItemsListMap.remove(listName)) {129 if (_selectedItemsListMap.remove(listName)) {
140 emit selectedItemsListChanged(listName);130 emit selectedItemsListChanged(listName);
141 return true;131 return true;