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

This commit is contained in:
Luis Ángel San Martín 2017-01-13 20:05:56 +01:00
parent 206365f027
commit 27f9bff91b

View File

@ -146,6 +146,18 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const
FolderItem *item = static_cast<FolderItem*>(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]