add exception column in database
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
script = ExtResource("2_q3ll5")
|
||||
element_scene = ExtResource("2_4jv4m")
|
||||
|
||||
[node name="Word" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="1"]
|
||||
[node name="Word" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="2"]
|
||||
visible = false
|
||||
text = "Sentence"
|
||||
|
||||
[node name="Graphemes" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="2"]
|
||||
[node name="Graphemes" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="3"]
|
||||
text = "Words"
|
||||
|
||||
[node name="Label" parent="NewGPLayer" index="1"]
|
||||
@@ -43,13 +43,13 @@ grow_vertical = 2
|
||||
layout_mode = 2
|
||||
script = null
|
||||
|
||||
[node name="Word" parent="NewGPLayer/VBoxContainer2/Title/TabContainer/NormalContainer" index="1"]
|
||||
[node name="Word" parent="NewGPLayer/VBoxContainer2/Title/TabContainer/NormalContainer" index="2"]
|
||||
text = "Word"
|
||||
|
||||
[node name="Graphemes" parent="NewGPLayer/VBoxContainer2/Title/TabContainer/NormalContainer" index="2"]
|
||||
[node name="Graphemes" parent="NewGPLayer/VBoxContainer2/Title/TabContainer/NormalContainer" index="3"]
|
||||
text = "Graphemes"
|
||||
|
||||
[node name="EditButton" parent="NewGPLayer/VBoxContainer2/Title/TabContainer/NormalContainer" index="3"]
|
||||
[node name="EditButton" parent="NewGPLayer/VBoxContainer2/Title/TabContainer/NormalContainer" index="4"]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
|
||||
[node name="NewGP" parent="NewGPLayer/VBoxContainer2" index="1" instance=ExtResource("3_jl0ks")]
|
||||
|
||||
@@ -2,6 +2,8 @@ extends "res://sources/language_tool/word_list_element.gd"
|
||||
|
||||
const word_list_element_scene: = preload("res://sources/language_tool/word_list_element.tscn")
|
||||
|
||||
var words_not_founds: = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
super()
|
||||
@@ -23,12 +25,14 @@ func _add_from_additional_word_list(new_text: String) -> int:
|
||||
new_text_clean = new_text_clean.replace(char, " ")
|
||||
var word_list_element: = word_list_element_scene.instantiate()
|
||||
var all_found: = true
|
||||
words_not_founds.clear()
|
||||
var word_ids: Array[int] = []
|
||||
for word in new_text_clean.split(" ", false):
|
||||
var word_id: int = word_list_element._try_to_complete_from_word(word)
|
||||
word_ids.append(word_id)
|
||||
if word_id < 0:
|
||||
all_found = false
|
||||
words_not_founds.append(word)
|
||||
word_list_element.free()
|
||||
if all_found:
|
||||
gp_ids = word_ids
|
||||
@@ -47,4 +51,8 @@ func _add_from_additional_word_list(new_text: String) -> int:
|
||||
Position = i
|
||||
})
|
||||
return id
|
||||
graphemes_edit.text = ""
|
||||
graphemes_edit.placeholder_text = "Not found:"
|
||||
for word_not_found in words_not_founds:
|
||||
graphemes_edit.placeholder_text += " " + word_not_found
|
||||
return -1
|
||||
|
||||
@@ -13,15 +13,21 @@ sub_table_phon_column = "Word"
|
||||
relational_table = "WordsInSentences"
|
||||
sub_table_id = "WordID"
|
||||
|
||||
[node name="Word" parent="TabContainer/NormalContainer" index="1"]
|
||||
[node name="ExceptionCheckBox" parent="TabContainer/NormalContainer" index="1"]
|
||||
visible = false
|
||||
|
||||
[node name="Word" parent="TabContainer/NormalContainer" index="2"]
|
||||
size_flags_vertical = 1
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="WordEdit" parent="TabContainer/EditContainer" index="1"]
|
||||
[node name="ExceptionEditCheckBox" parent="TabContainer/EditContainer" index="1"]
|
||||
visible = false
|
||||
|
||||
[node name="WordEdit" parent="TabContainer/EditContainer" index="2"]
|
||||
placeholder_text = "Press enter for autocomplete"
|
||||
|
||||
[node name="GraphemesEdit" parent="TabContainer/EditContainer" index="2"]
|
||||
[node name="GraphemesEdit" parent="TabContainer/EditContainer" index="3"]
|
||||
placeholder_text = "Each word in the sentence"
|
||||
|
||||
[editable path="TabContainer/NormalContainer/EditButton"]
|
||||
|
||||
@@ -26,6 +26,7 @@ func _ready() -> void:
|
||||
element.graphemes = e[_e.sub_table_graph_column + "s"]
|
||||
element.phonemes = e[_e.sub_table_phon_column + "s"]
|
||||
element.id = e[_e.table_graph_column + "Id"]
|
||||
element.exception = e.Exception
|
||||
element.set_gp_ids_from_string(e[_e.sub_table_id + "s"])
|
||||
elements_container.add_child(element)
|
||||
element.undo_redo = undo_redo
|
||||
@@ -35,14 +36,14 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _get_query() -> String:
|
||||
return "SELECT %s.ID as %sId, %s, group_concat(%s, ' ') as %ss, group_concat(%s, ' ') as %ss, group_concat(%s.ID, ' ') as %ss
|
||||
return "SELECT %s.ID as %sId, %s, group_concat(%s, ' ') as %ss, group_concat(%s, ' ') as %ss, group_concat(%s.ID, ' ') as %ss, %s.Exception
|
||||
FROM %s
|
||||
INNER JOIN ( SELECT * FROM %s ORDER BY %s.Position ) %s ON %s.ID = %s.%sID
|
||||
INNER JOIN %s ON %s.ID = %s.%s
|
||||
GROUP BY %s.ID" % [_e.table, _e.table_graph_column,
|
||||
_e.table_graph_column, _e.sub_table_graph_column, _e.sub_table_graph_column,
|
||||
_e.sub_table_phon_column, _e.sub_table_phon_column,
|
||||
_e.sub_table, _e.sub_table_id,
|
||||
_e.sub_table, _e.sub_table_id, _e.table,
|
||||
_e.table,
|
||||
_e.relational_table, _e.relational_table, _e.relational_table, _e.table, _e.relational_table, _e.table_graph_column,
|
||||
_e.sub_table, _e.sub_table, _e.relational_table, _e.sub_table_id,
|
||||
|
||||
@@ -33,13 +33,16 @@ script = null
|
||||
text = "Lesson"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Word" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="1"]
|
||||
[node name="ExceptionCheckBox" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="1"]
|
||||
visible = false
|
||||
|
||||
[node name="Word" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="2"]
|
||||
text = "Word"
|
||||
|
||||
[node name="Graphemes" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="2"]
|
||||
[node name="Graphemes" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="3"]
|
||||
text = "Graphemes"
|
||||
|
||||
[node name="EditButton" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="3"]
|
||||
[node name="EditButton" parent="VBoxContainer/WordListElement/TabContainer/NormalContainer" index="4"]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/WordListElement"]
|
||||
|
||||
@@ -19,6 +19,8 @@ signal validated()
|
||||
@onready var tab_container: = $TabContainer
|
||||
@onready var popup_menu: = %Popup
|
||||
@onready var lesson_label: = %Lesson
|
||||
@onready var exception_checkbox: = %ExceptionCheckBox
|
||||
@onready var exception_edit_checkbox: = %ExceptionEditCheckBox
|
||||
|
||||
var word: = "":
|
||||
set = set_word
|
||||
@@ -39,6 +41,16 @@ var prev_caret_position: int = 0
|
||||
var unvalidated_graphemes: = ""
|
||||
var unvalidated_phonemes: = ""
|
||||
var unvalidated_gp_ids: Array[int] = []
|
||||
var exception: = 0:
|
||||
set = set_exception
|
||||
|
||||
|
||||
func set_exception(p_exception: bool) -> void:
|
||||
exception = p_exception
|
||||
if exception_checkbox:
|
||||
exception_checkbox.button_pressed = bool(exception)
|
||||
if exception_edit_checkbox:
|
||||
exception_edit_checkbox.button_pressed = bool(exception)
|
||||
|
||||
|
||||
func set_word(p_word: String) -> void:
|
||||
@@ -87,6 +99,7 @@ func _ready() -> void:
|
||||
set_word(word)
|
||||
set_graphemes(graphemes)
|
||||
set_lesson(lesson)
|
||||
set_exception(exception)
|
||||
popup_menu.button.text = "Add new %s" % sub_table
|
||||
|
||||
|
||||
@@ -109,10 +122,12 @@ func _on_validate_button_pressed() -> void:
|
||||
undo_redo.add_do_property(self, "phonemes", unvalidated_phonemes)
|
||||
undo_redo.add_do_property(self, "gp_ids", unvalidated_gp_ids.duplicate())
|
||||
undo_redo.add_do_property(self, "word", word_edit.text)
|
||||
undo_redo.add_do_property(self, "exception", int(exception_edit_checkbox.button_pressed))
|
||||
undo_redo.add_undo_property(self, "graphemes", graphemes)
|
||||
undo_redo.add_undo_property(self, "phonemes", phonemes)
|
||||
undo_redo.add_undo_property(self, "gp_ids", gp_ids.duplicate())
|
||||
undo_redo.add_undo_property(self, "word", word)
|
||||
undo_redo.add_undo_property(self, "exception", int(exception_checkbox.button_pressed))
|
||||
undo_redo.commit_action()
|
||||
tab_container.current_tab = 0
|
||||
update_lesson()
|
||||
@@ -228,14 +243,14 @@ func set_gp_ids_from_string(p_gp_ids: String) -> void:
|
||||
|
||||
func insert_in_database() -> void:
|
||||
if id >= 0:
|
||||
var query: = "SELECT %s, group_concat(%s, ' ') as %ss, group_concat(%s, ' ') as %ss, group_concat(%s.ID, ' ') as %sIDs
|
||||
var query: = "SELECT %s, group_concat(%s, ' ') as %ss, group_concat(%s, ' ') as %ss, group_concat(%s.ID, ' ') as %sIDs, %s.Exception
|
||||
FROM %s
|
||||
INNER JOIN ( SELECT * FROM %s ORDER BY %s.Position ) %s ON %s.ID = %s.%sID
|
||||
INNER JOIN %s ON %s.ID = %s.%s
|
||||
WHERE %s.ID = ?
|
||||
GROUP BY %s.ID" % [table_graph_column, sub_table_graph_column, sub_table_graph_column,
|
||||
sub_table_phon_column, sub_table_phon_column,
|
||||
relational_table, relational_table,
|
||||
relational_table, relational_table, table,
|
||||
table,
|
||||
relational_table, relational_table, relational_table, table, relational_table, table_graph_column,
|
||||
sub_table, sub_table, relational_table, sub_table_id,
|
||||
@@ -245,8 +260,8 @@ func insert_in_database() -> void:
|
||||
print(query)
|
||||
if not Database.db.query_result.is_empty():
|
||||
var e = Database.db.query_result[0]
|
||||
if word != e[table_graph_column]:
|
||||
Database.db.update_rows(table, "ID=%s" % id, {table_graph_column: word})
|
||||
if word != e[table_graph_column] or exception != e.Exception:
|
||||
Database.db.update_rows(table, "ID=%s" % id, {table_graph_column: word, "Exception": exception})
|
||||
if graphemes != e[sub_table_graph_column + "s"] or phonemes != e[sub_table_phon_column + "s"]:
|
||||
var gps_in_words_ids: Array = Array(e[relational_table + "IDs"].split(" "))
|
||||
while gps_in_words_ids.size() > gp_ids.size():
|
||||
@@ -331,3 +346,7 @@ func _on_word_edit_text_submitted(new_text: String) -> void:
|
||||
update_lesson()
|
||||
|
||||
graphemes_edit.grab_focus()
|
||||
|
||||
|
||||
func _on_exception_check_box_toggled(toggled_on: bool) -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
@@ -48,6 +48,14 @@ text = "7"
|
||||
horizontal_alignment = 1
|
||||
clip_text = true
|
||||
|
||||
[node name="ExceptionCheckBox" type="CheckBox" parent="TabContainer/NormalContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 50
|
||||
disabled = true
|
||||
text = "Exception"
|
||||
expand_icon = true
|
||||
|
||||
[node name="Word" type="Label" parent="TabContainer/NormalContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
@@ -83,6 +91,13 @@ layout_mode = 2
|
||||
[node name="TextureRect" parent="TabContainer/EditContainer/MinusButton" index="0"]
|
||||
texture = ExtResource("3_mgblq")
|
||||
|
||||
[node name="ExceptionEditCheckBox" type="CheckBox" parent="TabContainer/EditContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 50
|
||||
text = "Exception"
|
||||
expand_icon = true
|
||||
|
||||
[node name="WordEdit" type="LineEdit" parent="TabContainer/EditContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
Reference in New Issue
Block a user