On Sun, Feb 28, 2010 at 6:51 PM, John McCabe-Dansted <gma...@gmail.com> wrote: > On Sun, Feb 28, 2010 at 6:46 PM, Jürgen Spitzmüller <sp...@lyx.org> wrote: >> Abdelrazak Younes wrote: >>> Hum, I'd prefer that you create a new Language model for the Buffer; >>> accessible through GuiWorkArea::languageModel() or even better through >>> GuiApplication::languageModel(Buffer * buf). >>> Then sorting would be a matter of using QAbstractItemModel::sort() and >>> this model would be available for other dialogs. >> >> I'm just the herald ;-) > > OK, I think I see how this can be done. I'll submit a clean up patch.
Maybe I spoke too soon. Menus.cpp seems to use a custom class called MenuItem (not e.g. QMenuItem). This presumably doesn't support importing a QAbstractItemModel. I could extract the data from the QAbstractItemModel and pump it into MenuItems, but would this eliminate any elegance gained by using QAbstractItemModel? FYI, I have QSortFilterProxyModel * languageModel(std::set<Language const *> languages); QAbstractItemModel * languageModel(); QAbstractItemModel * languageModel(Buffer * b); The first needs to return QSortFilterProxyModel because this is the type of the lang_model_ variable that is used to cache the result of languageModel(). It seems a little ugly that the first form returns QSortFilterProxyModel, but the others return QAbstractItemModel. Should I e.g. - make the first one private? - Change lang_model_ to QAbstractItemModel - Change all the functions to return QSortFilterProxyModel -- John C. McCabe-Dansted