Skip to content

Commit d52f381

Browse files
committed
Release 1.6
- Deleted Keywords will now be kept in the Database, to be still displayed in Presets. - Deleted Keywords will be reenabled in the Database instead of adding them again. - Pressing the Spacebar-Key while a Preset with a Sample Image is selected, display the enlarged display of the Sample Image. - Opening Database Connections using just DB.Connect instead of If DB.Connect. - Missing Keywords in Database, will no longer cause empty spaces followed by a "," anymore.
1 parent 7b3195b commit d52f381

9 files changed

+193
-60
lines changed

Class_Keyword.xojo_code

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Protected Class Class_Keyword
1515
#tag EndMethod
1616

1717
#tag Method, Flags = &h0
18-
Function Delete() As Boolean
18+
Function Disable() As Boolean
1919
If Self.DatabaseID>0 Then
2020

2121
Try
2222

23-
App.SDP_Database.ExecuteSQL("DELETE FROM keyword WHERE id=?",Self.DatabaseID)
24-
App.SDP_Database.ExecuteSQL("DELETE FROM preset_keyword WHERE id_keyword=?", Self.DatabaseID)
23+
App.SDP_Database.ExecuteSQL("UPDATE keyword SET active=0 WHERE id=?",Self.DatabaseID)
24+
// App.SDP_Database.ExecuteSQL("DELETE FROM preset_keyword WHERE id_keyword=?", Self.DatabaseID)
2525

2626
Return True
2727

@@ -107,8 +107,24 @@ Protected Class Class_Keyword
107107
If Self.DatabaseID = 0 Then
108108

109109
#Pragma BreakOnExceptions False
110-
App.SDP_Database.ExecuteSQL("INSERT INTO keyword (id_category,words,weight,negative) VALUES (?,?,?,?)", _
111-
Self.CategoryID,Self.Keyword,Self.Weight,Self.Negative)
110+
111+
Var ExistedBefore As RowSet = App.SDP_Database.SelectSQL("SELECT id FROM keyword WHERE words=?", Self.Keyword)
112+
113+
If ExistedBefore <> Nil And Not ExistedBefore.AfterLastRow Then
114+
115+
If ExistedBefore.Column("id").IntegerValue > 0 Then
116+
117+
App.SDP_Database.ExecuteSQL("UPDATE keyword SET active=1,weight=?,negative=? WHERE words=?",Self.Weight,Self.Negative,Self.Keyword)
118+
119+
Else
120+
121+
App.SDP_Database.ExecuteSQL("INSERT INTO keyword (id_category,words,weight,negative) VALUES (?,?,?,?)", _
122+
Self.CategoryID,Self.Keyword,Self.Weight,Self.Negative)
123+
124+
End If
125+
126+
End If
127+
112128
#Pragma BreakOnExceptions True
113129
Else
114130

Class_Model.xojo_code

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Protected Class Class_Model
4343
#tag EndMethod
4444

4545
#tag Method, Flags = &h0
46-
Sub Save()
46+
Function Save() As Boolean
4747
Try
4848

4949
#Pragma BreakOnExceptions False
@@ -61,11 +61,14 @@ Protected Class Class_Model
6161
Else
6262

6363
System.Log(System.LogLevelError, CurrentMethodName + " - Error Code: " + err.ErrorNumber.ToString + EndOfLine + "Error Message: " + err.Message)
64+
Return False
6465

6566
End If
6667

6768
End Try
68-
End Sub
69+
70+
Return True
71+
End Function
6972
#tag EndMethod
7073

