[WDX] Field selection with submenus

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

[WDX] Field selection with submenus

Post by *Dalai »

Hi *.*.

After having completed a large portion of content fields for a new WDX plugin, I wanted to make the field selection a little easier for the user. My plugin is able to read any number of instances of "TheThing", all of which provide the same pieces of information. I'll give an example to make it clear: A file contains "TheThing" twice, and each instance of "TheThing" can deliver 10 information fields. These information fields are of different types, some are bool, some are date/time, some are (Unicode) strings.

I'm not sure if and how this can be achieved with the TC WDX interface. Unfortunately, its documentation is lacking when it comes to examples...

Here's what I have in mind:

Code: Select all

mypluginname > regular_field1
             | regular_field2
             | regular_field3
             | subfield1 > FromTheThing1
                         | FromTheThing2
                         | FromTheThingX
             | subfield2 > FromTheThing1
                         | FromTheThing2
                         | FromTheThingX
I tried copying the "FromTheThing1|FromTheThing2|..." string to the Units variable in ContentGetSupportedField, and that works fine for strings. But it doesn't work properly for ft_boolean and ft_datetime. Although the field selection shows all "units" for the ft_datetime fields, TC always only returns the appropriate unit name but no value. And ft_boolean fields don't show the "units" in TC's search. Sure, boolean values don't have units per se, but they do show up in the field selection for custom columns.

I hope my post is not too confusing, and I also hope it's clear what I want to achieve. If not, or if there's need for code examples, please don't hesitate to ask.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: [WDX] Field selection with submenus

Post by *nsp »

@Dalai
What you picture is not "unit" but grouping which do not exists in TC plugin. A unit is normally just a flavor of the same field value with the same type.
To me using unit is not the right way as "subfield1" do not have a single value by itself. It should be better to have a naming convention with a separator to group field in a path like name, TC will have to display fields taking this into consideration. Another way would be to add in content plugin API a grouping notion where you could assign for each field a "group" for presentation only.
You could suggest to christian @ghisler(Author) this king of enhancement.
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WDX] Field selection with submenus

Post by *Dalai »

Thanks for your response.
nsp wrote: 2022-06-20, 05:39 UTCA unit is normally just a flavor of the same field value with the same type.
Well, that's what these subfields shown above are supposed to be. Let's say, subfield1 is of type ft_string (or ft_stringw, doesn't matter), and subfield2 is of type ft_datetime. They're still of these same types, regardless of where they get their information from, be it "FromTheThing1" or "FromTheThing2" or somewhere else. Sure, they're not the same field value but definitely the same field type.
You could suggest to christian @ghisler(Author) this kind of enhancement.
First, I need to understand how this all works. Then I can think about whether or not it makes sense to make a suggestion. Keep in mind that waiting for a suggestion to be implemented has obvious drawbacks, and I intend to make my plugin work with a wide range of TC versions.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: [WDX] Field selection with submenus

Post by *nsp »

If you give a look to the documentation on github, https://github.com/ghisler/WDX-SDK/ for ContentGetSupportedField and ContentGetValue you could see the you can return a different type than the one defined in ContentGetSupportedField.

In you case, i would only define a numeric for the "subfield" and then other type for the unit values
Subfield1 -> units FromTheThing1,..............FromTheThingX
- - -
Subfieldn -> units FromTheThing1,..............FromTheThingX

If no unit is provided, you can return subfield number and then return matching type for the units.

This is not the common understanding but should work for you. // you will not have units for the returned value as you already consumed it for presentation.
Also i do not know how sorting will work and if you can apply format for datetime ?
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WDX] Field selection with submenus

Post by *Dalai »

Yes, I know the field type can be returned differently in ContentGetSupportedField and ContentGetValue. But I don't think it would do me any good.
nsp wrote: 2022-06-20, 14:45 UTCIn you case, i would only define a numeric for the "subfield" and then other type for the unit values
I don't understand. Units don't have types, only fields do. Or what do you mean by "unit values"?

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: [WDX] Field selection with submenus

Post by *nsp »

Dalai wrote: 2022-06-20, 19:25 UTC
I don't understand. Units don't have types, only fields do. Or what do you mean by "unit values"?
What i mean is:
  • For subfield1 in ContentGetSupportedField you return a ft_numeric32 or ft_string or ft_stringW as type to be able to define Units String and have it operational in TC.
  • Do not return date/time/bool for field definition in ContentGetSupportedField.
  • Inside ContentGetValue if a unit Index is passed return the "good" type and fiedValueForIndex as it should. (this is what i mean as unit type)
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WDX] Field selection with submenus

Post by *Dalai »

nsp wrote: 2022-06-21, 05:07 UTCWhat i mean is:
  • For subfield1 in ContentGetSupportedField you return a ft_numeric32 or ft_string or ft_stringW as type to be able to define Units String and have it operational in TC.
  • Do not return date/time/bool for field definition in ContentGetSupportedField.
  • Inside ContentGetValue if a unit Index is passed return the "good" type and fiedValueForIndex as it should. (this is what i mean as unit type)
Ah, now I get it.

Unfortunately, this doesn't work properly. In TC's search, every field is now considered a string field (since that's what the plugin returns), i.e. only string operators are shown. This is not what I want or what a user expects. In other words, ContentGetSupportedField needs to return the correct field type to make TC's search provide the proper operators for a field.

Furthermore, ft_datetime fields still only show the unit without any value. Example: When something like

Code: Select all

[=plugin.subfield1.FromTheThing1]
is defined in a column, TC just shows "FromTheThing1" in the column, despite "FromTheThing1" being the <default>. Only when the "FromTheThing1" is removed, TC shows the value.

It looks like I have to find another way to make this work.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: [WDX] Field selection with submenus

Post by *nsp »

In the search, you cannot search taking into account units. So it will never work unless Christian implement it and this is mainly why we should consider that he units only reflect a rendering of the same value.

With date/time, units are stripped down to let a format string to take place. (This could be considered as a bug) just try with a unit like YMD.
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WDX] Field selection with submenus

Post by *Dalai »

nsp wrote: 2022-06-21, 16:10 UTCIn the search, you cannot search taking into account units.
Oh, but they can, and they need to be taken into account. If a plugin provides custom units, they're shown in TC's search as an additional dropdown under "Value". Take the NTLinks plugin for example. It has a field named RP_Target with units Natural and Symbolic. A user needs to be able to search for files with any of these "units". Or the TCMediaInfo plugin which provides several Bitrate fields with different units (Bps through Mbps). Or the TrID_Identifier plugin which has several fields, all of which have units Extension, Name and Accuracy. And there are more plugins out there.
[...] this is mainly why we should consider that he units only reflect a rendering of the same value.
But they're not, at least not necessarily, see examples above.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: [WDX] Field selection with submenus

Post by *nsp »

Dalai wrote: 2022-06-21, 18:14 UTC
nsp wrote: 2022-06-21, 16:10 UTCIn the search, you cannot search taking into account units.
Oh, but they can, and they need to be taken into account. If a plugin provides custom units, they're shown in TC's search as an additional dropdown under "Value". ...
[...] this is mainly why we should consider that he units only reflect a rendering of the same value.
But they're not, at least not necessarily, see examples above.
You can return different type for any unit of a field but the operators are only defined at field level by default using field type. This is why field.unit work ok in column but search is not completelly implemented in TC. (Not working in your case as TC will do the comparison with wrong operators...)

If you want your own operators and do the comparison by yourself, you need to implement specific functions(Which make the work a bit more complicated and only works after TC 10.0).

Code: Select all

int __stdcall ContentGetSupportedFieldFlags(int FieldIndex);

int __stdcall ContentGetSupportedOperators(int FieldIndex, char* FieldOperators, int maxlen);

int __stdcall ContentFindValue(char* FileName, int FieldIndex, int UnitIndex, int OperationIndex, int FieldType, int flags, void* FieldValue);
int __stdcall ContentFindValueW(WCHAR* FileName, int FieldIndex, int UnitIndex, int OperationIndex, int FieldType, int flags, void* FieldValue);
But the fields with contflags_fieldsearch are not usable in column.....
see viewtopic.php?p=409912
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WDX] Field selection with submenus

Post by *Dalai »

Yes, well, that's not gonna happen. Too much work to implement and not wide enough range of supported TC versions.

For now, I've implemented it as a flat menu structure, like this:

Code: Select all

mypluginname > regular_field1
             | regular_field2
             | regular_field3
             | separator
             | TheThing1 subfield1
             | TheThing1 subfield2
             | TheThing1 subfield3
             | separator
             | TheThing2 subfield1
             | TheThing2 subfield2
             | TheThing2 subfield3
It's configurable via INI how many "TheThing"s are supposed to be shown. Took quite a while to get the right formula for the different indices and so on. However, it's the kind of presentation that I don't like very much, because it gets nasty to select an item from a menu with two dozen items or more. And it has a drawback when it comes to language files: each subfield name needs to appear as often as there are "TheThing"s... well, there's always something ;).

Maybe someone has an idea how to make the presentation/field selection better once I release the plugin to the public.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Post Reply