[Kmymoney-devel] Plugin Config File Install

Allan agander93 at gmail.com
Fri Dec 30 17:18:02 UTC 2011


On 30/12/11 15:04, Thomas Baumgart wrote:
> Hi,
>
> on Friday 30 December 2011 14:13:15 Allan wrote:
>
>> I'm progressing with adding profiles to the csv plugin, and have a
>> startup-type query.
>>
>> Each profile has its own group within the config file, and because the
>> config for brokers is, well, complicated, I want to include the two
>> broker configs that I've done in the plugin config file, which I install
>> in /user/share/.....
>>
>> So, after installation, those two sections are available, and I load
>> into memory from the default config file the parameters for the chosen
>> profile.  When the plugin is closed, the current parameters are saved to
>> the user's ~/.kde/4 config location, but this new file contains only the
>> one profile, the one that was first loaded.
>>
>> So, the question is, how do I get the two profiles into the user's
>> config file?  Is there a way to install into the user's .kde folder
>> rather than /usr/share/... ?  I could, I suppose  supply the absolute
>> path, but is there a KDEDIR version I can use?  (I've used the absolute
>> path now, which is OK, but doesn't allow for distros that use ~/.kde
>> instead of ~/.kde4.)  Or, do I have to resort to copying groups from the
>> default config into the one that gets saved locally?  That doesn't seem
>> the right approach, but...
>
> Instead of using
>
>    KSharedConfigPtr config =
> KSharedConfig::openConfig(KStandardDirs::locateLocal("config",
> "csvimporterrc"));
>
> I suggest to supply a method in CsvImporterPlugin as follows:
>
> KSharedConfigPtr* CsvImporterPlugin::config(void)
> {
>    return component().isValid() ? component().config() : 0;
> }
>
> and use that to extract the config pointer. You could also pass that pointer
> to CsvDialog and it's sub-ordinate objects in the ctor if you like.
>
> Your config file will be named kmm_csvimportrc just like the plugin. This does
> not solve your initial problem, but adds to have clean code.
>

Thanks, I'll look into that to see what it does for me, but at the 
moment I haven't found what component() actually is, or relates to.

>
> I am not sure if I understand the problem 100%. You say you have two groups in
> your global config file and you can select from them. Then in the local file,
> only one appears. Does this mean, you cannot access the other one at all after
> you have once selected a profile or what?
>
> A pointer to the code locations you talk about would be of help here.
>

Sorry, it's just in my sandbox at the moment, but I'll have another go 
at explaining.

Eventually, each profile, of which there could be several, depending on 
csv file structure, will have an entry in a combobox, allowing the user 
to select the one he wants.  Again, eventually, the config file will 
have a group for each profile, containing its column numbers, start and 
end lines, date format, etc.  So, in real life, the user adds a new 
profile, loads his file and enters the column numbers.  When the user 
closes the plugin, the profile is saved in the config file, identified 
by its profile name.  All this works fine.

The complication is that for brokers, and to an extent for investments, 
each institution identifies investment activity types in a different 
way.  There could be a column containing just the activity type (not 
standardised), or it could be tucked away in a detail column, hopefully 
with some identifying prefix.  Then, the actual activities are 
identified in different ways too.  So things get a bit complex.  I 
therefore thought it would be a good idea to include a couple of sample 
broker profiles in the source that could be used by the user for guidance.

Normally, the user would select his profile and that would get loaded 
into the UI etc.  However, immediately after installation, there is a 
default config file containing two profiles.  When the user finishes and 
closes the plugin, his profile gets saved into his local config file 
folder.  The other profile which wasn't selected, doesn't get saved 
locally because it was never loaded, and it's that problem I'm trying to 
resolve.

I install the default config file with its two profiles into 
/usr/share/..., but the locally saved version contains only the one that 
was selected and loaded.

If, instead of installing into /usr/share/..., I installed locally into 
~/.kde, that would solve the problem, except some distros use ~/.kde4 
and some use ~/.kde, so I can't use an absolute path.  So, I don't know 
how to install into a variable local folder, without knowing how to 
identify it to KDE and make, etc.

I could avoid the issue altogether by putting the sample profiles into 
contribs, but the user needs to know to look there, and not everyone 
wants to resort to using the handbook right at the start.

I hope that's a more complete explanation of the problem.

Allan


More information about the KMyMoney-devel mailing list