Implementation parking creation
This commit is contained in:
@@ -1,12 +1,70 @@
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from src.m.Parking import Parking
|
||||
from src.m.Place import ListeTypePlace
|
||||
from src.v.MyQWidget import MyQWidget
|
||||
from src.v.Ui_CreaParking import Ui_CreaParking
|
||||
|
||||
__author__ = 'sidya'
|
||||
|
||||
|
||||
class CreaParking:
|
||||
def __init__(self):
|
||||
self.w = QtGui.QWidget()
|
||||
self.ui = Ui_CreaParking()
|
||||
self.ui.setupUi(self.w)
|
||||
self.w.show()
|
||||
def __init__(self, main):
|
||||
self.__main = main
|
||||
self.__main.activity("Debut Creation Parking", self.__main.lvl.INFO)
|
||||
|
||||
self.__row = 0
|
||||
|
||||
self.__w = MyQWidget(self.__main)
|
||||
self.__ui = Ui_CreaParking()
|
||||
self.__ui.setupUi(self.__w)
|
||||
|
||||
#connect
|
||||
self.__ui.btn_addRow.clicked.connect(self.addRow)
|
||||
self.__ui.btn_rmRow.clicked.connect(self.rmRow)
|
||||
self.__ui.btn_valider.clicked.connect(self.valider)
|
||||
self.__ui.btn_annuler.clicked.connect(self.annuler)
|
||||
|
||||
#Validator
|
||||
self.__ui.lineEdit_nbNiv.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp('[0-9]*')))
|
||||
|
||||
|
||||
self.showWindow()
|
||||
|
||||
|
||||
def insererTable(self,hauteur,longueur,nombre) :
|
||||
self.__typePlacesparNiveau.add(hauteur,longueur,nombre)
|
||||
|
||||
def addRow(self):
|
||||
self.__ui.tableWidget.insertRow(self.__row)
|
||||
self.__row += 1
|
||||
|
||||
def rmRow(self):
|
||||
self.__ui.tableWidget.removeRow(self.__ui.tableWidget.rowCount()-1)
|
||||
self.__row -= 1
|
||||
|
||||
def annuler(self):
|
||||
self.__main.activity("Annulation Creation Parking", self.__main.lvl.INFO)
|
||||
self.__w.hide()
|
||||
self.__main.showWindow()
|
||||
|
||||
def valider(self):
|
||||
try:
|
||||
l = ListeTypePlace()
|
||||
for i in range(0,self.__ui.tableWidget.rowCount()):
|
||||
l.add(int(self.__ui.tableWidget.itemAt(i,0).text()), int(self.__ui.tableWidget.itemAt(i,1).text()),
|
||||
int(self.__ui.tableWidget.itemAt(i,3).text()))
|
||||
self.__main.addParking(Parking(
|
||||
int(self.__ui.lineEdit_nbNiv.text()),
|
||||
l,
|
||||
self.__ui.lineEdit_nom.text()))
|
||||
self.__main.activity("Ajout Parking : detail", self.__main.lvl.INFO)
|
||||
self.__w.hide()
|
||||
self.__main.showWindow()
|
||||
except Exception as e :
|
||||
self.__main.activity("Erreur lors de la creations du Parking \n" + str(e), self.__main.lvl.FAIL)
|
||||
self.annuler()
|
||||
|
||||
def showWindow(self):
|
||||
self.__w.show()
|
||||
self.__child = None #supprime l'eventuel widget enfant
|
||||
self.__w.focusWidget() # reprend le focus sur la fenetre
|
||||
@@ -1,10 +1,14 @@
|
||||
import sys
|
||||
|
||||
from PyQt4 import QtGui
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PyQt4.QtCore import QTranslator, QLocale
|
||||
|
||||
from src.c.log.log import Log
|
||||
from src.c.log.log import lvl
|
||||
|
||||
from src.c.CreaParking import CreaParking
|
||||
from src.c.log.log import Log
|
||||
from src.m.Parking import Parking, ListeTypePlace
|
||||
from src.v.MyQMainWindow import MyQMainWindow
|
||||
from src.v.Ui_MainWindow import Ui_MainWindow
|
||||
|
||||
__author__ = 'sidya'
|
||||
@@ -13,7 +17,8 @@ __author__ = 'sidya'
|
||||
class Main:
|
||||
def __init__(self):
|
||||
# Init des logs
|
||||
self.log = Log()
|
||||
self.lvl = lvl()
|
||||
self.__log = Log()
|
||||
|
||||
l = ListeTypePlace()
|
||||
l.add(10, 11, 5)
|
||||
@@ -27,25 +32,27 @@ class Main:
|
||||
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
self.view = QtGui.QMainWindow()
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self.view)
|
||||
|
||||
|
||||
self.__view = MyQMainWindow()
|
||||
self.__ui = Ui_MainWindow()
|
||||
self.__ui.setupUi(self.__view)
|
||||
|
||||
#connect
|
||||
self.ui.comboBox.currentIndexChanged['QString'].connect(self.selectParking)
|
||||
self.ui.btn_creer.clicked.connect(self.creerParking)
|
||||
self.__ui.comboBox.currentIndexChanged['QString'].connect(self.selectParking)
|
||||
self.__ui.btn_creer.clicked.connect(self.creerParking)
|
||||
|
||||
|
||||
#Chargement activité
|
||||
self.loadLastActivity()
|
||||
self.majListeParking()
|
||||
|
||||
self.view.show()
|
||||
self.showWindow()
|
||||
sys.exit(app.exec_())
|
||||
|
||||
|
||||
def activity(self, msg, lvl):
|
||||
self.log.printL(msg, lvl)
|
||||
self.ui.addItemActivite(self.activite.readlines()[-1])
|
||||
self.__log.printL(msg, lvl)
|
||||
self.addItemActivite(self.activite.readlines()[-1])
|
||||
|
||||
def loadLastActivity(self):
|
||||
try:
|
||||
@@ -57,32 +64,41 @@ class Main:
|
||||
|
||||
liste = self.activite.readlines()
|
||||
for l in [l[:-1] for l in liste[-11:-1]]:
|
||||
self.ui.addItemActivite(l)
|
||||
self.addItemActivite(l)
|
||||
|
||||
|
||||
def addItemActivite(self, line):
|
||||
self.log.addItem(line)
|
||||
self.__ui.listWidget.addItem(line)
|
||||
|
||||
def majListeParking(self):
|
||||
self.ui.comboBox.clear()
|
||||
self.ui.comboBox.addItem("Selectionner un parking")
|
||||
self.__ui.comboBox.clear()
|
||||
self.__ui.comboBox.addItem("Selectionner un parking")
|
||||
for p in self.__parkings:
|
||||
self.ui.comboBox.addItem(p.nom)
|
||||
self.__ui.comboBox.addItem(p.nom)
|
||||
|
||||
def selectParking(self):
|
||||
self.ui.nom.clear()
|
||||
self.ui.niveau.clear()
|
||||
self.ui.placesParNiveau.clear()
|
||||
self.ui.placesDispo.clear()
|
||||
self.ui.placesSuperAbo.clear()
|
||||
if(self.ui.comboBox.currentIndex() != 0) :
|
||||
self.ui.nom.setText(self.__parkings[self.ui.comboBox.currentIndex()-1].nom)
|
||||
self.ui.niveau.setText(str(self.__parkings[self.ui.comboBox.currentIndex()-1].nbNiveau))
|
||||
self.ui.placesParNiveau.setText(str(self.__parkings[self.ui.comboBox.currentIndex()-1].nbPlacesParNiveau))
|
||||
self.ui.placesDispo.setText(str(self.__parkings[self.ui.comboBox.currentIndex()-1].nbPlacesLibresParking))
|
||||
self.ui.placesSuperAbo.setText("lol")
|
||||
self.__ui.nom.clear()
|
||||
self.__ui.niveau.clear()
|
||||
self.__ui.placesParNiveau.clear()
|
||||
self.__ui.placesDispo.clear()
|
||||
self.__ui.placesSuperAbo.clear()
|
||||
if(self.__ui.comboBox.currentIndex() != 0) :
|
||||
self.__ui.nom.setText(self.__parkings[self.__ui.comboBox.currentIndex()-1].nom)
|
||||
self.__ui.niveau.setText(str(self.__parkings[self.__ui.comboBox.currentIndex()-1].nbNiveau))
|
||||
self.__ui.placesParNiveau.setText(str(self.__parkings[self.__ui.comboBox.currentIndex()-1].nbPlacesParNiveau))
|
||||
self.__ui.placesDispo.setText(str(self.__parkings[self.__ui.comboBox.currentIndex()-1].nbPlacesLibresParking))
|
||||
self.__ui.placesSuperAbo.setText("lol")
|
||||
|
||||
|
||||
def creerParking(self):
|
||||
self.view.hide()
|
||||
CreaParking()
|
||||
self.__view.hide()
|
||||
self.__widgetCourant = CreaParking(self)
|
||||
|
||||
def addParking(self,parking):
|
||||
self.__parkings.append(parking)
|
||||
|
||||
def showWindow(self):
|
||||
self.majListeParking()
|
||||
self.__view.show()
|
||||
self.__widgetCourant = None #supprime eventuel widget
|
||||
self.__view.focusWidget() # reprend le focus sur la fenetre principal
|
||||
@@ -82,8 +82,6 @@ class Log(object):
|
||||
pMsg = bcolors.DEBUG + str(pMsg) + bcolors.ENDC
|
||||
elif pLvl == lvl.INFO :
|
||||
pMsg = bcolors.INFO + str(pMsg) + bcolors.ENDC
|
||||
elif pLvl == lvl.SUCCESS :
|
||||
pMsg = bcolors.SUCCESS + str(pMsg) + bcolors.ENDC
|
||||
elif pLvl == lvl.WARNING :
|
||||
pMsg = bcolors.WARNING + str(pMsg) + bcolors.ENDC
|
||||
elif pLvl == lvl.FAIL :
|
||||
|
||||
Reference in New Issue
Block a user