Skip to content
Snippets Groups Projects
Commit fed3f95f authored by inso's avatar inso
Browse files

Delete node from community

parent 258c7dc6
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,11 @@ ...@@ -24,7 +24,11 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QTreeView" name="communityView"/> <widget class="QTreeView" name="communityView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
...@@ -125,8 +129,25 @@ ...@@ -125,8 +129,25 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>communityView</sender>
<signal>customContextMenuRequested(QPoint)</signal>
<receiver>CommunityConfigurationDialog</receiver>
<slot>showContextMenu(QPoint)</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>addNode()</slot> <slot>addNode()</slot>
<slot>showContextMenu(QPoint)</slot>
</slots> </slots>
</ui> </ui>
...@@ -4,7 +4,7 @@ Created on 8 mars 2014 ...@@ -4,7 +4,7 @@ Created on 8 mars 2014
@author: inso @author: inso
''' '''
from cutecoin.gen_resources.communityConfigurationDialog_uic import Ui_CommunityConfigurationDialog from cutecoin.gen_resources.communityConfigurationDialog_uic import Ui_CommunityConfigurationDialog
from PyQt5.QtWidgets import QDialog, QErrorMessage from PyQt5.QtWidgets import QDialog, QErrorMessage, QMenu
from cutecoin.models.community.treeModel import CommunityTreeModel from cutecoin.models.community.treeModel import CommunityTreeModel
from cutecoin.models.node import TrustedNode from cutecoin.models.node import TrustedNode
from cutecoin.core.exceptions import NotMemberOfCommunityError from cutecoin.core.exceptions import NotMemberOfCommunityError
...@@ -52,6 +52,20 @@ class ConfigureCommunityDialog(QDialog, Ui_CommunityConfigurationDialog): ...@@ -52,6 +52,20 @@ class ConfigureCommunityDialog(QDialog, Ui_CommunityConfigurationDialog):
self.community.addTrustedNode( TrustedNode(server, port )) self.community.addTrustedNode( TrustedNode(server, port ))
self.communityView.setModel( CommunityTreeModel(self.community )) self.communityView.setModel( CommunityTreeModel(self.community ))
def showContextMenu(self, point):
menu = QMenu()
action = menu.addAction("Delete", self.removeNode)
if self.community is not None:
if len(self.community.trustedNodes) == 1:
action.setEnabled(False)
menu.exec_(self.communityView.mapToGlobal(point))
def removeNode(self):
for index in self.communityView.selectedIndexes():
self.community.trustedNodes.pop(index.row())
self.communityView.setModel( CommunityTreeModel(self.community ))
def accept(self): def accept(self):
self.close() self.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment