tvplanit: Add ReadOnly flag to ResourceGroup to prevent editing of events in overlay mode.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5147 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
e6b0f403d5
commit
7b4cfd3f6e
@ -411,6 +411,7 @@ var
|
||||
begin
|
||||
datastore := VpControlLink1.Datastore;
|
||||
grp := datastore.Resources.AddResourceGroup('Res2 overlayed', [1, 2]);
|
||||
grp.ReadOnly := true;
|
||||
if datastore.Resource <> nil then
|
||||
datastore.Resource.Group := grp else
|
||||
datastore.Resource.Group := nil;
|
||||
|
@ -188,6 +188,10 @@ msgctxt "vpsr.rscancelbtn"
|
||||
msgid "Cancel"
|
||||
msgstr "Abbrechen"
|
||||
|
||||
#: vpsr.rscannoteditoverlayedevent
|
||||
msgid "Cannot edit this overlayed event."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rscaption
|
||||
msgctxt "vpsr.rscaption"
|
||||
msgid "Caption"
|
||||
|
@ -194,6 +194,10 @@ msgctxt "vpsr.rscancelbtn"
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
#: vpsr.rscannoteditoverlayedevent
|
||||
msgid "Cannot edit this overlayed event."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rscaption
|
||||
msgctxt "vpsr.rscaption"
|
||||
msgid "Caption"
|
||||
|
@ -188,6 +188,10 @@ msgctxt "vpsr.rscancelbtn"
|
||||
msgid "Cancel"
|
||||
msgstr "Afbreken"
|
||||
|
||||
#: vpsr.rscannoteditoverlayedevent
|
||||
msgid "Cannot edit this overlayed event."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rscaption
|
||||
msgctxt "vpsr.rscaption"
|
||||
msgid "Caption"
|
||||
|
@ -178,6 +178,10 @@ msgctxt "vpsr.rscancelbtn"
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rscannoteditoverlayedevent
|
||||
msgid "Cannot edit this overlayed event."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rscaption
|
||||
msgctxt "vpsr.rscaption"
|
||||
msgid "Caption"
|
||||
|
@ -188,6 +188,10 @@ msgctxt "vpsr.rscancelbtn"
|
||||
msgid "Cancel"
|
||||
msgstr "Отмена"
|
||||
|
||||
#: vpsr.rscannoteditoverlayedevent
|
||||
msgid "Cannot edit this overlayed event."
|
||||
msgstr ""
|
||||
|
||||
#: vpsr.rscaption
|
||||
msgctxt "vpsr.rscaption"
|
||||
msgid "Caption"
|
||||
|
@ -185,6 +185,7 @@ type
|
||||
FResourceID: Integer;
|
||||
FCaption: String;
|
||||
FIDs: Array of Integer;
|
||||
FReadOnly: Boolean;
|
||||
function GetCount: integer;
|
||||
function GetItem(AIndex: Integer): TVpResource;
|
||||
public
|
||||
@ -199,6 +200,7 @@ type
|
||||
property Count: Integer read GetCount;
|
||||
property Items[AIndex: Integer]: TVpResource read GetItem; default;
|
||||
property ResourceID: Integer read FResourceID;
|
||||
property ReadOnly: boolean read FReadOnly write FReadOnly;
|
||||
end;
|
||||
|
||||
TVpSchedule = class
|
||||
@ -287,6 +289,8 @@ type
|
||||
public
|
||||
constructor Create(Owner: TVpSchedule);
|
||||
destructor Destroy; override;
|
||||
function CanEdit: Boolean;
|
||||
function GetResource: TVpResource;
|
||||
function IsOverlayed: Boolean;
|
||||
property Owner: TVpSchedule read FOwner;
|
||||
property ResourceID: Integer read FResourceID write FResourceID;
|
||||
@ -1097,6 +1101,29 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
{ Returs false if the event cannot be edited. This is happens if the event is
|
||||
overlayed and its resourcegroup is readonly }
|
||||
function TVpEvent.CanEdit: Boolean;
|
||||
var
|
||||
res: TVpResource;
|
||||
grp: TVpResourceGroup;
|
||||
begin
|
||||
Result := true;
|
||||
if IsOverlayed then begin
|
||||
res := GetResource;
|
||||
if res <> nil then begin
|
||||
grp := res.Group;
|
||||
if grp.ReadOnly then Result := false;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Returns the resource to which the event belongs. }
|
||||
function TVpEvent.GetResource: TVpResource;
|
||||
begin
|
||||
Result := FOwner.Owner;
|
||||
end;
|
||||
|
||||
{ The event is overlayed if its ResourceID is different from that of the
|
||||
resource to which it belongs. }
|
||||
function TVpEvent.IsOverlayed: Boolean;
|
||||
|
@ -826,6 +826,8 @@ var
|
||||
begin
|
||||
if ReadOnly then
|
||||
Exit;
|
||||
if (FActiveEvent <> nil) and (not FActiveEvent.CanEdit) then
|
||||
exit;
|
||||
|
||||
dvClickTimer.Enabled := false;
|
||||
EndEdit(self);
|
||||
@ -888,7 +890,9 @@ procedure TVpDayView.InitializeDefaultPopup;
|
||||
var
|
||||
NewItem: TMenuItem;
|
||||
NewSubItem: TMenuItem;
|
||||
canEdit: Boolean;
|
||||
begin
|
||||
canEdit := (FActiveEvent <> nil) and FActiveEvent.CanEdit;
|
||||
FDefaultPopup.Items.Clear;
|
||||
|
||||
if RSDayPopupAdd <> '' then begin
|
||||
@ -902,6 +906,7 @@ begin
|
||||
if RSDayPopupEdit <> '' then begin
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := RSDayPopupEdit;
|
||||
NewItem.Enabled := canEdit;
|
||||
NewItem.OnClick := PopupEditEvent;
|
||||
NewItem.Tag := 1;
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
@ -910,11 +915,16 @@ begin
|
||||
if RSDayPopupDelete <> '' then begin
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := RSDayPopupDelete;
|
||||
NewItem.Enabled := canEdit;
|
||||
NewItem.OnClick := PopupDeleteEvent;
|
||||
NewItem.Tag := 1;
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
end;
|
||||
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := '-';
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
|
||||
if RSDayPopupNav <> '' then begin
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := RSDayPopupNav;
|
||||
@ -1634,7 +1644,8 @@ begin
|
||||
inherited MouseMove(Shift, X, Y);
|
||||
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
||||
if (not dvDragging) and dvMouseDown and
|
||||
((dvMouseDownPoint.x <> x) or (dvMouseDownPoint.y <> y))
|
||||
((dvMouseDownPoint.x <> x) or (dvMouseDownPoint.y <> y)) and
|
||||
FActiveEvent.CanEdit
|
||||
then begin
|
||||
dvDragging := true;
|
||||
dvClickTimer.Enabled := false;
|
||||
@ -1800,6 +1811,11 @@ begin
|
||||
if (DataStore = nil) or (DataStore.Resource = nil) or ReadOnly then
|
||||
Exit;
|
||||
|
||||
if (not NewEvent) and (not FActiveEvent.CanEdit) then begin
|
||||
MessageDlg(RSCannotEditOverlayedEvent, mtInformation, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
AllowIt := false;
|
||||
if Assigned(FOwnerEditEvent) then
|
||||
FOwnerEditEvent(self, FActiveEvent, DataStore.Resource, AllowIt)
|
||||
@ -1942,6 +1958,8 @@ begin
|
||||
Exit;
|
||||
if not FAllowInplaceEdit then
|
||||
Exit;
|
||||
if (FActiveEvent <> nil) and (not FActiveEvent.CanEdit) then
|
||||
Exit;
|
||||
|
||||
{ call the user defined BeforeEdit event }
|
||||
AllowIt := true;
|
||||
|
@ -716,10 +716,6 @@ begin
|
||||
try
|
||||
datastore.Resource.GetResourceGroups(list);
|
||||
if list.Count > 0 then begin
|
||||
newItem := TMenuItem.Create(AMenu.Owner);
|
||||
newItem.Caption := '-';
|
||||
AMenu.Add(newItem);
|
||||
|
||||
newItem := TMenuItem.Create(AMenu.Owner);
|
||||
newItem.Caption := RSPopupResourceGroups;
|
||||
newItem.Tag := 0;
|
||||
|
@ -141,6 +141,7 @@ resourcestring
|
||||
RSConfirmDeleteEvent = 'Delete event from schedule?';
|
||||
RSStartEndTimeError = 'Incorrect order of start and end times. ' +
|
||||
'Do you want to flip them?';
|
||||
RSCannotEditOverlayedEvent= 'Cannot edit this overlayed event.';
|
||||
|
||||
{Task Specific}
|
||||
RSConfirmDeleteTask = 'Delete this task from your list?';
|
||||
|
@ -605,6 +605,8 @@ var
|
||||
begin
|
||||
if ReadOnly then
|
||||
exit;
|
||||
if (FActiveEvent <> nil) and (not FActiveEvent.CanEdit) then
|
||||
exit;
|
||||
|
||||
wvClickTimer.Enabled := false;
|
||||
EndEdit(nil);
|
||||
@ -903,93 +905,101 @@ procedure TVpWeekView.InitializeDefaultPopup;
|
||||
var
|
||||
NewItem: TMenuItem;
|
||||
NewSubItem: TMenuItem;
|
||||
canEdit: Boolean;
|
||||
begin
|
||||
canEdit := (FActiveEvent <> nil) and FActiveEvent.CanEdit;
|
||||
FDefaultPopup.Items.Clear;
|
||||
|
||||
if RSWeekPopupAdd <> '' then begin
|
||||
NewItem := TMenuItem.Create (Self);
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := RSWeekPopupAdd;
|
||||
NewItem.OnClick := PopupAddEvent;
|
||||
NewItem.Tag := 0;
|
||||
FDefaultPopup.Items.Add (NewItem);
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupEdit <> '' then begin
|
||||
NewItem := TMenuItem.Create (Self);
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := RSWeekPopupEdit;
|
||||
NewItem.Enabled := canEdit;
|
||||
NewItem.OnClick := PopupEditEvent;
|
||||
NewItem.Tag := 1;
|
||||
FDefaultPopup.Items.Add (NewItem);
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupDelete <> '' then begin
|
||||
NewItem := TMenuItem.Create (Self);
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := RSWeekPopupDelete;
|
||||
NewItem.Enabled := canEdit;
|
||||
NewItem.OnClick := PopupDeleteEvent;
|
||||
NewItem.Tag := 1;
|
||||
FDefaultPopup.Items.Add (NewItem);
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
end;
|
||||
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := '-';
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
|
||||
if RSWeekPopupNav <> '' then begin
|
||||
NewItem := TMenuItem.Create (Self);
|
||||
NewItem := TMenuItem.Create(Self);
|
||||
NewItem.Caption := RSWeekPopupNav;
|
||||
NewItem.Tag := 0;
|
||||
FDefaultPopup.Items.Add (NewItem);
|
||||
FDefaultPopup.Items.Add(NewItem);
|
||||
|
||||
if RSWeekPopupNavToday <> '' then begin
|
||||
NewSubItem := TMenuItem.Create (Self);
|
||||
NewSubItem := TMenuItem.Create(Self);
|
||||
NewSubItem.Caption := RSWeekPopupNavToday;
|
||||
NewSubItem.OnClick := PopupToday;
|
||||
NewSubItem.Tag := 0;
|
||||
NewItem.Add (NewSubItem);
|
||||
NewItem.Add(NewSubItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupNavNextWeek <> '' then begin
|
||||
NewSubItem := TMenuItem.Create (Self);
|
||||
NewSubItem := TMenuItem.Create(Self);
|
||||
NewSubItem.Caption := RSWeekPopupNavNextWeek;
|
||||
NewSubItem.OnClick := PopupNextWeek;
|
||||
NewSubItem.Tag := 0;
|
||||
NewItem.Add (NewSubItem);
|
||||
NewItem.Add(NewSubItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupNavPrevWeek <> '' then begin
|
||||
NewSubItem := TMenuItem.Create (Self);
|
||||
NewSubItem := TMenuItem.Create(Self);
|
||||
NewSubItem.Caption := RSWeekPopupNavPrevWeek;
|
||||
NewSubItem.OnClick := PopupPrevWeek;
|
||||
NewSubItem.Tag := 0;
|
||||
NewItem.Add (NewSubItem);
|
||||
NewItem.Add(NewSubItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupNavNextMonth <> '' then begin
|
||||
NewSubItem := TMenuItem.Create (Self);
|
||||
NewSubItem := TMenuItem.Create(Self);
|
||||
NewSubItem.Caption := RSWeekPopupNavNextMonth;
|
||||
NewSubItem.OnClick := PopupNextMonth;
|
||||
NewSubItem.Tag := 0;
|
||||
NewItem.Add (NewSubItem);
|
||||
NewItem.Add(NewSubItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupNavPrevMonth <> '' then begin
|
||||
NewSubItem := TMenuItem.Create (Self);
|
||||
NewSubItem := TMenuItem.Create(Self);
|
||||
NewSubItem.Caption := RSWeekPopupNavPrevMonth;
|
||||
NewSubItem.OnClick := PopupPrevMonth;
|
||||
NewSubItem.Tag := 0;
|
||||
NewItem.Add (NewSubItem);
|
||||
NewItem.Add(NewSubItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupNavNextYear <> '' then begin
|
||||
NewSubItem := TMenuItem.Create (Self);
|
||||
NewSubItem := TMenuItem.Create(Self);
|
||||
NewSubItem.Caption := RSWeekPopupNavNextYear;
|
||||
NewSubItem.OnClick := PopupNextYear;
|
||||
NewSubItem.Tag := 0;
|
||||
NewItem.Add (NewSubItem);
|
||||
NewItem.Add(NewSubItem);
|
||||
end;
|
||||
|
||||
if RSWeekPopupNavPrevYear <> '' then begin
|
||||
NewSubItem := TMenuItem.Create (Self);
|
||||
NewSubItem := TMenuItem.Create(Self);
|
||||
NewSubItem.Caption := RSWeekPopupNavPrevYear;
|
||||
NewSubItem.OnClick := PopupPrevYear;
|
||||
NewSubItem.Tag := 0;
|
||||
NewItem.Add (NewSubItem);
|
||||
NewItem.Add(NewSubItem);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1138,6 +1148,11 @@ var
|
||||
begin
|
||||
if DataStore = nil then Exit;
|
||||
|
||||
if (not NewEvent) and (not ActiveEvent.CanEdit) then begin
|
||||
MessageDlg(RSCannotEditOverlayedEvent, mtInformation, [mbOk], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
AllowIt := false;
|
||||
if Assigned(FOwnerEditEvent) then
|
||||
FOwnerEditEvent(self, ActiveEvent, DataStore.Resource, AllowIt)
|
||||
@ -1237,7 +1252,7 @@ var
|
||||
AllowIt: Boolean;
|
||||
begin
|
||||
if ActiveEvent <> nil then begin
|
||||
if not FAllowInplaceEdit then
|
||||
if (not FAllowInplaceEdit) or (not ActiveEvent.CanEdit) then
|
||||
exit;
|
||||
|
||||
AllowIt := true;
|
||||
@ -1450,7 +1465,8 @@ begin
|
||||
inherited MouseMove(Shift, X, Y);
|
||||
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
||||
if (not wvDragging) and wvMouseDown and
|
||||
((wvMouseDownPoint.x <> x) or (wvMouseDownPoint.y <> y))
|
||||
((wvMouseDownPoint.x <> x) or (wvMouseDownPoint.y <> y)) and
|
||||
FActiveEvent.CanEdit
|
||||
then begin
|
||||
wvDragging := true;
|
||||
wvClickTimer.Enabled := false;
|
||||
|
Loading…
Reference in New Issue
Block a user