On 02/21/2018 11:16 PM, Stefan Giese wrote:
Yes but I don't want to write a script to populate my directories with foo.qml... What I want is to have foo.qml applied to foo.shp whenever I open a foo.shp. If I was just opening a few shape files occasionally I would just apply the style the way I do now which is to load Style.
I get lots of shapefiles that come in a deep directory tree. I load the whole directory tree using the excellent plug-in load them all but then I have to go in and manually apply the styles. I occasionally use another excellent plugin multiqml to apply Styles in a somewhat automated fashion but it's still difficult.
I thought I had heard of some way to do this but couldn't google the right thing. So I discovered by browsing the qgis source code that whenever it loads a new map layer, in addition to checking for a foo.qml file, it checks a sqlite db qgis.qmldb (actually it checks for qgis.qmldb in the settings path and resources/qgis.qmldb and the project path projectbasename.qmldb) and I thought I could use this. I couldn't find any instructions on how to create the sqlite database but I did find an example by Googling and I created my own.
Initially I tried using foo.shp as the key but that didn't work. Once I discovered how to build a debug qgis version I discovered that unfortunately this looks for the full path instead of just foo.shp, actually it is the full path/foo.qml. So I don't have to put foo.qml files all throughout my directory tree but I still have to have a separate entry for each foo file in this qml database.
So I added one more test where it takes just the file name so foo.qml and searches for that in the qml database in the application settings directory. For me this works great I can load a whole bunch of shape files using load them all and they all get the style that I want!
This is what I changed the code to:
_______________________________________________ Qgis-user mailing list Qgisemail@example.com List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user