On 03/01/2010 07:07 AM, John McCabe-Dansted wrote:
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.
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.
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?
Yes IMO. But I would rather make it:
void updateLanguageModel(QSortFilterProxyModel *, std::set<Language const
*> languages);
- Change lang_model_ to QAbstractItemModel
No, but I would create a new private member:
QMap<Buffer *, QSortFilterProxyModel *> buffer_language_models_;
- Change all the functions to return QSortFilterProxyModel
No.
Abdel.