Sharing with harbour-vocabullary

The harbour-vocabullary app is very useful for me. I use it constantly to well… learn new vocabulary.

Today, with the help of seb, we managed to add the first sharing functionality to the Deepfish app: adding the translation results to the harbour-nemosyne database.

We did so by exporting the results to a database created and stored in the $HOME/Documents folder. I’d like to do the same thing with the vocabulary app. This means, take the results from a translation and add them to the words database of the vocabulary app.

But there are a two problems:

  • The database is stored in /home/defaultuser/.local/share/harbour-vocabulary/harbour-vocabulary .
  • There is no way to use an external database like nemosyne, only a CSV file that you can import.

Therefore the only solution right now that I can see would be to create a CSV file that the user imports with all the translations… but then he could have them duplicated.

Do you see any other option. I also tried contacting the lead dev last week, hopefully he can reply. But maybe the other two developers can see this message and we can work something out !

2 Likes

maybe in order to minimize the chance of duplicate entries, deepfish can create a new csv in every session and the user can select the appropriate one in vocabulary. but that doesn’t sound like a permanent solution

we can modify harbour-vocabulary.cpp. i asked chatgpt and i will compile it and try it out, here is the relevant part of the conversation, after i pasted the content of harbour-vocabulary.cpp: " can you see from this where the database is stored?

Yes, I can see that the path of the database is stored in the QString variable named “path”, which is created using the following line of code:

QString path = QString(QStandardPaths::writableLocation(QStandardPaths::DataLocation));

This line uses the QStandardPaths class to determine the writable location for data storage and then creates a string with that path. Then it’s appending the file name “database.sqlite3” to the path and finally the path is used to open the database.

path.append("/database.sqlite3");
QFile file(path);

So the database file is stored at the path returned by QStandardPaths::writableLocation(QStandardPaths::DataLocation) + “/database.sqlite3”.

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e)Sebastian Matkovich

can you modify the code to write the database to the users Documents directory?

Yes, I can provide you a modification of the code that will store the database in the user’s Documents directory. Here’s the modification that you need to make:

QString path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
path.append("/database.sqlite3");
QFile file(path);

This code uses QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) to determine the writable location for the user’s documents. Then it appends the file name “database.sqlite3” to the path and creates a QFile object with that path. You can change the path to point any location you want, but make sure it’s writable and readable for your application. It’s important to keep in mind that this change will only work on the platforms that have a Documents folder and also you need to make sure that the application has the permissions to read and write in the Documents folder."

1 Like

yes it works, the database is in Documents now. i uploaded my modifications here: harbour-vocabulary | OpenRepos.net — Community Repository System

1 Like

I’m trying that out then !