Skip to content

Commit

Permalink
refresh tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Oct 13, 2023
1 parent d1ff9a7 commit a0bc76d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ QVariant BaseTrackTableModel::composeCoverArtToolTipHtml(
this,
coverInfo,
absoluteHeightOfCoverartToolTip);
return QVariant();
return tr("Fetching image ...");
}
QByteArray data;
QBuffer buffer(&data);
Expand Down
23 changes: 23 additions & 0 deletions src/widget/wlibrarytableview.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include "widget/wlibrarytableview.h"

#include <QApplication>
#include <QFocusEvent>
#include <QFontMetrics>
#include <QHeaderView>
#include <QHelpEvent>
#include <QPalette>
#include <QScrollBar>
#include <QToolTip>

#include "library/trackmodel.h"
#include "moc_wlibrarytableview.cpp"
Expand Down Expand Up @@ -391,3 +394,23 @@ QModelIndex WLibraryTableView::moveCursor(CursorAction cursorAction,

return QTableView::moveCursor(cursorAction, modifiers);
}

void WLibraryTableView::dataChanged(
const QModelIndex& topLeft,
const QModelIndex& bottomRight,
const QVector<int>& roles) {
for (auto& role : roles) {

Check warning on line 402 in src/widget/wlibrarytableview.cpp

View workflow job for this annotation

GitHub Actions / clang-tidy

'auto &role' can be declared as 'const auto &role' [readability-qualified-auto]
// If the tooltip is still visible update with the loaded cover.
if (role == Qt::ToolTipRole && QToolTip::isVisible()) {
QPoint globalPos = QCursor::pos();
QWidget* pViewPort = QApplication::widgetAt(QCursor::pos());
if (pViewPort) {
QHelpEvent toolTipEvent(QEvent::ToolTip,
pViewPort->mapFromGlobal(globalPos),
globalPos);
viewportEvent(&toolTipEvent);
}
}
}
QAbstractItemView::dataChanged(topLeft, bottomRight, roles);
};
5 changes: 5 additions & 0 deletions src/widget/wlibrarytableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class WLibraryTableView : public QTableView, public virtual LibraryView {
/// @param optional: index, otherwise row/column member vars are used
void restoreCurrentIndex(const QModelIndex& index = QModelIndex());

void dataChanged(
const QModelIndex& topLeft,
const QModelIndex& bottomRight,
const QVector<int>& roles = QVector<int>()) override;

signals:
void loadTrack(TrackPointer pTrack);
void loadTrackToPlayer(TrackPointer pTrack, const QString& group, bool play = false);
Expand Down

0 comments on commit a0bc76d

Please sign in to comment.