Exemple #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')
Exemple #2
0
 def closeTab(self, index):
     widget = self.tabWidget.widget(index)
     msgBox = QMessageBox()
     msgBox.setText(u'是否真的要关闭: ' + self.tabWidget.tabText(index))
     msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
     msgBox.setDefaultButton(QMessageBox.No)
     msgBox.setWindowTitle(u'关闭tab页')
     info = widget.information()
     if info:
         try:
             accounts = info['accounts']
             text = u'该tab页已登陆帐号:\n'
             for account in accounts:
                 text += account + '\n'
             text.rstrip('\n')
             msgBox.setInformativeText(unicode(text))
         except KeyError:
             pass
     result = msgBox.exec_()
     if result == QMessageBox.Yes:
         for webChat in widget.webchats:
             vmId = webChat.vmId()
             clientId = application.lookUpClientIdByResourceId(vmId)
             message = Message(cmd=Message.CMD_CLOSE_VM)
             message['vmId'] = vmId
             EventManager.trigger(
                 Event('Client.replyReady.' + clientId, message))
         self.tabWidget.removeTab(index)
Exemple #3
0
 def closeTab(self, index):
     widget = self.tabWidget.widget(index)
     msgBox = QMessageBox()
     msgBox.setText(u'是否真的要关闭: ' + self.tabWidget.tabText(index))
     msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
     msgBox.setDefaultButton(QMessageBox.No)
     msgBox.setWindowTitle(u'关闭tab页')
     info = widget.information()
     if info:
         try:
             accounts = info['accounts']
             text = u'该tab页已登陆帐号:\n'
             for account in accounts:
                 text += account + '\n'
             text.rstrip('\n')
             msgBox.setInformativeText(unicode(text))
         except KeyError:
             pass
     result = msgBox.exec_()
     if result == QMessageBox.Yes:
         for webChat in widget.webchats:
             vmId = webChat.vmId()
             clientId = application.lookUpClientIdByResourceId(vmId)
             message = Message(cmd=Message.CMD_CLOSE_VM)
             message['vmId'] = vmId
             EventManager.trigger(Event('Client.replyReady.' + clientId, message))
         self.tabWidget.removeTab(index)
Exemple #4
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))
Exemple #5
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))
Exemple #6
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'未找到对应的服务器,修改失败')
Exemple #7
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'未找到对应的服务器,修改失败')
Exemple #8
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'未找到对应的服务器,修改失败')