tvplanit: Add a mORMot variant of the full demo (based on code kindly provided by DonAlfredo).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5123 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-09-02 17:58:47 +00:00
parent aef96e2519
commit 395e3f20ed
10 changed files with 323 additions and 36 deletions

View File

@ -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

View File

@ -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.

View File

@ -64,11 +64,11 @@
<ResourceBaseClass Value="Form"/>
</Unit3>
<Unit4>
<Filename Value="demodatamodule.pas"/>
<Filename Value="bufdsdatamodule.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="DemoDM"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="DataModule"/>
<UnitName Value="demoDatamodule"/>
</Unit4>
</Units>
</ProjectOptions>
@ -92,6 +92,12 @@
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-dBUFDATASET"/>
<OtherDefines Count="1">
<Define0 Value="BUFDATASET"/>
</OtherDefines>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -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}

View File

@ -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,31 +439,16 @@ 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;
Resource := Resources.Items[Resources.Count-1];
end;
end;

View File

@ -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

View File

@ -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.

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="mORMot Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
</General>
<i18n>
<EnableI18N Value="True"/>
<OutDir Value="..\..\languages"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="Printer4Lazarus"/>
</Item1>
<Item2>
<PackageName Value="laz_visualplanit"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="5">
<Unit0>
<Filename Value="mormotdemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="demomain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="demoMain"/>
</Unit1>
<Unit2>
<Filename Value="sound.pas"/>
<IsPartOfProject Value="True"/>
</Unit2>
<Unit3>
<Filename Value="ExVpRptSetup.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="frmReportSetup"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit3>
<Unit4>
<Filename Value="mormotdatamodule.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="DemoDM"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="DataModule"/>
</Unit4>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="mormotdemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);..\mormot\mORMotSourceHere;..\..\source"/>
<Libraries Value="..\mormot\mORMotSourceHere\fpc-win32"/>
<OtherUnitFiles Value="..\mormot;..\mormot\mORMotSourceHere;..\mormot\mORMotSourceHere\SQLite3"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-dMORMOT"/>
<OtherDefines Count="1">
<Define0 Value="MORMOT"/>
</OtherDefines>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -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.

View File

@ -129,6 +129,7 @@ object FrmSoundDialog: TFrmSoundDialog
Color = clDefault
HideSelection = False
Mask = '*.wav'
ReadOnly = True
TabOrder = 1
ObjectTypes = [otNonFolders]
ShellTreeView = ShellTreeView