示例#1
0
 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')
示例#2
0
 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'用户名和密码均不为空时才能保存')
示例#3
0
 def handleAddGpsOk(self, request):
     toolBarId = application.lookUpToolBarIdByResourceId(request['id'])
     if toolBarId:
         EventManager.trigger(
             Event('ToolBar.changeState.' + toolBarId, False))
     else:
         Log.e(u'未找到需要改变状态的ToolBar')
示例#4
0
 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_)
示例#5
0
 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_)
示例#6
0
 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))
示例#7
0
 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))
示例#8
0
 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'未找到对应的服务器,修改失败')
示例#9
0
 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'未找到对应的服务器,修改失败')
示例#10
0
 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'经度和纬度均不为空时才能保存')
示例#11
0
 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'用户名和密码均不为空时才能保存')
示例#12
0
 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'未找到对应的服务器,修改失败')
示例#13
0
 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'经度和纬度均不为空时才能保存')
示例#14
0
 def handleAddGpsOk(self, request):
     toolBarId = application.lookUpToolBarIdByResourceId(request['id'])
     if toolBarId:
         EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, False))
     else:
         Log.e(u'未找到需要改变状态的ToolBar')