-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the comparison outcome logic to not allow the user to consolidate the same node multiple times.
- Loading branch information
Showing
7 changed files
with
132 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from typing import Literal | ||
|
||
from PyQt5.QtWidgets import QMessageBox | ||
from .model.network import Node | ||
|
||
|
||
def show_node_consolidation_warning( | ||
a_or_b: Literal["A", "B"], node: Node, other_node: Node | ||
) -> bool: | ||
""" | ||
This is a popup warning box shown to users when they try to consolidate a node that | ||
has already been consolidated in a different comparison. | ||
Returns True/False, True if the user clicks OK, False if Cancel. | ||
This totally breaks the MVVM / MVC pattern we're using, but it works. | ||
""" | ||
user_says_ok = False | ||
|
||
msg = QMessageBox() | ||
msg.setModal(True) | ||
msg.setIcon(QMessageBox.Icon.Question) | ||
msg.setWindowTitle(f"Node {a_or_b} {node.name} already consolidated") | ||
msg.setInformativeText( | ||
( | ||
f"The node {a_or_b} {node.name} (id = {node.id}" | ||
+ " has already been marked as the same as another node" | ||
+ f" {other_node.name} (id = {other_node.id})).\n" | ||
+ f" Are you sure you want to mark node {a_or_b} {node.name} " | ||
+ f" (id = {node.id}) as the same here instead?" | ||
) | ||
) | ||
msg.setStandardButtons( | ||
QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel | ||
) | ||
|
||
def _btn_clicked(btn): | ||
nonlocal user_says_ok | ||
if btn.text() == "OK": | ||
user_says_ok = True | ||
else: | ||
user_says_ok = False | ||
|
||
msg.buttonClicked.connect(_btn_clicked) | ||
|
||
msg.exec_() | ||
|
||
return user_says_ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters