The inflexibility of adding data to a multilist


14-08-2009 01:43:10

I've just got some questions/ideas regarding how data (items) are added to a multi list. From my understanding, you must begin by adding an "item", for which you can specify the data to be put in the first column only. You then need to find the index of the item you added (for which you have only the data you entered into the first column on initialisation), so you can add data to the other columns of the item separately, like this:
multiList.addItem("column 1 data");
multiList.setSubItemNameAt(1, serverList->findSubItemWith(0, "column 1 data"), "column 2 data";
multiList.setSubItemNameAt(2, serverList->findSubItemWith(0, "column 1 data"), "column 3 data";
// ...

Using the above code, you are wholly dependant on the first column's data being a unique key, which can severely limit your choice of column layout. Is there another way to do the above which I have missed?

In any case, what about having addItem() and insertItemAt() return the index of where the item was added? This would allow one to create the entire item without requiring a column for a unique key et al, and shouldn't break the interface either.

Another feature that might be useful, would be and overloaded version of addItem() with a vector of strings as a parameter, which could be used to initialise all the columns of the item in one go.

What do you think?

- Andreas