From ec6735c44e5a5003219eea2805e082a7d1c1abb9 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Tue, 23 Jul 2013 07:31:28 +0200 Subject: [PATCH] Provide the filename as tooltip --- src/model/danboorutablemodel.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/model/danboorutablemodel.cpp b/src/model/danboorutablemodel.cpp index 0a43c08..7a7aedb 100644 --- a/src/model/danboorutablemodel.cpp +++ b/src/model/danboorutablemodel.cpp @@ -72,9 +72,13 @@ namespace Danbooru { return QVariant(); } - if (role == Qt::DisplayRole) { + DanbooruPost* post = m_posts.at(index.row()); - Danbooru::DanbooruPost* post = m_posts.at(index.row()); + if (!post) { + return QVariant(); + } + + if (role == Qt::DisplayRole) { QVariant variant; variant.setValue(post); @@ -83,11 +87,14 @@ namespace Danbooru { } if (role == Qt::DecorationRole) { - DanbooruPost* post = m_posts.at(index.row()); const QPixmap* pixmap = post->pixmap(); return *pixmap; } + if (role == Qt::ToolTipRole) { + return post->fileUrl().fileName(); + } + return QVariant(); }