Recent

Author Topic: TVPlanit Reboot  (Read 35669 times)

wp

  • Hero Member
  • *****
  • Posts: 12859
Re: TVPlanit Reboot
« Reply #30 on: July 02, 2016, 09:38:21 pm »
In my demo it is inside a tabsheet of a pagecontrol as well. Just set Align to alClient.

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #31 on: July 02, 2016, 09:41:11 pm »
In my demo it is inside a tabsheet of a pagecontrol as well. Just set Align to alClient.

I know. Same as in my application too, but my application has a bottom button panel that sort of masked the last hour of the day in the DayView. I just removed it and it was OK.
« Last Edit: October 02, 2016, 11:36:14 am by JD »
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

wp

  • Hero Member
  • *****
  • Posts: 12859
Re: TVPlanit Reboot
« Reply #32 on: July 02, 2016, 10:04:23 pm »
Just to make sure if this isn't another bug of the tvplanit controls: if the bottom panel is bottom-aligned and the dayView is client-aligned, both within the same tabsheet, then they should be out of their way.

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #33 on: July 02, 2016, 11:13:00 pm »
Just to make sure if this isn't another bug of the tvplanit controls: if the bottom panel is bottom-aligned and the dayView is client-aligned, both within the same tabsheet, then they should be out of their way.

The bottom panel is bottom aligned in a panel. The tabsheet is client aligned in the same panel & the day view is client aligned in the tabsheet. No problems, I just removed the bottom panel  :D.

A new issue just arose. I use DrawingStyle of dsNone for the WeekView to completely eliminate borders & it worked before but in the recent updates, it says DrawingStyle not supported. Is this deliberate? I can always change the options in any case.

JD
« Last Edit: July 02, 2016, 11:29:22 pm by JD »
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

wp

  • Hero Member
  • *****
  • Posts: 12859
Re: TVPlanit Reboot
« Reply #34 on: July 02, 2016, 11:29:57 pm »
A new issue just arose. I use DrawingStyle of dsNone for the WeekView and MonthView to completely eliminate borders & it worked before but in the recent updates, it says DrawingStyle not supported. Is this deliberate? I can always change the options in any case.
Oh - I thought there are only the two options dsFlat and ds3D, my fault... I spent some time today in rewriting the style dsFlat such that no 3d-bevels are displayed. Yes, you are right, dsNone is useful for some "super-flat", borderless option (maybe I should take the freedom to rename it to dsNoBorder). But even after I'll remove the exception added today I guess it will not work well because there are many if constructs which do not consider a third case. Of course, this can be fixed.

I made some progress with printing now. It is now possible to display the full page in the preview. I still see some bugs. Once they are fixed I'll update the demo to show this feature.

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #35 on: July 03, 2016, 12:01:28 am »
A new issue just arose. I use DrawingStyle of dsNone for the WeekView and MonthView to completely eliminate borders & it worked before but in the recent updates, it says DrawingStyle not supported. Is this deliberate? I can always change the options in any case.
Oh - I thought there are only the two options dsFlat and ds3D, my fault... I spent some time today in rewriting the style dsFlat such that no 3d-bevels are displayed. Yes, you are right, dsNone is useful for some "super-flat", borderless option (maybe I should take the freedom to rename it to dsNoBorder). But even after I'll remove the exception added today I guess it will not work well because there are many if constructs which do not consider a third case. Of course, this can be fixed.

dsNone makes the controls look more "modern".

I made some progress with printing now. It is now possible to display the full page in the preview. I still see some bugs. Once they are fixed I'll update the demo to show this feature.

That's great.
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

wp

  • Hero Member
  • *****
  • Posts: 12859
Re: TVPlanit Reboot
« Reply #36 on: July 03, 2016, 11:44:29 am »
New DrawingStyle dsNoBorder (replaces the former dsNone). If you had used dsNone somewhere in the lfm file be prepared of errors at loading. To avoid this load the lfm file into a text editor and replace all dsNone by dsNoBorder.

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #37 on: July 03, 2016, 12:39:20 pm »
New DrawingStyle dsNoBorder (replaces the former dsNone). If you had used dsNone somewhere in the lfm file be prepared of errors at loading. To avoid this load the lfm file into a text editor and replace all dsNone by dsNoBorder.

