def deleteSelectedItems(self): selection = self.gpsTable.selectionModel() indexes = selection.selectedRows() #uuids: {clientId: [uuid,]} uuids = {} for index in indexes: uuid_ = self.gpsModel.gpsItems[index.row()].id() clientId = application.lookUpClientIdByResourceId(uuid_) if clientId in uuids: uuids[clientId].append(uuid_) else: uuids[clientId] = [uuid_] if len(uuids) == 0: return for clientId in uuids: message = Message(cmd=Message.CMD_DELETE_GPS) message['ids'] = uuids[clientId] EventManager.trigger(Event('Client.replyReady.' + clientId, message)) self.deleteGpsItems(uuids[clientId]) for uuid_ in uuids[clientId]: toolBarId = application.lookUpToolBarIdByResourceId(uuid_) if toolBarId: EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的ToolBar')
def handleSaveClicked(self): readable = self.readableEdit.text() username = self.nameEdit.text() password = self.passwordEdit.text() if len(username) > 0 and len(password) > 0: resourceId = uuid.uuid4().hex account = { 'id': resourceId, 'desc': readable, 'username': username, 'password': password } self.wantSaveAccount.emit(account) clientId = application.getRandomClientId() message = Message(cmd=Message.CMD_ADD_ACCOUNT) message['account'] = account if clientId: EventManager.trigger( Event('Client.replyReady.' + clientId, message)) application.addResource(resourceId, clientId) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: EventManager.trigger( Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的服务器,增加失败') else: Log.w(u'用户名和密码均不为空时才能保存')
def handleAddGpsOk(self, request): toolBarId = application.lookUpToolBarIdByResourceId(request['id']) if toolBarId: EventManager.trigger( Event('ToolBar.changeState.' + toolBarId, False)) else: Log.e(u'未找到需要改变状态的ToolBar')
def handleDeleteGpsOk(self, request): ids = request['ids'] for id_ in ids: toolBarId = application.lookUpToolBarIdByResourceId(id_) if toolBarId: EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, False)) else: Log.e(u'未找到需要改变状态的ToolBar') application.delItemFromToolBar(id_)
def handleDeleteGpsOk(self, request): ids = request['ids'] for id_ in ids: toolBarId = application.lookUpToolBarIdByResourceId(id_) if toolBarId: EventManager.trigger( Event('ToolBar.changeState.' + toolBarId, False)) else: Log.e(u'未找到需要改变状态的ToolBar') application.delItemFromToolBar(id_)
def editVm(self, index, unused, roles): """同步修改到服务器,只能修改虚拟机备注""" if Qt.EditRole not in roles: self.treeView.update() return item = self.model.itemForIndex(index) resourceId = item.id() clientId = application.lookUpClientIdByResourceId(resourceId) if clientId: message = Message(cmd=Message.CMD_UPDATE_VM) message['vmId'] = resourceId message['desc'] = item.description() EventManager.trigger(Event('Client.replyReady.' + clientId, message)) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: print 'ToolBar.changeState.' + toolBarId EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True))
def editVm(self, index, unused, roles): """同步修改到服务器,只能修改虚拟机备注""" if Qt.EditRole not in roles: self.treeView.update() return item = self.model.itemForIndex(index) resourceId = item.id() clientId = application.lookUpClientIdByResourceId(resourceId) if clientId: message = Message(cmd=Message.CMD_UPDATE_VM) message['vmId'] = resourceId message['desc'] = item.description() EventManager.trigger( Event('Client.replyReady.' + clientId, message)) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: print 'ToolBar.changeState.' + toolBarId EventManager.trigger( Event('ToolBar.changeState.' + toolBarId, True))
def editLocation(self, index, unused, roles): """同步修改到服务器,对于GPS坐标来说,客户端只能更改坐标备注""" if Qt.EditRole not in roles: self.gpsTable.update() return item = self.gpsModel.itemForIndex(index) resourceId = item.id() clientId = application.lookUpClientIdByResourceId(resourceId) if clientId: message = Message(cmd=Message.CMD_UPDATE_GPS) message['id'] = resourceId message['desc'] = item.description() EventManager.trigger(Event('Client.replyReady.' + clientId, message)) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: print 'ToolBar.changeState.' + toolBarId EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的服务器,修改失败')
def editAccount(self, index, unused, roles): """同步修改到服务器""" if Qt.EditRole not in roles: self.table.update() return item = self.model.itemForIndex(index) resourceId = item.id() clientId = application.lookUpClientIdByResourceId(resourceId) if clientId: message = Message(cmd=Message.CMD_UPDATE_ACCOUNT) message['id'] = resourceId message['desc'] = item.description() message['username'] = item.username() message['password'] = item.password() EventManager.trigger(Event('Client.replyReady.' + clientId, message)) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: print 'ToolBar.changeState.' + toolBarId EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的服务器,修改失败')
def handleSaveClicked(self): readable = self.readableEdit.text() lng = self.lngEdit.text() lat = self.latEdit.text() if len(lng) > 0 and len(lat) > 0: resourceId = uuid.uuid4().hex gps = {'id': resourceId, 'desc': readable, 'lng': lng, 'lat': lat} self.wantSaveLocation.emit(gps) clientId = application.getRandomClientId() message = Message(cmd=Message.CMD_ADD_GPS) message['gps'] = gps if clientId: EventManager.trigger(Event('Client.replyReady.' + clientId, message)) application.addResource(resourceId, clientId) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的服务器,增加失败') else: Log.w(u'经度和纬度均不为空时才能保存')
def handleSaveClicked(self): readable = self.readableEdit.text() username = self.nameEdit.text() password = self.passwordEdit.text() if len(username) > 0 and len(password) > 0: resourceId = uuid.uuid4().hex account = {'id': resourceId, 'desc': readable, 'username': username, 'password': password} self.wantSaveAccount.emit(account) clientId = application.getRandomClientId() message = Message(cmd=Message.CMD_ADD_ACCOUNT) message['account'] = account if clientId: EventManager.trigger(Event('Client.replyReady.' + clientId, message)) application.addResource(resourceId, clientId) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的服务器,增加失败') else: Log.w(u'用户名和密码均不为空时才能保存')
def editAccount(self, index, unused, roles): """同步修改到服务器""" if Qt.EditRole not in roles: self.table.update() return item = self.model.itemForIndex(index) resourceId = item.id() clientId = application.lookUpClientIdByResourceId(resourceId) if clientId: message = Message(cmd=Message.CMD_UPDATE_ACCOUNT) message['id'] = resourceId message['desc'] = item.description() message['username'] = item.username() message['password'] = item.password() EventManager.trigger( Event('Client.replyReady.' + clientId, message)) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: print 'ToolBar.changeState.' + toolBarId EventManager.trigger( Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的服务器,修改失败')
def handleSaveClicked(self): readable = self.readableEdit.text() lng = self.lngEdit.text() lat = self.latEdit.text() if len(lng) > 0 and len(lat) > 0: resourceId = uuid.uuid4().hex gps = {'id': resourceId, 'desc': readable, 'lng': lng, 'lat': lat} self.wantSaveLocation.emit(gps) clientId = application.getRandomClientId() message = Message(cmd=Message.CMD_ADD_GPS) message['gps'] = gps if clientId: EventManager.trigger( Event('Client.replyReady.' + clientId, message)) application.addResource(resourceId, clientId) toolBarId = application.lookUpToolBarIdByResourceId(resourceId) if toolBarId: EventManager.trigger( Event('ToolBar.changeState.' + toolBarId, True)) else: Log.e(u'未找到对应的服务器,增加失败') else: Log.w(u'经度和纬度均不为空时才能保存')
def handleAddGpsOk(self, request): toolBarId = application.lookUpToolBarIdByResourceId(request['id']) if toolBarId: EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, False)) else: Log.e(u'未找到需要改变状态的ToolBar')