You've already forked lazarus-ccr
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:
@ -411,6 +411,7 @@ var
|
|||||||
begin
|
begin
|
||||||
datastore := VpControlLink1.Datastore;
|
datastore := VpControlLink1.Datastore;
|
||||||
grp := datastore.Resources.AddResourceGroup('Res2 overlayed', [1, 2]);
|
grp := datastore.Resources.AddResourceGroup('Res2 overlayed', [1, 2]);
|
||||||
|
grp.ReadOnly := true;
|
||||||
if datastore.Resource <> nil then
|
if datastore.Resource <> nil then
|
||||||
datastore.Resource.Group := grp else
|
datastore.Resource.Group := grp else
|
||||||
datastore.Resource.Group := nil;
|
datastore.Resource.Group := nil;
|
||||||
|
@ -188,6 +188,10 @@ msgctxt "vpsr.rscancelbtn"
|
|||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
msgstr "Abbrechen"
|
msgstr "Abbrechen"
|
||||||
|
|
||||||
|
#: vpsr.rscannoteditoverlayedevent
|
||||||
|
msgid "Cannot edit this overlayed event."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: vpsr.rscaption
|
#: vpsr.rscaption
|
||||||
msgctxt "vpsr.rscaption"
|
msgctxt "vpsr.rscaption"
|
||||||
msgid "Caption"
|
msgid "Caption"
|
||||||
|
@ -194,6 +194,10 @@ msgctxt "vpsr.rscancelbtn"
|
|||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
msgstr "Annuler"
|
msgstr "Annuler"
|
||||||
|
|
||||||
|
#: vpsr.rscannoteditoverlayedevent
|
||||||
|
msgid "Cannot edit this overlayed event."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: vpsr.rscaption
|
#: vpsr.rscaption
|
||||||
msgctxt "vpsr.rscaption"
|
msgctxt "vpsr.rscaption"
|
||||||
msgid "Caption"
|
msgid "Caption"
|
||||||
|
@ -188,6 +188,10 @@ msgctxt "vpsr.rscancelbtn"
|
|||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
msgstr "Afbreken"
|
msgstr "Afbreken"
|
||||||
|
|
||||||
|
#: vpsr.rscannoteditoverlayedevent
|
||||||
|
msgid "Cannot edit this overlayed event."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: vpsr.rscaption
|
#: vpsr.rscaption
|
||||||
msgctxt "vpsr.rscaption"
|
msgctxt "vpsr.rscaption"
|
||||||
msgid "Caption"
|
msgid "Caption"
|
||||||
|
@ -178,6 +178,10 @@ msgctxt "vpsr.rscancelbtn"
|
|||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: vpsr.rscannoteditoverlayedevent
|
||||||
|
msgid "Cannot edit this overlayed event."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: vpsr.rscaption
|
#: vpsr.rscaption
|
||||||
msgctxt "vpsr.rscaption"
|
msgctxt "vpsr.rscaption"
|
||||||
msgid "Caption"
|
msgid "Caption"
|
||||||
|
@ -188,6 +188,10 @@ msgctxt "vpsr.rscancelbtn"
|
|||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
msgstr "Отмена"
|
msgstr "Отмена"
|
||||||
|
|
||||||
|
#: vpsr.rscannoteditoverlayedevent
|
||||||
|
msgid "Cannot edit this overlayed event."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: vpsr.rscaption
|
#: vpsr.rscaption
|
||||||
msgctxt "vpsr.rscaption"
|
msgctxt "vpsr.rscaption"
|
||||||
msgid "Caption"
|
msgid "Caption"
|
||||||
|
@ -185,6 +185,7 @@ type
|
|||||||
FResourceID: Integer;
|
FResourceID: Integer;
|
||||||
FCaption: String;
|
FCaption: String;
|
||||||
FIDs: Array of Integer;
|
FIDs: Array of Integer;
|
||||||
|
FReadOnly: Boolean;
|
||||||
function GetCount: integer;
|
function GetCount: integer;
|
||||||
function GetItem(AIndex: Integer): TVpResource;
|
function GetItem(AIndex: Integer): TVpResource;
|
||||||
public
|
public
|
||||||
@ -199,6 +200,7 @@ type
|
|||||||
property Count: Integer read GetCount;
|
property Count: Integer read GetCount;
|
||||||
property Items[AIndex: Integer]: TVpResource read GetItem; default;
|
property Items[AIndex: Integer]: TVpResource read GetItem; default;
|
||||||
property ResourceID: Integer read FResourceID;
|
property ResourceID: Integer read FResourceID;
|
||||||
|
property ReadOnly: boolean read FReadOnly write FReadOnly;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TVpSchedule = class
|
TVpSchedule = class
|
||||||
@ -287,6 +289,8 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(Owner: TVpSchedule);
|
constructor Create(Owner: TVpSchedule);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function CanEdit: Boolean;
|
||||||
|
function GetResource: TVpResource;
|
||||||
function IsOverlayed: Boolean;
|
function IsOverlayed: Boolean;
|
||||||
property Owner: TVpSchedule read FOwner;
|
property Owner: TVpSchedule read FOwner;
|
||||||
property ResourceID: Integer read FResourceID write FResourceID;
|
property ResourceID: Integer read FResourceID write FResourceID;
|
||||||
@ -1097,6 +1101,29 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
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
|
{ The event is overlayed if its ResourceID is different from that of the
|
||||||
resource to which it belongs. }
|
resource to which it belongs. }
|
||||||
function TVpEvent.IsOverlayed: Boolean;
|
function TVpEvent.IsOverlayed: Boolean;
|
||||||
|
@ -826,6 +826,8 @@ var
|
|||||||
begin
|
begin
|
||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
Exit;
|
Exit;
|
||||||
|
if (FActiveEvent <> nil) and (not FActiveEvent.CanEdit) then
|
||||||
|
exit;
|
||||||
|
|
||||||
dvClickTimer.Enabled := false;
|
dvClickTimer.Enabled := false;
|
||||||
EndEdit(self);
|
EndEdit(self);
|
||||||
@ -888,7 +890,9 @@ procedure TVpDayView.InitializeDefaultPopup;
|
|||||||
var
|
var
|
||||||
NewItem: TMenuItem;
|
NewItem: TMenuItem;
|
||||||
NewSubItem: TMenuItem;
|
NewSubItem: TMenuItem;
|
||||||
|
canEdit: Boolean;
|
||||||
begin
|
begin
|
||||||
|
canEdit := (FActiveEvent <> nil) and FActiveEvent.CanEdit;
|
||||||
FDefaultPopup.Items.Clear;
|
FDefaultPopup.Items.Clear;
|
||||||
|
|
||||||
if RSDayPopupAdd <> '' then begin
|
if RSDayPopupAdd <> '' then begin
|
||||||
@ -902,6 +906,7 @@ begin
|
|||||||
if RSDayPopupEdit <> '' then begin
|
if RSDayPopupEdit <> '' then begin
|
||||||
NewItem := TMenuItem.Create(Self);
|
NewItem := TMenuItem.Create(Self);
|
||||||
NewItem.Caption := RSDayPopupEdit;
|
NewItem.Caption := RSDayPopupEdit;
|
||||||
|
NewItem.Enabled := canEdit;
|
||||||
NewItem.OnClick := PopupEditEvent;
|
NewItem.OnClick := PopupEditEvent;
|
||||||
NewItem.Tag := 1;
|
NewItem.Tag := 1;
|
||||||
FDefaultPopup.Items.Add(NewItem);
|
FDefaultPopup.Items.Add(NewItem);
|
||||||
@ -910,11 +915,16 @@ begin
|
|||||||
if RSDayPopupDelete <> '' then begin
|
if RSDayPopupDelete <> '' then begin
|
||||||
NewItem := TMenuItem.Create(Self);
|
NewItem := TMenuItem.Create(Self);
|
||||||
NewItem.Caption := RSDayPopupDelete;
|
NewItem.Caption := RSDayPopupDelete;
|
||||||
|
NewItem.Enabled := canEdit;
|
||||||
NewItem.OnClick := PopupDeleteEvent;
|
NewItem.OnClick := PopupDeleteEvent;
|
||||||
NewItem.Tag := 1;
|
NewItem.Tag := 1;
|
||||||
FDefaultPopup.Items.Add(NewItem);
|
FDefaultPopup.Items.Add(NewItem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
NewItem := TMenuItem.Create(Self);
|
||||||
|
NewItem.Caption := '-';
|
||||||
|
FDefaultPopup.Items.Add(NewItem);
|
||||||
|
|
||||||
if RSDayPopupNav <> '' then begin
|
if RSDayPopupNav <> '' then begin
|
||||||
NewItem := TMenuItem.Create(Self);
|
NewItem := TMenuItem.Create(Self);
|
||||||
NewItem.Caption := RSDayPopupNav;
|
NewItem.Caption := RSDayPopupNav;
|
||||||
@ -1634,7 +1644,8 @@ begin
|
|||||||
inherited MouseMove(Shift, X, Y);
|
inherited MouseMove(Shift, X, Y);
|
||||||
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
||||||
if (not dvDragging) and dvMouseDown and
|
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
|
then begin
|
||||||
dvDragging := true;
|
dvDragging := true;
|
||||||
dvClickTimer.Enabled := false;
|
dvClickTimer.Enabled := false;
|
||||||
@ -1800,6 +1811,11 @@ begin
|
|||||||
if (DataStore = nil) or (DataStore.Resource = nil) or ReadOnly then
|
if (DataStore = nil) or (DataStore.Resource = nil) or ReadOnly then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
if (not NewEvent) and (not FActiveEvent.CanEdit) then begin
|
||||||
|
MessageDlg(RSCannotEditOverlayedEvent, mtInformation, [mbOK], 0);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
AllowIt := false;
|
AllowIt := false;
|
||||||
if Assigned(FOwnerEditEvent) then
|
if Assigned(FOwnerEditEvent) then
|
||||||
FOwnerEditEvent(self, FActiveEvent, DataStore.Resource, AllowIt)
|
FOwnerEditEvent(self, FActiveEvent, DataStore.Resource, AllowIt)
|
||||||
@ -1942,6 +1958,8 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
if not FAllowInplaceEdit then
|
if not FAllowInplaceEdit then
|
||||||
Exit;
|
Exit;
|
||||||
|
if (FActiveEvent <> nil) and (not FActiveEvent.CanEdit) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
{ call the user defined BeforeEdit event }
|
{ call the user defined BeforeEdit event }
|
||||||
AllowIt := true;
|
AllowIt := true;
|
||||||
|
@ -716,10 +716,6 @@ begin
|
|||||||
try
|
try
|
||||||
datastore.Resource.GetResourceGroups(list);
|
datastore.Resource.GetResourceGroups(list);
|
||||||
if list.Count > 0 then begin
|
if list.Count > 0 then begin
|
||||||
newItem := TMenuItem.Create(AMenu.Owner);
|
|
||||||
newItem.Caption := '-';
|
|
||||||
AMenu.Add(newItem);
|
|
||||||
|
|
||||||
newItem := TMenuItem.Create(AMenu.Owner);
|
newItem := TMenuItem.Create(AMenu.Owner);
|
||||||
newItem.Caption := RSPopupResourceGroups;
|
newItem.Caption := RSPopupResourceGroups;
|
||||||
newItem.Tag := 0;
|
newItem.Tag := 0;
|
||||||
|
@ -141,6 +141,7 @@ resourcestring
|
|||||||
RSConfirmDeleteEvent = 'Delete event from schedule?';
|
RSConfirmDeleteEvent = 'Delete event from schedule?';
|
||||||
RSStartEndTimeError = 'Incorrect order of start and end times. ' +
|
RSStartEndTimeError = 'Incorrect order of start and end times. ' +
|
||||||
'Do you want to flip them?';
|
'Do you want to flip them?';
|
||||||
|
RSCannotEditOverlayedEvent= 'Cannot edit this overlayed event.';
|
||||||
|
|
||||||
{Task Specific}
|
{Task Specific}
|
||||||
RSConfirmDeleteTask = 'Delete this task from your list?';
|
RSConfirmDeleteTask = 'Delete this task from your list?';
|
||||||
|
@ -605,6 +605,8 @@ var
|
|||||||
begin
|
begin
|
||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
exit;
|
exit;
|
||||||
|
if (FActiveEvent <> nil) and (not FActiveEvent.CanEdit) then
|
||||||
|
exit;
|
||||||
|
|
||||||
wvClickTimer.Enabled := false;
|
wvClickTimer.Enabled := false;
|
||||||
EndEdit(nil);
|
EndEdit(nil);
|
||||||
@ -903,7 +905,9 @@ procedure TVpWeekView.InitializeDefaultPopup;
|
|||||||
var
|
var
|
||||||
NewItem: TMenuItem;
|
NewItem: TMenuItem;
|
||||||
NewSubItem: TMenuItem;
|
NewSubItem: TMenuItem;
|
||||||
|
canEdit: Boolean;
|
||||||
begin
|
begin
|
||||||
|
canEdit := (FActiveEvent <> nil) and FActiveEvent.CanEdit;
|
||||||
FDefaultPopup.Items.Clear;
|
FDefaultPopup.Items.Clear;
|
||||||
|
|
||||||
if RSWeekPopupAdd <> '' then begin
|
if RSWeekPopupAdd <> '' then begin
|
||||||
@ -917,6 +921,7 @@ begin
|
|||||||
if RSWeekPopupEdit <> '' then begin
|
if RSWeekPopupEdit <> '' then begin
|
||||||
NewItem := TMenuItem.Create(Self);
|
NewItem := TMenuItem.Create(Self);
|
||||||
NewItem.Caption := RSWeekPopupEdit;
|
NewItem.Caption := RSWeekPopupEdit;
|
||||||
|
NewItem.Enabled := canEdit;
|
||||||
NewItem.OnClick := PopupEditEvent;
|
NewItem.OnClick := PopupEditEvent;
|
||||||
NewItem.Tag := 1;
|
NewItem.Tag := 1;
|
||||||
FDefaultPopup.Items.Add(NewItem);
|
FDefaultPopup.Items.Add(NewItem);
|
||||||
@ -925,11 +930,16 @@ begin
|
|||||||
if RSWeekPopupDelete <> '' then begin
|
if RSWeekPopupDelete <> '' then begin
|
||||||
NewItem := TMenuItem.Create(Self);
|
NewItem := TMenuItem.Create(Self);
|
||||||
NewItem.Caption := RSWeekPopupDelete;
|
NewItem.Caption := RSWeekPopupDelete;
|
||||||
|
NewItem.Enabled := canEdit;
|
||||||
NewItem.OnClick := PopupDeleteEvent;
|
NewItem.OnClick := PopupDeleteEvent;
|
||||||
NewItem.Tag := 1;
|
NewItem.Tag := 1;
|
||||||
FDefaultPopup.Items.Add(NewItem);
|
FDefaultPopup.Items.Add(NewItem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
NewItem := TMenuItem.Create(Self);
|
||||||
|
NewItem.Caption := '-';
|
||||||
|
FDefaultPopup.Items.Add(NewItem);
|
||||||
|
|
||||||
if RSWeekPopupNav <> '' then begin
|
if RSWeekPopupNav <> '' then begin
|
||||||
NewItem := TMenuItem.Create(Self);
|
NewItem := TMenuItem.Create(Self);
|
||||||
NewItem.Caption := RSWeekPopupNav;
|
NewItem.Caption := RSWeekPopupNav;
|
||||||
@ -1138,6 +1148,11 @@ var
|
|||||||
begin
|
begin
|
||||||
if DataStore = nil then Exit;
|
if DataStore = nil then Exit;
|
||||||
|
|
||||||
|
if (not NewEvent) and (not ActiveEvent.CanEdit) then begin
|
||||||
|
MessageDlg(RSCannotEditOverlayedEvent, mtInformation, [mbOk], 0);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
AllowIt := false;
|
AllowIt := false;
|
||||||
if Assigned(FOwnerEditEvent) then
|
if Assigned(FOwnerEditEvent) then
|
||||||
FOwnerEditEvent(self, ActiveEvent, DataStore.Resource, AllowIt)
|
FOwnerEditEvent(self, ActiveEvent, DataStore.Resource, AllowIt)
|
||||||
@ -1237,7 +1252,7 @@ var
|
|||||||
AllowIt: Boolean;
|
AllowIt: Boolean;
|
||||||
begin
|
begin
|
||||||
if ActiveEvent <> nil then begin
|
if ActiveEvent <> nil then begin
|
||||||
if not FAllowInplaceEdit then
|
if (not FAllowInplaceEdit) or (not ActiveEvent.CanEdit) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
AllowIt := true;
|
AllowIt := true;
|
||||||
@ -1450,7 +1465,8 @@ begin
|
|||||||
inherited MouseMove(Shift, X, Y);
|
inherited MouseMove(Shift, X, Y);
|
||||||
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
||||||
if (not wvDragging) and wvMouseDown and
|
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
|
then begin
|
||||||
wvDragging := true;
|
wvDragging := true;
|
||||||
wvClickTimer.Enabled := false;
|
wvClickTimer.Enabled := false;
|
||||||
|
Reference in New Issue
Block a user