From 27f9bff91b7e1e7a2cd3d1352fab872ef150333c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 13 Jan 2017 20:05:56 +0100 Subject: [PATCH] Added tooltip to folder items in the folders' treeview, it will show the complete name of the folder, usefull when the name is clipped by the parent view, plus the number of children in that folder. Only the number of subfolders can be known when the tooltip is decorated --- YACReaderLibrary/db/folder_model.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/db/folder_model.cpp b/YACReaderLibrary/db/folder_model.cpp index d1ea8c2f..6b5886a7 100644 --- a/YACReaderLibrary/db/folder_model.cpp +++ b/YACReaderLibrary/db/folder_model.cpp @@ -146,6 +146,18 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const FolderItem *item = static_cast(index.internalPointer()); + if (role == Qt::ToolTipRole) + { + QString toolTip = item->data(FolderModel::Name).toString(); + int totalNumOfChildren = item->childCount() + item->comicNames.size(); + if(totalNumOfChildren > 0) + { + toolTip = toolTip + " - " + QString::number(totalNumOfChildren); + } + + return toolTip; + } + if (role == Qt::DecorationRole) #ifdef Q_OS_MAC @@ -175,8 +187,6 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const if (role != Qt::DisplayRole) return QVariant(); - - return item->data(index.column()); } //! [3]