Show C type definition in tooltip in Types widget (#3169)

This commit is contained in:
Lucas Hosseini 2023-05-06 03:53:40 +02:00 committed by GitHub
parent 68b3cb1004
commit 8c89dfde8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -14,6 +14,17 @@ TypesModel::TypesModel(QList<TypeDescription> *types, QObject *parent)
{
}
QVariant TypesModel::toolTipValue(const QModelIndex &index) const
{
TypeDescription t = index.data(TypesModel::TypeDescriptionRole).value<TypeDescription>();
if (t.category == "Primitive") {
return QVariant();
}
return Core()->getTypeAsC(t.type).trimmed();
}
int TypesModel::rowCount(const QModelIndex &) const
{
return types->count();
@ -45,6 +56,8 @@ QVariant TypesModel::data(const QModelIndex &index, int role) const
default:
return QVariant();
}
case Qt::ToolTipRole:
return toolTipValue(index);
case TypeDescriptionRole:
return QVariant::fromValue(exp);
default:

View File

@ -30,6 +30,11 @@ class TypesModel : public QAbstractListModel
private:
QList<TypeDescription> *types;
/**
* @brief Returns a description of the type for the given index
*/
QVariant toolTipValue(const QModelIndex &index) const;
public:
enum Columns { TYPE = 0, SIZE, CATEGORY, FORMAT, COUNT };
static const int TypeDescriptionRole = Qt::UserRole;