diff --git a/components/tvplanit/examples/fulldemo/bufdsdatamodule.lfm b/components/tvplanit/examples/fulldemo/bufdsdatamodule.lfm
new file mode 100644
index 000000000..ed89e3420
--- /dev/null
+++ b/components/tvplanit/examples/fulldemo/bufdsdatamodule.lfm
@@ -0,0 +1,37 @@
+object DemoDM: TDemoDM
+ OldCreateOrder = False
+ Height = 150
+ HorizontalOffset = 603
+ VerticalOffset = 519
+ Width = 277
+ object Datastore: TVpBufDSDataStore
+ CategoryColorMap.Category0.Color = clNavy
+ CategoryColorMap.Category0.Description = 'Category 0'
+ CategoryColorMap.Category1.Color = clRed
+ CategoryColorMap.Category1.Description = 'Category 1'
+ CategoryColorMap.Category2.Color = clYellow
+ CategoryColorMap.Category2.Description = 'Category 2'
+ CategoryColorMap.Category3.Color = clLime
+ CategoryColorMap.Category3.Description = 'Category 3'
+ CategoryColorMap.Category4.Color = clPurple
+ CategoryColorMap.Category4.Description = 'Category 4'
+ CategoryColorMap.Category5.Color = clTeal
+ CategoryColorMap.Category5.Description = 'Category 5'
+ CategoryColorMap.Category6.Color = clFuchsia
+ CategoryColorMap.Category6.Description = 'Category 6'
+ CategoryColorMap.Category7.Color = clOlive
+ CategoryColorMap.Category7.Description = 'Category 7'
+ CategoryColorMap.Category8.Color = clAqua
+ CategoryColorMap.Category8.Description = 'Category 8'
+ CategoryColorMap.Category9.Color = clMaroon
+ CategoryColorMap.Category9.Description = 'Category 9'
+ EnableEventTimer = True
+ PlayEventSounds = True
+ AutoConnect = True
+ AutoCreate = True
+ DayBuffer = 31
+ Directory = 'data'
+ left = 87
+ top = 32
+ end
+end
diff --git a/components/tvplanit/examples/fulldemo/bufdsdatamodule.pas b/components/tvplanit/examples/fulldemo/bufdsdatamodule.pas
new file mode 100644
index 000000000..def38cb49
--- /dev/null
+++ b/components/tvplanit/examples/fulldemo/bufdsdatamodule.pas
@@ -0,0 +1,31 @@
+unit bufdsdatamodule;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, VpBaseDS, VpBufDS;
+
+type
+
+ { TDemoDM }
+
+ TDemoDM = class(TDataModule)
+ Datastore: TVpBufDSDataStore;
+ private
+
+ public
+// constructor Create(AOwner: TComponent); override;
+
+ end;
+
+var
+ DemoDM: TDemoDM;
+
+implementation
+
+{$R *.lfm}
+
+end.
+
diff --git a/components/tvplanit/examples/fulldemo/demo.lpi b/components/tvplanit/examples/fulldemo/demo.lpi
index a7e7c2e71..3316d39ff 100644
--- a/components/tvplanit/examples/fulldemo/demo.lpi
+++ b/components/tvplanit/examples/fulldemo/demo.lpi
@@ -64,11 +64,11 @@
-
+
+
-
@@ -92,6 +92,12 @@
+
+
+
+
+
+
diff --git a/components/tvplanit/examples/fulldemo/demo.lpr b/components/tvplanit/examples/fulldemo/demo.lpr
index 5f7bdb17c..7ea82f940 100644
--- a/components/tvplanit/examples/fulldemo/demo.lpr
+++ b/components/tvplanit/examples/fulldemo/demo.lpr
@@ -8,7 +8,7 @@ uses
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, demoMain, laz_visualplanit, LCLTranslator, DefaultTranslator,
- printer4lazarus, demoDatamodule;
+ bufdsdatamodule, printer4lazarus;
{$R *.res}
diff --git a/components/tvplanit/examples/fulldemo/demomain.pas b/components/tvplanit/examples/fulldemo/demomain.pas
index 557e3fd71..c9cbce209 100644
--- a/components/tvplanit/examples/fulldemo/demomain.pas
+++ b/components/tvplanit/examples/fulldemo/demomain.pas
@@ -9,12 +9,10 @@ uses
clocale,
{$ENDIF}
Classes, SysUtils, FileUtil, PrintersDlgs, Forms, Controls, Graphics, Dialogs,
- ExtCtrls, StdCtrls, ComCtrls, LCLTranslator, Menus, LCLVersion,
-// VpBufDS,
- VpBaseDS, VpDayView,
- VpWeekView, VpTaskList, VpAbout, VpContactGrid, VpMonthView, VpResEditDlg,
- VpContactButtons, VpNavBar, VpData, VpPrtPrvDlg, VpPrtFmtDlg, Types,
- VpBase, VpCalendar;
+ ExtCtrls, StdCtrls, ComCtrls, LCLTranslator, Menus, Types, LCLVersion,
+ VpBaseDS, VpDayView, VpWeekView, VpTaskList, VpAbout, VpContactGrid,
+ VpMonthView, VpResEditDlg, VpContactButtons, VpNavBar, VpData,
+ VpPrtPrvDlg, VpPrtFmtDlg, VpBase, VpCalendar;
type
@@ -171,8 +169,13 @@ uses
{$ENDIF}
IniFiles, Math, Printers,
VpMisc, VpPrtFmt,
- demoDatamodule,
- sound, ExVpRptSetup;
+ sound, ExVpRptSetup,
+
+ // Using the defines BUFDATASET or MORMOT (defined in project options) we
+ // select the datastore to use in this demo.
+ {$IFDEF BUFDATASET}BufDSDatamodule{$ENDIF}
+ {$IFDEF MORMOT}mORMotDatamodule{$ENDIF}
+ ;
const
LANGUAGE_DIR = '..\..\languages\';
@@ -408,13 +411,19 @@ end;
// Load the last resource.
procedure TMainForm.FormCreate(Sender: TObject);
-var
- lastRes: TVpResource;
begin
- (*
- Datastore := TVpBufDSDatastore.Create(self);
+ PopulateLanguages;
+ ReadIni;
- with Datastore as TVpBufDSDatastore do begin
+ // Establish connection of datastore (resides in a datamodule) to all
+ // dependent controls.
+ VpControlLink1.Datastore := DemoDM.Datastore;
+
+ with VpControlLink1.Datastore do begin
+
+ // These properties could be set also in Object Inspector.
+ // But we do it here at runtime because the mORMot datastore is
+ // created at runtime, and we want both versions to behave the same.
CategoryColorMap.Category0.BackgroundColor := clSkyBlue;
CategoryColorMap.Category0.Color := clNavy;
CategoryColorMap.Category0.Description := 'Appointment';
@@ -430,32 +439,17 @@ begin
CategoryColorMap.Category4.BackgroundColor := 15332329;
CategoryColorMap.Category4.Color := clMoneyGreen;
CategoryColorMap.Category4.Description := 'Private';
- EnableEventTimer := True;
- PlayEventSounds := True;
+
+ PlayEventSounds := true;
OnPlaySound := @VpBufDSDataStore1PlaySound;
{$IFDEF WINDOWS}
MediaFolder := AppendPathDelim(SysUtils.GetEnvironmentVariable('SYSTEMROOT')) + 'media';
{$ENDIF}
- DayBuffer := 31;
- Directory := 'data';
- Connected := true;
- end;
- VpControlLink1.Datastore := Datastore;
- *)
- // Establish connection of datastore (resides in a datamodule) to all
- // dependent controls.
- VpControlLink1.Datastore := DemoDM.VpBufDSDatastore1;
-
- PopulateLanguages;
- ReadIni;
-
- with VpControlLink1.Datastore do
+ // By default select the last resource entered.
if Resources.Count > 0 then
- begin
- lastRes := Resources.Items[Resources.Count-1];
- Resource := lastRes;
- end;
+ Resource := Resources.Items[Resources.Count-1];
+ end;
end;
procedure TMainForm.MnuAboutClick(Sender: TObject);
diff --git a/components/tvplanit/examples/fulldemo/mormotdatamodule.lfm b/components/tvplanit/examples/fulldemo/mormotdatamodule.lfm
new file mode 100644
index 000000000..18806b6d1
--- /dev/null
+++ b/components/tvplanit/examples/fulldemo/mormotdatamodule.lfm
@@ -0,0 +1,14 @@
+object DemoDM: TDemoDM
+ OldCreateOrder = False
+ Height = 150
+ HorizontalOffset = 280
+ VerticalOffset = 130
+ Width = 447
+ object Timer1: TTimer
+ Enabled = False
+ Interval = 250
+ OnTimer = Timer1Timer
+ left = 62
+ top = 34
+ end
+end
diff --git a/components/tvplanit/examples/fulldemo/mormotdatamodule.pas b/components/tvplanit/examples/fulldemo/mormotdatamodule.pas
new file mode 100644
index 000000000..f3e816e41
--- /dev/null
+++ b/components/tvplanit/examples/fulldemo/mormotdatamodule.pas
@@ -0,0 +1,64 @@
+unit mormotdatamodule;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, Forms, Dialogs, ExtCtrls, VpmORMotDS;
+
+type
+
+ { TDemoDM }
+
+ TDemoDM = class(TDataModule)
+ Timer1: TTimer;
+ procedure Timer1Timer(Sender: TObject);
+ private
+ public
+ Datastore: TVpmORMotDatastore;
+ constructor Create(AOwner: TComponent); override;
+ end;
+
+var
+ DemoDM: TDemoDM;
+
+implementation
+
+{$R *.lfm}
+
+constructor TDemoDM.Create(AOwner: TComponent);
+begin
+ inherited;
+
+ Datastore := TVpmORMotDatastore.Create(self);
+
+ with Datastore do
+ begin
+ // if the HostIP is set, it will look for a running server on this IP address when connecting.
+ // leave blank (comment out) for a local (and private) database
+
+ HostIP := 'localhost';
+ Directory := 'data';
+ Connected := true;
+
+ if (Length(HostIP)>0) and (not Connected) then
+ begin
+ MessageDlg('Cannot connect with server', mtError, [mbOk], 0);
+ Application.Terminate;
+ end;
+ end;
+
+ Timer1.Enabled := true;
+end;
+
+procedure TDemoDM.Timer1Timer(Sender: TObject);
+begin
+ Timer1.Enabled := False;
+ Datastore.CheckUpdate;
+ Timer1.Enabled := True;
+end;
+
+
+end.
+
diff --git a/components/tvplanit/examples/fulldemo/mormotdemo.lpi b/components/tvplanit/examples/fulldemo/mormotdemo.lpi
new file mode 100644
index 000000000..6eb07818f
--- /dev/null
+++ b/components/tvplanit/examples/fulldemo/mormotdemo.lpi
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/tvplanit/examples/fulldemo/mormotdemo.lpr b/components/tvplanit/examples/fulldemo/mormotdemo.lpr
new file mode 100644
index 000000000..007546a07
--- /dev/null
+++ b/components/tvplanit/examples/fulldemo/mormotdemo.lpr
@@ -0,0 +1,23 @@
+program mormotdemo;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ Forms, demoMain, laz_visualplanit, LCLTranslator, DefaultTranslator,
+ printer4lazarus, mormotdatamodule;
+
+{$R *.res}
+
+begin
+ Application.Title := 'mORMot Demo';
+ RequireDerivedFormResource := True;
+ Application.Initialize;
+ Application.CreateForm(TDemoDM, DemoDM);
+ Application.CreateForm(TMainForm, MainForm);
+ Application.Run;
+end.
+
diff --git a/components/tvplanit/source/vpwavdlg.lfm b/components/tvplanit/source/vpwavdlg.lfm
index 81c6dbac9..234880f74 100644
--- a/components/tvplanit/source/vpwavdlg.lfm
+++ b/components/tvplanit/source/vpwavdlg.lfm
@@ -129,6 +129,7 @@ object FrmSoundDialog: TFrmSoundDialog
Color = clDefault
HideSelection = False
Mask = '*.wav'
+ ReadOnly = True
TabOrder = 1
ObjectTypes = [otNonFolders]
ShellTreeView = ShellTreeView