7174
#tag Method, Flags = &h0
@@ -151,22 +154,30 @@ Protected Class Class_Model
151154
Group="Behavior"
152155
InitialValue=""
153156
Type="String"
154-
EditorType=""
157+
EditorType="MultiLineEditor"
155158
#tag EndViewProperty
156159
#tag ViewProperty
157160
Name="NegativePrompt"
158161
Visible=false
159162
Group="Behavior"
160163
InitialValue=""
161164
Type="String"
162-
EditorType=""
165+
EditorType="MultiLineEditor"
163166
#tag EndViewProperty
164167
#tag ViewProperty
165168
Name="Note"
166169
Visible=false
167170
Group="Behavior"
168171
InitialValue=""
169172
Type="String"
173+
EditorType="MultiLineEditor"
174+
#tag EndViewProperty
175+
#tag ViewProperty
176+
Name="DatabaseID"
177+
Visible=false
178+
Group="Behavior"
179+
InitialValue="0"
180+
Type="Integer"
170181
EditorType=""
171182
#tag EndViewProperty
172183
#tag EndViewBehavior

Class_Preset.xojo_code

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ Protected Class Class_Preset
214214

215215
Else
216216

217-
Prompt(0) = Prompt(0) + KW.Keyword + ", "
217+
If KW.Keyword.Trim <> "" Then
218+
219+
Prompt(0) = Prompt(0) + KW.Keyword + ", "
220+
221+
End If
218222

219223
End If
220224

Container_Keyword.xojo_window

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,15 @@ End
489489
RS = App.SDP_Database.SelectSQL("SELECT keyword.id,keyword.words,category.label,keyword.negative,keyword.weight " + _
490490
"FROM category " + _
491491
"INNER Join keyword ON category.id = keyword.id_category " + _
492+
"WHERE active=1 " + _
492493
"ORDER BY keyword.negative,keyword.words")
493494

494495
Else
495496

496497
RS = App.SDP_Database.SelectSQL("SELECT keyword.id,keyword.words,category.label,keyword.negative,keyword.weight " + _
497498
"FROM category " + _
498499
"INNER Join keyword ON category.id = keyword.id_category " + _
499-
"WHERE id_category=? " + _
500+
"WHERE active=1 AND id_category=? " + _
500501
"ORDER BY keyword.negative,keyword.words", PopupMenu_Category.RowTagAt(PopupMenu_Category.SelectedRowIndex).IntegerValue)
501502

502503
End If
@@ -511,15 +512,15 @@ End
511512
RS = App.SDP_Database.SelectSQL("SELECT keyword.id,keyword.words,category.label,keyword.negative,keyword.weight " + _
512513
"FROM category " + _
513514
"INNER Join keyword ON category.id = keyword.id_category " + _
514-
"WHERE keyword.words LIKE ? " + _
515+
"WHERE active=1 AND keyword.words LIKE ? " + _
515516
"ORDER BY keyword.negative,keyword.words", Filter)
516517

517518
Else
518519

519520
RS = App.SDP_Database.SelectSQL("SELECT keyword.id,keyword.words,category.label,keyword.negative,keyword.weight " + _
520521
"FROM category " + _
521522
"INNER Join keyword ON category.id = keyword.id_category " + _
522-
"WHERE keyword.words LIKE ? AND id_category=? " + _
523+
"WHERE active=1 AND keyword.words LIKE ? AND id_category=? " + _
523524
"ORDER BY keyword.negative,keyword.words", Filter, PopupMenu_Category.RowTagAt(PopupMenu_Category.SelectedRowIndex).IntegerValue)
524525

525526
End If
@@ -676,7 +677,7 @@ End
676677
#tag EndMethod
677678

678679
#tag Method, Flags = &h0
679-
Sub Keyword_Delete()
680+
Sub Keyword_Disable()
680681
If ListBox_PromptWords.SelectedRowIndex = -1 Then Return
681682

682683
If ListBox_PromptWords.SelectedRowCount>1 Then
@@ -699,7 +700,7 @@ End
699700
Var KW As New Class_Keyword(ListBox_PromptWords.RowTagAt(X).IntegerValue)
700701

701702
CurrentPreset.Keyword_Remove(KW)
702-
Call KW.Delete
703+
Call KW.Disable
703704

704705
End If
705706