I already experienced this yesterday. I was forced to restore from an old backup to be able to continue. I'll try out the new property ASAP.
« Last Edit: July 03, 2016, 01:09:35 pm by JD »
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #38 on: July 03, 2016, 07:27:17 pm »
I'm a little stumped. I have a form with a VpDayView, TVpBufDSDatastore and TVpControlLink. I pull resource and event data from a remote database and I copy it manually into the TVpBufDSDatastore Resource and Events using two procedures I wrote LoadTVPResource and LoadTVPEvents. See below

Code: [Select]
// LoadTVPResource
procedure TfrmMain.LoadTVPResource(
  ADatastore: TVpBufDSDatastore; AJSON: string);
var
  intGridRow, intNumberOfSQLQueryRows: integer;
  // JSON related variables
  jsParser: TJSONParser;
  jsArrayRow: TJSONArray;
  jsObj: TJSONObject;
begin
  //
  if AJSON = EmptyStr then
    exit;
 
  // create the json parser
  jsParser    := TJSONParser.Create(AJSON);
  //
  try
    // Parse the JSON data
    jsArrayRow  := jsParser.Parse as TJSONArray;
    //
    try
      // get the number of rows returned by the query in the JSON data object
      intNumberOfSQLQueryRows := jsArrayRow.Count;
      // Empty the dataset
      ADataStore.ResourceTable.Close;
      ADataStore.ResourceTable.Open;
      //AComboBox.Clear;
      // append the json rows to the grid
      for intGridRow := 0 to Pred(intNumberOfSQLQueryRows) { - 1} do
      begin
        // assign the object to jsObj
        jsObj := jsArrayRow.Objects[intGridRow];
        //
        try
          // All events related to a particular resource
          //
          with ADataStore.ResourceTable do
          begin
            //
            Append;
            //
            if not jsObj.Items[0].IsNull then
              FieldByName('resourceid').AsInteger         := jsObj.Items[0].AsInteger
            else
              FieldByName('resourceid').Clear;
            //
            if not jsObj.Items[2].IsNull then
              FieldByName('description').AsString       := jsObj.Items[2].AsString
            else
              FieldByName('description').Clear;
            //
            if not jsObj.Items[3].IsNull then
              FieldByName('notes').AsString          := jsObj.Items[3].AsString
            else
              FieldByName('notes').Clear;
            //
            if not jsObj.Items[4].IsNull then
              FieldByName('imageindex').AsInteger         := jsObj.Items[4].AsInteger
            else
              FieldByName('imageindex').Clear;
            //
            if not jsObj.Items[5].IsNull then
              FieldByName('resourceactive').AsBoolean      := jsObj.Items[5].AsBoolean
            else
              FieldByName('resourceactive').Clear;
          end;
        finally
          //
          jsObj.Clear;
        end;
      end;      // for intGridRow := 0 to intNumberOfSQLQueryRows - 1 do
    finally
      //
      jsArrayRow.Free;
    end;          // try...finally (jsParser := TJSONParser.Create(AJSString))
  finally
    // free the jsParser
    FreeAndNil(jsParser);
  end;
  //
  ADataStore.ResourceTable.Active := True;
end;


Code: [Select]
// LoadTVPEvents
procedure TfrmMain.LoadTVPEvents(
  ADatastore: TVpBufDSDatastore; AJSON: string);
var
  intGridRow, intNumberOfSQLQueryRows: integer;
  // JSON related variables
  jsParser: TJSONParser;
  jsArrayRow: TJSONArray;
  jsObj: TJSONObject;
