UI: TableView::selectedText: Use tool-tip when display text is empty

This commit is contained in:
Nodir Temirkhodjaev 2024-09-12 18:22:06 +05:00
parent b0296048d6
commit fab68363d1
2 changed files with 12 additions and 2 deletions

View File

@ -75,13 +75,22 @@ QString TableView::selectedText() const
prevColumn = column; prevColumn = column;
} }
const QString s = model()->data(index).toString(); text.append(cellText(index));
text.append(s);
} }
return text; return text;
} }
QString TableView::cellText(const QModelIndex &index) const
{
const QString displayText = model()->data(index).toString();
if (!displayText.isEmpty())
return displayText;
const QString tooltipText = model()->data(index, Qt::ToolTipRole).toString();
return tooltipText;
}
void TableView::selectCell(int row, int column) void TableView::selectCell(int row, int column)
{ {
const auto index = model()->index(row, column); const auto index = model()->index(row, column);

View File

@ -20,6 +20,7 @@ public:
QModelIndexList sortedSelectedIndexes() const; QModelIndexList sortedSelectedIndexes() const;
QString selectedText() const; QString selectedText() const;
QString cellText(const QModelIndex &index) const;
signals: signals:
void currentIndexChanged(const QModelIndex &index); void currentIndexChanged(const QModelIndex &index);