UI: Programs: Show Notes in Name's tooltip

This commit is contained in:
Nodir Temirkhodjaev 2024-01-17 16:33:11 +03:00
parent 060b117b07
commit da8983f397
2 changed files with 12 additions and 4 deletions

View File

@ -153,7 +153,7 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const
// Label // Label
case Qt::DisplayRole: case Qt::DisplayRole:
case Qt::ToolTipRole: case Qt::ToolTipRole:
return dataDisplay(index); return dataDisplay(index, role);
// Icon // Icon
case Qt::DecorationRole: case Qt::DecorationRole:
@ -171,7 +171,7 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const
return QVariant(); return QVariant();
} }
QVariant AppListModel::dataDisplay(const QModelIndex &index) const QVariant AppListModel::dataDisplay(const QModelIndex &index, int role) const
{ {
const int row = index.row(); const int row = index.row();
const int column = index.column(); const int column = index.column();
@ -182,7 +182,7 @@ QVariant AppListModel::dataDisplay(const QModelIndex &index) const
switch (column) { switch (column) {
case 0: case 0:
return appRow.appName; return dataDisplayAppName(appRow, role);
case 1: case 1:
return dataDisplayState(appRow); return dataDisplayState(appRow);
case 2: case 2:
@ -196,6 +196,13 @@ QVariant AppListModel::dataDisplay(const QModelIndex &index) const
return QVariant(); return QVariant();
} }
QVariant AppListModel::dataDisplayAppName(const AppRow &appRow, int role) const
{
return appRow.appName
+ (role != Qt::ToolTipRole || appRow.notes.isEmpty() ? QString()
: "\n\n" + appRow.notes);
}
QVariant AppListModel::dataDisplayState(const AppRow &appRow) const QVariant AppListModel::dataDisplayState(const AppRow &appRow) const
{ {
QString text = appStateText(appRow); QString text = appStateText(appRow);

View File

@ -60,7 +60,8 @@ protected:
private: private:
QVariant headerDataDisplay(int section) const; QVariant headerDataDisplay(int section) const;
QVariant dataDisplay(const QModelIndex &index) const; QVariant dataDisplay(const QModelIndex &index, int role) const;
QVariant dataDisplayAppName(const AppRow &appRow, int role) const;
QVariant dataDisplayState(const AppRow &appRow) const; QVariant dataDisplayState(const AppRow &appRow) const;
QVariant dataDecoration(const QModelIndex &index) const; QVariant dataDecoration(const QModelIndex &index) const;
QVariant dataForeground(const QModelIndex &index) const; QVariant dataForeground(const QModelIndex &index) const;