X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fdelegates%2Fcomboboxdelegate.cpp;h=3f83f1dac5056dc2ddad0e12daf1108655c3a91e;hb=a68e838647f7b2646a4de343e879afc81c57a3ad;hp=e060ae16c9a1788d22b1560bf8729156986e89a1;hpb=6aa828d1255e83dbc51df7b3ef88d5cfcdc68b75;p=emufront diff --git a/src/delegates/comboboxdelegate.cpp b/src/delegates/comboboxdelegate.cpp index e060ae1..3f83f1d 100644 --- a/src/delegates/comboboxdelegate.cpp +++ b/src/delegates/comboboxdelegate.cpp @@ -32,16 +32,19 @@ void ComboBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti // get the item id from the hosting view's model int objid = index.model()->data(index, Qt::DisplayRole).toInt(); - // find matching object from QComboBox's model + // find a matching object from the editor's model QModelIndex startInd = cbmodel->index(0, cbmodelIdColumn); QModelIndexList indList = cbmodel->match(startInd, Qt::DisplayRole, objid); + // If an object was found in the editor's model create an index to the editor's model QModelIndex ind = indList.empty() ? QModelIndex() : cbmodel->index(indList.first().row(), cbmodelDisplayColumn); + // Get the name field of an object using the created index QString txt = ind.isValid() ? cbmodel->data(ind).toString() : ""; + // Render the name text painter->save(); painter->drawText(option.rect, txt); painter->restore();