begin
  //
  if AJSON = EmptyStr then
    exit;

  // create the json parser
  jsParser    := TJSONParser.Create(AJSON);
  //
  try
    // Parse the JSON data
    jsArrayRow  := jsParser.Parse as TJSONArray;
    //
    try
      // get the number of rows returned by the query in the JSON data object
      intNumberOfSQLQueryRows := jsArrayRow.Count;
      // Empty the dataset
      ADataStore.EventsTable.Close;
      ADataStore.EventsTable.Open;
      // append the json rows to the grid
      for intGridRow := 0 to Pred(intNumberOfSQLQueryRows) { - 1} do
      begin
        // assign the object to jsObj
        jsObj := jsArrayRow.Objects[intGridRow];
        //
        try
          // All events related to a particular resource
          //
          with ADataStore.EventsTable do
          begin
            //
            Append;
            //
            if not jsObj.Items[0].IsNull then
              FieldByName('recordid').AsInteger         := jsObj.Items[0].AsInteger
            else
              FieldByName('recordid').Clear;
            //
            if not jsObj.Items[1].IsNull then
              FieldByName('resourceid').AsInteger         := jsObj.Items[1].AsInteger
            else
              FieldByName('resourceid').Clear;
            //
            if not jsObj.Items[3].IsNull then
              FieldByName('starttime').AsDateTime       := SQLDateToDateTime(jsObj.Items[3].AsString)
            else
              FieldByName('starttime').Clear;
            //
            if not jsObj.Items[4].IsNull then
              FieldByName('endtime').AsDateTime         := SQLDateToDateTime(jsObj.Items[4].AsString)
            else
              FieldByName('endtime').Clear;
            //
            if not jsObj.Items[5].IsNull then
              FieldByName('description').AsString       := jsObj.Items[5].AsString
            else
              FieldByName('description').Clear;
            //
            if not jsObj.Items[6].IsNull then
              FieldByName('location').AsString          := jsObj.Items[6].AsString
            else
              FieldByName('location').Clear;
            //
            if not jsObj.Items[7].IsNull then
              FieldByName('notes').AsString             := jsObj.Items[7].AsString
            else
              FieldByName('notes').Clear;
            //
            if not jsObj.Items[8].IsNull then
              FieldByName('category').AsInteger         := jsObj.Items[8].AsInteger
            else
              FieldByName('category').Clear;
            //
            if not jsObj.Items[9].IsNull then
              FieldByName('alldayevent').AsBoolean      := jsObj.Items[9].AsBoolean
            else
              FieldByName('alldayevent').Clear;
            //
            if not jsObj.Items[10].IsNull then
              FieldByName('dingpath').AsString          := jsObj.Items[10].AsString
            else
              FieldByName('dingpath').Clear;
            //
            if not jsObj.Items[11].IsNull then
              FieldByName('alarmset').AsBoolean         := jsObj.Items[11].AsBoolean
            else
              FieldByName('alarmset').Clear;
            //
            if not jsObj.Items[12].IsNull then
              FieldByName('alarmadvance').AsInteger         := jsObj.Items[12].AsInteger
            else
              FieldByName('alarmadvance').Clear;
            //
            if not jsObj.Items[13].IsNull then
              FieldByName('alarmadvancetype').AsInteger     := jsObj.Items[13].AsInteger
            else
              FieldByName('alarmadvancetype').Clear;
            //
            if not jsObj.Items[14].IsNull then
              FieldByName('snoozetime').AsDateTime      := SQLDateToDateTime(jsObj.Items[14].AsString)
            else
              FieldByName('snoozetime').Clear;
            //
            if not jsObj.Items[15].IsNull then
              FieldByName('repeatcode').AsInteger       := jsObj.Items[15].AsInteger
            else
              FieldByName('repeatcode').Clear;
            //
            if not jsObj.Items[16].IsNull then
              FieldByName('repeatrangeend').AsDateTime  := SQLDateToDateTime(jsObj.Items[16].AsString)
            else
              FieldByName('repeatrangeend').Clear;
            //
            if not jsObj.Items[17].IsNull then
              FieldByName('custominterval').AsBoolean   := jsObj.Items[17].AsBoolean
            else
              FieldByName('custominterval').Clear;
          end;
        finally
          //
          jsObj.Clear;
        end;
      end;      // for intGridRow := 0 to intNumberOfSQLQueryRows - 1 do
    finally
      //
      jsArrayRow.Free;
    end;          // try...finally (jsParser := TJSONParser.Create(AJSString))
  finally
    // free the jsParser
    FreeAndNil(jsParser);
  end;
  //
  ADataStore.EventsTable.Active := True;
  //
  if not ADataStore.Connected then ADataStore.Connected := True;
end;

The problem is I don't see the events on the VpDayView in the form. The DayView keeps saying no resource has been selected. Does that mean I have to somehow use a TVpResourceCombo no matter what?

Thanks,

JD
« Last Edit: July 03, 2016, 07:29:30 pm by JD »
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

wp

  • Hero Member
  • *****
  • Posts: 12859
Re: TVPlanit Reboot
« Reply #39 on: July 03, 2016, 08:00:16 pm »
Could it be that the "Post" is missing for both datasets?