@@ -766,7 +767,7 @@ End
766767
#tag Events PushButton_Delete_Keyword
767768
#tag Event
768769
Sub Action()
769-
Keyword_Delete
770+
Keyword_Disable
770771
End Sub
771772
#tag EndEvent
772773
#tag EndEvents
@@ -850,7 +851,7 @@ End
850851

851852
Case "Delete Keyword"
852853

853-
Keyword_Delete
854+
Keyword_Disable
854855

855856
End Select
856857
End Function

Container_Preset.xojo_window

Lines changed: 86 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Begin DesktopContainer Container_Preset
9090
Text = ""
9191
TextAlignment = 0
9292
TextColor = &c000000
93-
Tooltip = "Save your current selection of keywords, your example image and your model settings as a preset under a freely selectable name. If you selected a preset from the list below and do not change the name, the selected preset will be updated with your current settings."
93+
Tooltip = "A name for your current selection of keywords, your example image and your model settings.\n\nIf you selected a preset from the list below and do not change the name, saving the selected preset will update it with your current settings.\n\nPress Enter or the Save Button, to save your current Preset."
9494
Top = 0
9595
Transparent = False
9696
Underline = False
@@ -104,7 +104,7 @@ Begin DesktopContainer Container_Preset
104104
Cancel = False
105105
Caption = "💾"
106106
Default = False
107-
Enabled = True
107+
Enabled = False
108108
FontName = "System"
109109
FontSize = 0.0
110110
FontUnit = 0
@@ -123,7 +123,7 @@ Begin DesktopContainer Container_Preset
123123
TabIndex = 2
124124
TabPanelIndex = 0
125125
TabStop = True
126-
Tooltip = "Save the currently selected keywords as a new preset under the name entered on the left.\r\n\r\nIf you change the name shown at left of a previously selected preset, the preset will be saved as a new preset with the new name."
126+
Tooltip = "Save the currently selected keywords as a preset labeled using the name entered in the Textfield to the left.\n\nIf you selected a preset from the list below and do not change the name, saving the selected preset will update it with your current settings."
127127
Top = 0
128128
Transparent = False
129129
Underline = False
@@ -136,7 +136,7 @@ Begin DesktopContainer Container_Preset
136136
Cancel = False
137137
Caption = "🗑️"
138138
Default = False
139-
Enabled = True
139+
Enabled = False
140140
FontName = "System"
141141
FontSize = 0.0
142142
FontUnit = 0
@@ -155,7 +155,7 @@ Begin DesktopContainer Container_Preset
155155
TabIndex = 3
156156
TabPanelIndex = 0
157157
TabStop = True
158-
Tooltip = "Delete the current preset."
158+
Tooltip = "Delete the currently selected presets."
159159
Top = 0
160160
Transparent = False
161161
Underline = False
@@ -197,12 +197,12 @@ Begin DesktopContainer Container_Preset
197197
LockTop = True
198198
NegativeColumn = 3
199199
RequiresSelection= True
200-
RowSelectionType= 0
200+
RowSelectionType= 1
201201
Scope = 2
202202
TabIndex = 4
203203
TabPanelIndex = 0
204204
TabStop = True
205-
Tooltip = ""
205+
Tooltip = "Press the SPACE-Key to enlarge the example image.\n\nSelect one or more Presets and click the Trashcan Button to delete selected Presets."
206206
Top = 34
207207
Transparent = False
208208
Underline = False
@@ -728,20 +728,29 @@ End
728728
Sub Preset_Delete()
729729
If ListBox_Presets.SelectedRowIndex=-1 Then Return
730730

731-
If Show_MessageDialog(MessageDialog.IconTypes.Caution, "Delete Preset", "Cancel", "Delete Preset", _
732-
"Are you sure you want to delete the Preset named " + ListBox_Presets.SelectedRowValue + " ?") Then
733-
734-
Var PS As New Class_Preset(ListBox_Presets.RowTagAt(ListBox_Presets.SelectedRowIndex).IntegerValue)
731+
If Show_MessageDialog(MessageDialog.IconTypes.Caution, "Delete Preset(s)", "Cancel", "Delete Preset(s)", _
732+
"Are you sure you want to delete the selected Preset(s)?") Then
735733

