Skip to content

Commit

Permalink
Fix height bug manifesting in plugin manager and grass toolbox list view
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8609 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jun 6, 2008
1 parent 6dfdcfe commit c403091
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions src/gui/qgsdetaileditemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,36 @@ QSize QgsDetailedItemDelegate::sizeHint(
{
if (qVariantCanConvert<QgsDetailedItemData>(theIndex.data(Qt::UserRole)))
{
return QSize(378,mpWidget->height());
QgsDetailedItemData myData =
qVariantValue<QgsDetailedItemData>(theIndex.data(Qt::UserRole));
if (myData.isRenderedAsWidget())
{
return QSize(378,mpWidget->height());
}
else // fall back to hand calculated & hand drawn item
{
QFont myFont = theOption.font;
QFont myTitleFont = myFont;
myTitleFont.setBold(true);
myTitleFont.setPointSize(myFont.pointSize() + 3);
QFontMetrics myTitleMetrics(myTitleFont);
QFontMetrics myDetailMetrics(myFont);
int myVerticalSpacer = 3; //spacing between title and description
int myHorizontalSpacer = 5; //spacing between checkbox / icon and description
int myHeight = myTitleMetrics.height() + myVerticalSpacer;
QString myDetailString = theIndex.model()->data(theIndex, Qt::UserRole).toString();
QStringList myList = wordWrap( myDetailString,
myDetailMetrics,
theOption.rect.width() - (mpCheckBox->width() + myHorizontalSpacer));
myHeight += (myList.count() + 1) * (myDetailMetrics.height() - myVerticalSpacer);
//for some reason itmes are non selectable if using rect.width() on osx and win
return QSize(50, myHeight + myVerticalSpacer);
//return QSize(theOption.rect.width(), myHeight + myVerticalSpacer);
}
}
else // fall back to hand calculated & hand drawn item
else //cant convert to qgsdetaileditemdata
{
QFont myFont = theOption.font;
QFont myTitleFont = myFont;
myTitleFont.setBold(true);
myTitleFont.setPointSize(myFont.pointSize() + 3);
QFontMetrics myTitleMetrics(myTitleFont);
QFontMetrics myDetailMetrics(myFont);
int myVerticalSpacer = 3; //spacing between title and description
int myHorizontalSpacer = 5; //spacing between checkbox / icon and description
int myHeight = myTitleMetrics.height() + myVerticalSpacer;
QString myDetailString = theIndex.model()->data(theIndex, Qt::UserRole).toString();
QStringList myList = wordWrap( myDetailString,
myDetailMetrics,
theOption.rect.width() - (mpCheckBox->width() + myHorizontalSpacer));
myHeight += (myList.count() + 1) * (myDetailMetrics.height() - myVerticalSpacer);
//for some reason itmes are non selectable if using rect.width() on osx and win
return QSize(50, myHeight + myVerticalSpacer);
//return QSize(theOption.rect.width(), myHeight + myVerticalSpacer);
return QSize(50,50); //fallback
}
}

Expand Down

0 comments on commit c403091

Please sign in to comment.