mirror of https://gitlab.com/basile.b/dexed.git
prevent category change if mod neither accepted nor canceled.
This commit is contained in:
parent
d4e484da3b
commit
2a0a3a9f91
|
@ -35,12 +35,13 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
|
|||
Width = 140
|
||||
Align = alLeft
|
||||
AutoExpand = True
|
||||
DefaultItemHeight = 16
|
||||
DefaultItemHeight = 18
|
||||
HideSelection = False
|
||||
ReadOnly = True
|
||||
ScrollBars = ssAutoBoth
|
||||
SortType = stText
|
||||
TabOrder = 0
|
||||
OnChanging = selCatChanging
|
||||
OnDeletion = selCatDeletion
|
||||
OnSelectionChanged = selCatSelectionChanged
|
||||
Options = [tvoAutoExpand, tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
|
@ -94,7 +95,7 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
|
|||
object btnCancel: TSpeedButton
|
||||
Left = 484
|
||||
Height = 24
|
||||
Hint = 'cancel and revert modifications'
|
||||
Hint = 'cancel and revert the modifications of the category'
|
||||
Top = 3
|
||||
Width = 30
|
||||
Align = alRight
|
||||
|
@ -105,7 +106,7 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
|
|||
object btnAccept: TSpeedButton
|
||||
Left = 518
|
||||
Height = 24
|
||||
Hint = 'accept modifications'
|
||||
Hint = 'accept the modifications of the category'
|
||||
Top = 3
|
||||
Width = 30
|
||||
Align = alRight
|
||||
|
|
|
@ -36,11 +36,14 @@ type
|
|||
procedure inspectorEditorFilter(Sender: TObject; aEditor: TPropertyEditor;
|
||||
var aShow: boolean);
|
||||
procedure inspectorModified(Sender: TObject);
|
||||
procedure selCatChanging(Sender: TObject; Node: TTreeNode;
|
||||
var AllowChange: Boolean);
|
||||
procedure selCatDeletion(Sender: TObject; Node: TTreeNode);
|
||||
procedure selCatSelectionChanged(Sender: TObject);
|
||||
protected
|
||||
procedure UpdateShowing; override;
|
||||
private
|
||||
fCatChanged: boolean;
|
||||
fEdOptsSubj: TCEEditableOptionsSubject;
|
||||
procedure updateCategories;
|
||||
function sortCategories(Cat1, Cat2: TTreeNode): integer;
|
||||
|
@ -76,6 +79,7 @@ end;
|
|||
|
||||
destructor TCEOptionEditorWidget.destroy;
|
||||
begin
|
||||
fCatChanged := false;
|
||||
fEdOptsSubj.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
@ -119,12 +123,28 @@ begin
|
|||
Dispose(PCategoryData(node.Data));
|
||||
end;
|
||||
|
||||
procedure TCEOptionEditorWidget.selCatChanging(Sender: TObject;
|
||||
Node: TTreeNode; var AllowChange: Boolean);
|
||||
begin
|
||||
if selCat.Selected = nil then exit;
|
||||
if selCat.Selected.Data = nil then exit;
|
||||
// accept/cancel is relative to a single category
|
||||
if fCatChanged then begin
|
||||
AllowChange := dlgOkCancel(
|
||||
'The modifications of the current category are not validated, ' +
|
||||
'discard them and continue ?'
|
||||
) = mrOk;
|
||||
fCatChanged := not AllowChange;
|
||||
if AllowChange then
|
||||
btnCancelClick(nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEOptionEditorWidget.selCatSelectionChanged(Sender: TObject);
|
||||
var
|
||||
dt: PCategoryData;
|
||||
begin
|
||||
// remove either the control, the form or the inspector
|
||||
// being used as editor.
|
||||
// remove either the control, the form or the inspector used as editor.
|
||||
inspector.TIObject := nil;
|
||||
if pnlEd.ControlCount > 0 then
|
||||
pnlEd.Controls[0].Parent := nil;
|
||||
|
@ -161,6 +181,7 @@ begin
|
|||
if selCat.Selected = nil then exit;
|
||||
if selcat.Selected.Data = nil then exit;
|
||||
//
|
||||
fCatChanged := true;
|
||||
PCategoryData(selCat.Selected.Data)^
|
||||
.observer
|
||||
.optionedEvent(oeeChange);
|
||||
|
@ -171,6 +192,7 @@ begin
|
|||
if selCat.Selected = nil then exit;
|
||||
if selcat.Selected.Data = nil then exit;
|
||||
//
|
||||
fCatChanged := false;
|
||||
if inspector.Parent <> nil then
|
||||
inspector.ItemIndex := -1;
|
||||
PCategoryData(selCat.Selected.Data)^
|
||||
|
@ -178,8 +200,6 @@ begin
|
|||
.optionedEvent(oeeCancel);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TCEOptionEditorWidget.inspectorEditorFilter(Sender: TObject;aEditor:
|
||||
TPropertyEditor; var aShow: boolean);
|
||||
begin
|
||||
|
@ -197,6 +217,7 @@ begin
|
|||
if selCat.Selected = nil then exit;
|
||||
if selcat.Selected.Data = nil then exit;
|
||||
//
|
||||
fCatChanged := false;
|
||||
if inspector.Parent <> nil then
|
||||
inspector.ItemIndex := -1;
|
||||
PCategoryData(selCat.Selected.Data)^
|
||||
|
|
Loading…
Reference in New Issue