On 03/01/2010 09:08 AM, John McCabe-Dansted wrote:
On Mon, Mar 1, 2010 at 3:44 PM, Abdelrazak Younes<you...@lyx.org> wrote:
Menu is QMenu underneath; this indeed does not support QAbstractItemModel,
which is IMHO a hole in Qt's API.
I could extract the data from the
QAbstractItemModel and pump it into MenuItems, but would this
eliminate any elegance gained by using QAbstractItemModel?
Yes, it would still be nice to create a new method for that because this
method could be used for other purpose: the misspelled items, the navigator
menu, etc.
OK, we implement the submenu by converting std::set<...> to
QAbstractItemModel to MenuList?
No, the submenu would just have to call
'setModel(guiApp->languageModel(buffer))'. The conversion from
std::set<...> would be automatically done in
GuiApplication::languageModel().
Yes IMO. But I would rather make it:
void updateLanguageModel(QSortFilterProxyModel *, std::set<Language const
*> languages);
So we implement languageModel() as something like the following?
AbstractItemModel * GuiApplication::languageModel()
{
if (d->language_model_)
return d->language_model_;
d->language_model_ = new QSortFilterProxyModel();
updateLanguageModel(d->language_model_, lyx::languages.getLanguages());
return d->language_model_;
}
Yes :-)
And something similar for 'languageModel(Buffer *)' except that here we
would have to search the QMap instead.
Abdel.
PS: you are learning fast, it's a pleasure to discuss that with you :-)