PDA

View Full Version : Use Organigramm to manage database



Mefisto
10th March 2009, 19:24
Hello!

This is my first post in this forum, so a big "Hello World" ;)

I'm from germany so excuse my bad english please...

I'm currently writing a chatbot based on Regular Expression for Triggers and Outputs stored in a database. That is right now working very well and you can already chat with the bot. The bot can also make "real conversations" about the "statement->answer->forget" sheme... In the database, there are two more fields that can either specify a topic (if the field in the entry is filled) or check whether a topic is currently set and only match the regex if the topics match. Here's a short example on how that works:

User: Hello Bot!
Bot: Hello User.
User: How are you?
Bot: I'm fine, and how are you? <---- Here the topic is set to... hm, let's say "feeling"
User: I'm fine, too. <--- Now, only database fields with the "If Topic"-Field "feeling" will be compared to the user entry.
Bot: That's nice :)

That would mean, if the user would have entred the "I'm fine, too." without the question by the bot before, the bot wouldn't have recognized the answer and outputed "That's nice". But that is not too important for my question.

After I've finished the said i now want to create a dialog in that the user can modify the database, with an optimized view for my needings. I've currently an QTableView, but that doesn't look very nice with over 1000 entries for bot answers. The table showes only 20 entries so the scrollbar on the right side is very small and scrolls very much entries with every moving :)

Now i've slept over the whole thing one night and, as i hoped it would, i got a nice idea how to solve that. Above i wrote that conditions in the database can be connected via "topics" to other conditions, that can be itself be connected to some condition(s) again and so on. So the best way to solve this would be to display the database in a kind of family tree, that get it's relation-model out of the "topic" system in the database.

So my first question is: Is it possible to create some kind of family tree in QT or is there any workaround that would allow me to do it?
And the first question: Could it be used with a database as I said above?

Thanks a lot in advance,

Jonathan

wysota
11th March 2009, 11:45
Yes, it's possible although it's a bit of work. You need to implement a proxy model that will sit between the sql model and the tree view (you have to switch to using QTreeView instead of QTableView) and translate the flat model to a hierarchical one.