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

Listing des communautés, démarrage du coeur de l'application, avec de le la...

Listing des communautés, démarrage du coeur de l'application, avec de le la sauvegarde au format JSON
parent 2dc0881e
No related branches found
No related tags found
No related merge requests found
Showing
with 136 additions and 19 deletions
......@@ -61,7 +61,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTableView" name="communitiesTable"/>
<widget class="QListView" name="communitiesList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
......
......@@ -14,7 +14,14 @@
<string notr="true">CuteCoin</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="accountNameLabel">
<property name="text">
<string>Please select an account</string>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="actionsFrame">
<property name="frameShape">
......@@ -26,8 +33,11 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="walletsTab">
<attribute name="title">
......@@ -153,6 +163,7 @@
</property>
<addaction name="actionChange_account"/>
<addaction name="actionAdd_account"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
......
......@@ -6,11 +6,12 @@ Created on 1 févr. 2014
import sys
from PyQt5.QtWidgets import QApplication, QDialog
from cutecoin.gui.mainWindow import MainWindow
from cutecoin.models.account import Account
from cutecoin.core import Core
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
core = Core(sys.argv)
window = MainWindow(core)
window.show()
sys.exit(app.exec_())
pass
\ No newline at end of file
'''
Created on 1 févr. 2014
@author: inso
'''
from cutecoin.core.appData import AppData
from cutecoin.core import config
class Core(object):
def __init__(self, argv):
'''
Constructor
'''
self.account = []
self.currentAccount = None
config.parseArguments(argv)
AppData().load(self)
def getAccounts(self):
return self.accounts
def addAccount(self, account):
self.accounts.append(account)
self.currentAccount = account
def delAccount(self, account):
self.accounts.remove(account)
'''
Created on 7 févr. 2014
@author: inso
'''
import json
from cutecoin.core import config
class AppData(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
def load(self, core):
json_data=open(config.data['home'])
data = json.load(json_data)
json_data.close()
data['accounts']
def save(self, core):
#TODO: Sauvegarde de l'état de l'application
pass
\ No newline at end of file
'''
Created on 7 févr. 2014
@author: inso
'''
data = { 'home' : '~/.cutecoin'}
def parseArguments(argv):
#TODO: Parsing d'arguments
pass
\ No newline at end of file
......@@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QDialog
from cutecoin.gui.addCommunityDialog import AddCommunityDialog
from cutecoin.models.account import Account
from cutecoin.models.account.communities import Communities
from cutecoin.models.account.communities.treeModel import CommunitiesTreeModel
from cutecoin.models.account.communities.listModel import CommunitiesListModel
import gnupg
......@@ -19,7 +19,7 @@ class AddAccountDialog(QDialog, Ui_AddAccountDialog):
'''
def __init__(self):
def __init__(self, mainWindow):
'''
Constructor
'''
......@@ -27,6 +27,11 @@ class AddAccountDialog(QDialog, Ui_AddAccountDialog):
super(AddAccountDialog, self).__init__()
self.setupUi(self)
self.dialog = AddCommunityDialog(self)
self.mainWindow = mainWindow
self.buttonBox.accepted.connect(self.mainWindow.actionAddAccount)
self.setData()
def setData(self):
......@@ -35,14 +40,13 @@ class AddAccountDialog(QDialog, Ui_AddAccountDialog):
for key in availableKeys:
self.pgpkeyList.addItem(key['uids'][0])
self.account = Account(self.pgpkeyList.currentText(), "", Communities())
def openAddCommunityDialog(self):
self.dialog.setCommunities(self.account.communities)
self.dialog.exec_()
def validAddCommunityDialog(self):
self.communitiesTable.setModel(CommunitiesTreeModel(self.account))
def actionAddCommunity(self):
self.communitiesList.setModel(CommunitiesListModel(self.account))
......@@ -21,7 +21,7 @@ class AddCommunityDialog(QDialog, Ui_AddCommunityDialog):
super(AddCommunityDialog, self).__init__()
self.setupUi(self)
self.accountDialog = accountDialog
self.buttonBox.accepted.connect(self.accountDialog.validAddCommunityDialog)
self.buttonBox.accepted.connect(self.accountDialog.actionAddCommunity)
def setCommunities(self, communities):
self.communities = communities
......
......@@ -13,15 +13,29 @@ class MainWindow(QMainWindow, Ui_MainWindow):
'''
def __init__(self):
def __init__(self, core):
'''
Constructor
'''
# Set up the user interface from Designer.
super(MainWindow, self).__init__()
self.setupUi(self)
self.core = core
def openAddAccountDialog(self):
dialog = AddAccountDialog()
dialog.setData()
dialog.exec_()
\ No newline at end of file
self.dialog = AddAccountDialog()
self.dialog.setData()
self.dialog.exec_()
def actionAddAccount(self):
self.core.addAccount(self.dialog.account)
'''
Refresh main window
When the selected account changes, all the widgets
in the window have to be refreshed
'''
def refreshMainWindow(self):
if self.core.currentAccount != None:
#TODO: rafraichissement de la fenetre
pass
......@@ -10,12 +10,12 @@ class CommunitiesListModel(QAbstractListModel):
'''
A Qt abstract item model to display communities in a tree
'''
def __init__(self, communities, parent=None):
def __init__(self, account, parent=None):
'''
Constructor
'''
super(CommunitiesListModel, self).__init__(parent)
self.communities = communities
self.communities = account.communities
def rowCount(self ,parent):
......
......@@ -9,6 +9,8 @@ from cutecoin.models.account.communities.itemModel import CommunitiesItemModel
from cutecoin.models.community.itemModel import CommunityItemModel
from cutecoin.models.node.itemModel import MainNodeItem, NodeItem
#TODO: Use it somewhere or remove it from the code
class CommunitiesTreeModel(QAbstractItemModel):
'''
A Qt abstract item model to display communities in a tree
......
'''
Created on 7 févr. 2014
@author: inso
'''
class Wallets(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
File moved
......@@ -23,8 +23,7 @@ class Community(object):
Listing members of a community
'''
# TODO : Try connecting with nodes of the list
# if the first fails
#TODO: Try connecting with nodes of the list if the first fails
# Maybe create a method
ucoin.settings['server'] = self.knowNodes[0].server
ucoin.settings['port'] = self.knowNodes[0].port
......
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