736734
Var SelectedRowIndex As Integer = ListBox_Presets.SelectedRowIndex
737-
If PS.Delete Then
738-
739-
CurrentPreset.Sample = Nil
740-
Canvas_Sample.Refresh
735+
736+
For X As Integer = ListBox_Presets.LastRowIndex DownTo 0
741737

742-
Presets_List
738+
If ListBox_Presets.RowSelectedAt(X) Then
739+
740+
Var PS As New Class_Preset(ListBox_Presets.RowTagAt(X).IntegerValue)
741+
If PS.Delete Then
742+
743+
CurrentPreset.Sample = Nil
744+
Canvas_Sample.Refresh
745+
746+
End If
747+
748+
End If
743749

744-
End If
750+
Next
751+
752+
Presets_List
753+
745754
If SelectedRowIndex<ListBox_Presets.RowCount Then ListBox_Presets.SelectedRowIndex=SelectedRowIndex
746755

747756
End If
@@ -801,11 +810,22 @@ End
801810
#tag Event
802811
Sub TextChanged()
803812
If Not Me.Enabled Then Return
804-
805813
CurrentPreset.Label = Me.Text.Trim
814+
PushButton_Save_Preset.Enabled = Me.Text <> ""
815+
806816
CurrentPreset.DatabaseID=0
807817
End Sub
808818
#tag EndEvent
819+
#tag Event
820+
Function KeyDown(key As String) As Boolean
821+
If key.Asc = 13 Then // Enter Key
822+
823+
Preset_Save
824+
Me.SetFocus
825+
826+
End If
827+
End Function
828+
#tag EndEvent
809829
#tag EndEvents
810830
#tag Events PushButton_Save_Preset
811831
#tag Event
@@ -824,7 +844,9 @@ End
824844
#tag Events ListBox_Presets
825845
#tag Event
826846
Sub SelectionChanged()
847+
PushButton_Delete_Preset.Enabled = Me.SelectedRowIndex <> DesktopListBox.NoSelection
827848
If Me.SelectedRowIndex=-1 Then Return
849+
PushButton_Save_Preset.Enabled = Me.SelectedRowCount = 1
828850

829851
Preset_Load(Me.RowTagAt(Me.SelectedRowIndex))
830852
End Sub
@@ -841,6 +863,52 @@ End
841863
Me.Tooltip = Me.CellTextAt(row,0)
842864
End Sub
843865
#tag EndEvent
866+
#tag Event
867+
Function KeyDown(key As String) As Boolean
868+
If Me.SelectedRowIndex = DesktopListBox.NoSelection Then Return False
869+
870+
// Var isShown As Boolean
871+
// For i As Integer = 0 To WindowCount-1
872+
// If Window(i) IsA Window_PresetSample Then
873+
// isShown = True
874+
// Exit
875+
// End
876+
// Next
877+
878+
Select Case key.Asc
879+
880+
Case 30 // Cursor Up
881+
882+
// If isShown Then
883+
//
884+
// Window_PresetSample.PresetSample = CurrentPreset.Sample
885+
// Window_PresetSample.Refresh
886+
//
887+
// End If
888+
889+
Case 31 // Cursor Down
890+
891+
// If isShown Then
892+
//
893+
// Window_PresetSample.PresetSample = CurrentPreset.Sample
894+
// Window_PresetSample.Refresh
895+
//
896+
// End If
897+
898+
Case 32 // Spacebar
899+
900+
If CurrentPreset.Sample<>Nil Then
901+
902+
Window_PresetSample.Show
903+
Window_PresetSample.PresetSample = CurrentPreset.Sample
904+
905+
End If
906+
907+
Return True
908+
909+
End Select
910+
End Function
911+
#tag EndEvent
844912
#tag EndEvents
845913
#tag Events TabPanel_Preset
846914
#tag Event

0 commit comments

Comments
 (0)