Is this code happening when the datastore is connected? In order so see the new records in the planner controls there must be more code. In particular you must create TVpEvent and TVpResource instances and add them to the internal lists. This is the primary storage location. The ini datastore shows that the components do not need anything else. The datasets or ini file are just needed to get persistent data, i.e. to keep data after the program ends.

I think it would be easier to disconnect the datastore while adding the data from the remote db, copy the data to the buf datasets like you do and then reconnect to rebuild the internal data structures. To access the resource, events etc. datasets while the datastore is closed you can open these dataset manually - I think your sequence of xxxTable.Close and xxxTable.Open is correct.

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #40 on: July 03, 2016, 08:22:10 pm »
Could it be that the "Post" is missing for both datasets?

Is this code happening when the datastore is connected? In order so see the new records in the planner controls there must be more code. In particular you must create TVpEvent and TVpResource instances and add them to the internal lists. This is the primary storage location. The ini datastore shows that the components do not need anything else. The datasets or ini file are just needed to get persistent data, i.e. to keep data after the program ends.

I think it would be easier to disconnect the datastore while adding the data from the remote db, copy the data to the buf datasets like you do and then reconnect to rebuild the internal data structures. To access the resource, events etc. datasets while the datastore is closed you can open these dataset manually - I think your sequence of xxxTable.Close and xxxTable.Open is correct.

The VpBufDSDataset has Autoconnect = true and AutoCreate = true. Do I still need to manually create TVpResource and TvpEvent instances when AutoCreate is true.
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

wp

  • Hero Member
  • *****
  • Posts: 12859
Re: TVPlanit Reboot
« Reply #41 on: July 03, 2016, 08:35:31 pm »
No. AutoCreate refers to creation of the database tables.

I'd turn both AutoXXXX off in object inspector. When you run your program for the first time, the tables do not yet exist. Call TVpDatastore.CreateTables to create the tables. Then use your own procedure to populate the tables with the data from the remote DB, I'm not sure if the datastore can be connected during this, maybe it's better to turn it off. Finally set Datastore.Connected to true in order to load data into the internal structures.

When the program runs later when the tables already exist and have been populated just set Datastore.Connected to true in FormCreate.

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #42 on: July 03, 2016, 09:21:25 pm »
No. AutoCreate refers to creation of the database tables.

I'd turn both AutoXXXX off in object inspector. When you run your program for the first time, the tables do not yet exist. Call TVpDatastore.CreateTables to create the tables. Then use your own procedure to populate the tables with the data from the remote DB, I'm not sure if the datastore can be connected during this, maybe it's better to turn it off. Finally set Datastore.Connected to true in order to load data into the internal structures.

When the program runs later when the tables already exist and have been populated just set Datastore.Connected to true in FormCreate.

I did exactly that but it still says No Resource Selected when I click the DayView. However when I accepted to select a resource, it showed me the resource I had added in the code above. So the data is there, it is just that the resource is not being loaded. How do I load the resource from the code?
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

wp

  • Hero Member
  • *****
  • Posts: 12859
Re: TVPlanit Reboot
« Reply #43 on: July 03, 2016, 09:43:15 pm »
In the BufDSDatastore demo I am doing this:
Code: Pascal  [Select][+][-]
  1. var
  2.   lastRes: TVpResource;
  3. ...
  4.   if VpBufDSDatastore1.Resources.Count > 0 then
  5.   begin
  6.     // Find the last resource ID value
  7.     lastRes := VpBufDSDatastore1.Resources.Items[VpBufDSDatastore1.Resources.Count-1];
  8.     VpBufDSDatastore1.ResourceID := lastRes.ResourceID;  
  9.     // or: store the ID of the currently loaded Resource in a cfg file and restore it like this
  10.     // VpBufDSDatastore1.ResourceID := resourceID_from_cfg_file;  // resourceID value read from cfg file
  11.   end;
  12.  

JD

  • Hero Member
  • *****
  • Posts: 1906
Re: TVPlanit Reboot
« Reply #44 on: July 03, 2016, 10:28:25 pm »
@wp Thanks for pointing that out. Now it loads the Resource. But the two events associated with the resource are not displayed in the DayView.

What am I missing?

Thanks,

JD
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

 

TinyPortal © 2005-2018