X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=dev-notes%2Fcode_policy.txt;fp=dev-notes%2Fcode_policy.txt;h=b86788d5373463312a43dcb14d02d60cf111df0f;hp=0000000000000000000000000000000000000000;hb=0d8b43cb8f3e1cedd57983c66f2b1108e1df010f;hpb=122b548bc61795a71aba52cb3c4876280295c4bc diff --git a/dev-notes/code_policy.txt b/dev-notes/code_policy.txt new file mode 100644 index 00000000..b86788d5 --- /dev/null +++ b/dev-notes/code_policy.txt @@ -0,0 +1,26 @@ +This file is intended to keep notes about general coding stuff, code +conventions or how to best interact with certain parts of Qt. + + + +Regarding QSortFilterProxyModel: +======================================== +When subclassing QSortFilterProxyModel avoid the use of the following +calls on QModelIndex and use their equivalents of QAbstractItemModel: + +inline QModelIndex QModelIndex::parent() const +inline QModelIndex QModelIndex::sibling(int arow, int acolumn) const +inline QModelIndex QModelIndex::child(int arow, int acolumn) const +inline QVariant QModelIndex::data(int arole) const +inline Qt::ItemFlags QModelIndex::flags() const + +For Example when reimplementing QSortFilterProxyModel::data(const +QModelIndex &idx, int role): + +Avoid: + idx.data(role); + +Instead: + QModelIndex source_index = mapToSource(idx); + sourceModel()->data(idx, role); +