开发者

Creating a complex tree model in Qt

开发者 https://www.devze.com 2022-12-31 12:59 出处:网络
I\'m writing an IRC Client (yes another one). Long story short. I\'m writing a Server dialogue that keeps a list of this:

I'm writing an IRC Client (yes another one). Long story short. I'm writing a Server dialogue that keeps a list of this:

Identity
    Networks
        Channels
        Addresses

I have 3 different list views that wil开发者_StackOverflowl be for the Networks, Channels and Addresses. When the user changes the Identity (combo box). The network listview will lookup all the networks for that specific Identity. After it loads up the Networks it will automatically select the first network and then load all the channels and addresses for that specific network.

The problem is I want to have 3 views for 1 model, to minimise all the memory and the loading of data. So that it makes it much easier to manage and not do a bunch of work.

If you'd look at QColumnView it's the same exact thing. But I don't need it to be on one exact page since the views are on entirely different tabs to make it easier to go through the Server dialogue.

I'm wondering what will be the best way to go about handling this complexity. The information is stored in a SQLite database. I already have the classes written to extract and store it. Just the modelling is the painful part of this solution.


I would make a single TreeModel, and then use QSortFilterProxyModel() to display three different views on it.


The best way to doing this would be to just load the models dynamically. When the ComboBox changes Identities. Delete all the items in the NetworkList and just repopulate it afterwards and delete all the networks that were in there.

0

精彩评论

暂无评论...
验证码 换一张
取 消