olivierkes / manuskript

A open-source tool for writers
http://www.theologeek.ch/manuskript
GNU General Public License v3.0
1.71k stars 226 forks source link

Data format documentation #1213

Closed kylegoetz closed 10 months ago

kylegoetz commented 10 months ago

Is there documentation anywhere of the actual data format of the whole "book" model? When I look at the code, it seems like the world, for example, is an array of pointers to Qt "item" objects of some sort.

I wanted to write an alternative UI in Swift for a native Manuskript app in macOS and probably also a web interface that talks to a server, but leverage all the non-UI parts of the Manuskript code. Essentially splitting Manuskript into manuskript and manuskript-ui (which is the Qt stuff).

However, it seems pretty much everything outside the ui module still relies on ui code (via Qt imports), and beyond that I can't find documentation on the data format the application uses so I can even begin the process of removing Qt-dependence from non-UI portions of the codebase.

Is there documentation available? Or is there no way to work with the data other than through Qt?

It seems there's some talk #1108 about porting to GTK, which I assume would involve this exact same effort. Any guidance would be appreciated.

kylegoetz commented 10 months ago

For example, worldModel might contain the data related to the world, but it also manages which sections are expanded and contracted, which is a UI thing, but this worldModel is not in the ui module but outside it. The importers and exporters are similar: would it be better if they receive the worldModel and open a file and write it in the defined export format without relying on UI code?

For example, World would have WorldItem[], and WorldItem has Name, Description, Conflict, and Passion. Is there any data type that just holds this? Or is it all immediately stored in Qt window objects and then never put back into any other format until you save/export?

TheJackiMonster commented 10 months ago

So what you probably want to look into is the gtk branch which contains the changes we made so far refactoring the UI. It's still very much in development. But some thing I did for it was separating the data representation completely from the actual UI which had not been done properly with Qt.

You can find all of the code regarding the data models here and I also separated the code for loading as well as saving changes on disk in files generally handling the IO. So it's much more legible than it has been before that where all different file formats where mixed in one single file to load and save a project. You can find this newer IO code here.

I hope this helps. If you encounter any issues with that code, please let me know since we are using it in the GTK efforts already and I want to make sure it has full compatibility later on with projects from the previous Qt based code base.

kylegoetz commented 10 months ago

Thanks! I can see a lot of work has gone into the refactoring! I did a really rough and dirty start just based off how the UI looked, probably just 10 minutes of effort so far, and I'm glad I can stop. :)