|
|
@@ -13,14 +13,12 @@ from PyQt5.Qt import Qt, QEvent, QGraphicsScene, QPointF, QFileDialog, \
|
|
|
from PyQt5.QtWidgets import QMainWindow, QGraphicsView
|
|
|
from path import Path
|
|
|
|
|
|
-from core import Mention
|
|
|
import core
|
|
|
|
|
|
|
|
|
Ui_window, _ = uic.loadUiType(Path(__file__).parent / 'qt_viewer.ui')
|
|
|
Ui_details, _ = uic.loadUiType(Path(__file__).parent / 'qt_details.ui')
|
|
|
Ui_select, _ = uic.loadUiType(Path(__file__).parent / 'qt_select_object.ui')
|
|
|
-Ui_warning, _ = uic.loadUiType(Path(__file__).parent / 'qt_warning.ui')
|
|
|
|
|
|
palette = {
|
|
|
"Table": QColor(240, 240, 20),
|
|
|
@@ -406,15 +404,6 @@ class Viewer(QMainWindow):
|
|
|
self.ui.txtPanel.clear()
|
|
|
self.load()
|
|
|
|
|
|
- duplicates = core.Analyse.duplicates()
|
|
|
- if duplicates:
|
|
|
- msg = "Les noms d'objets suivants sont utilisés simultanément par plusieurs objets:\n"
|
|
|
- msg += "\n".join(["- {} ({})".format(key, ", ".join([obj.type_ for obj in val])) for key, val in duplicates.items()])
|
|
|
- msg += "\n Veuillez corriger manuellement les rélérences des objets succeptibles de contenir des erreurs."
|
|
|
- dlg = WarningDialog(msg, parent=self)
|
|
|
- dlg.show()
|
|
|
- dlg.exec_()
|
|
|
-
|
|
|
QMessageBox.information(self, "Analyse", "Analyse terminée: {} objets chargés en mémoire".format(len(core.Analyse.objects)))
|
|
|
|
|
|
def load(self):
|
|
|
@@ -435,7 +424,7 @@ class Viewer(QMainWindow):
|
|
|
topitem.addChild(item)
|
|
|
|
|
|
item = QTreeWidgetItem()
|
|
|
- if any(m.warning for m in obj.mentions):
|
|
|
+ if any(len(m.warnings) > 0 for m in obj.mentions):
|
|
|
item.setIcon(0, QIcon(QPixmap(core.here / "rsc\\warning_16.png")))
|
|
|
item.setText(1, obj.name_)
|
|
|
item.setData(2, 0, index)
|
|
|
@@ -552,7 +541,7 @@ class Viewer(QMainWindow):
|
|
|
if r:
|
|
|
core.Analyse.build_trees()
|
|
|
self.maj_view_with(obj)
|
|
|
- if any(m.warning for m in obj.mentions):
|
|
|
+ if any(len(m.warnings) > 0 for m in obj.mentions):
|
|
|
self.ui.treeWidget.currentItem().setIcon(0, QIcon(QPixmap(core.here / "rsc\\warning_16.png")))
|
|
|
else:
|
|
|
self.ui.treeWidget.currentItem().setIcon(0, QIcon())
|
|
|
@@ -582,7 +571,8 @@ class DetailsDialog(QDialog):
|
|
|
self.ui = Ui_details()
|
|
|
self.ui.setupUi(self)
|
|
|
|
|
|
- self.ui.tbl_mentions.verticalHeader().sectionClicked.connect(self.verticalHeaderClicked)
|
|
|
+ self.ui.tbl_mentions.verticalHeader().sectionDoubleClicked.connect(self.verticalHeaderDoubleClicked)
|
|
|
+
|
|
|
self.ui.tbl_mentions.itemClicked.connect(self.itemClicked)
|
|
|
self.ui.btn_add.clicked.connect(self.add_mention)
|
|
|
self.ui.btn_edit.clicked.connect(self.edit_mention)
|
|
|
@@ -606,9 +596,9 @@ class DetailsDialog(QDialog):
|
|
|
for index, mention in enumerate(self.obj.mentions):
|
|
|
|
|
|
item = QTableWidgetItem("")
|
|
|
- if mention.warning:
|
|
|
+ if len(mention.warnings) > 0:
|
|
|
item.setIcon(QIcon(QPixmap(core.here / "rsc\\warning_16.png")))
|
|
|
- item.setToolTip(mention.warning)
|
|
|
+ item.setToolTip("\n".join([w.text for w in mention.warnings]) + "\n\nDoucle-cliquer pour supprimer l'avertissement.")
|
|
|
self.ui.tbl_mentions.setVerticalHeaderItem(index, item)
|
|
|
|
|
|
item = QTableWidgetItem("")
|
|
|
@@ -634,13 +624,13 @@ class DetailsDialog(QDialog):
|
|
|
self.ui.btn_edit.setEnabled(True)
|
|
|
self.ui.btn_del.setEnabled(True)
|
|
|
|
|
|
- def verticalHeaderClicked(self, row):
|
|
|
+ def verticalHeaderDoubleClicked(self, row):
|
|
|
index = self.ui.tbl_mentions.item(row, 0).data(0)
|
|
|
mention = self.obj.mentions[index]
|
|
|
- if mention.warning:
|
|
|
+ if mention.warnings:
|
|
|
if QMessageBox.question(self, "Confirmation", "Voulez-vous supprimer cet avertissement?") == QMessageBox.Yes:
|
|
|
- mention.warning = ""
|
|
|
- self.ui.tbl_mentions.setVerticalHeaderItem(row, QTableWidgetItem(""))
|
|
|
+ del mention.warnings[:]
|
|
|
+ self.ui.tbl_mentions.verticalHeaderItem(row).setIcon(QIcon())
|
|
|
|
|
|
def add_mention(self):
|
|
|
dlg = ObjectSelectorDialog(parent=self)
|
|
|
@@ -648,7 +638,7 @@ class DetailsDialog(QDialog):
|
|
|
r = dlg.exec_()
|
|
|
if not r:
|
|
|
return
|
|
|
- mention = Mention(0, dlg.obj.name_, "(ajouté manuellement)", dlg.obj)
|
|
|
+ mention = core.Mention(0, dlg.obj.name_, "(ajouté manuellement)", dlg.obj)
|
|
|
|
|
|
linenum, _ = QInputDialog.getInt(self, "Ligne", "Numéro de ligne correspondant dans le code-source? (facultatif)", 0)
|
|
|
if linenum > 0:
|
|
|
@@ -747,16 +737,4 @@ class ObjectSelectorDialog(QDialog):
|
|
|
def done(self, status):
|
|
|
if not status:
|
|
|
self.obj = None
|
|
|
- super(ObjectSelectorDialog, self).done(status)
|
|
|
-
|
|
|
-
|
|
|
-class WarningDialog(QDialog):
|
|
|
-
|
|
|
- def __init__(self, msg="", parent=None):
|
|
|
- super (WarningDialog, self).__init__(parent)
|
|
|
- self.createWidgets()
|
|
|
- self.ui.displayText.setPlainText(msg)
|
|
|
-
|
|
|
- def createWidgets(self):
|
|
|
- self.ui = Ui_warning()
|
|
|
- self.ui.setupUi(self)
|
|
|
+ super(ObjectSelectorDialog, self).done(status)
|