Add accessor methods to list view items and popup menus for styling

pull/2/head
Timothy Pearson 12 years ago
parent 294ec2ee1f
commit 180abfff4d

@ -489,6 +489,15 @@ static QString qEllipsisText( const QString &org, const QFontMetrics &fm, int wi
greater than 1000, to allow for extensions to this class.
*/
/*!
Constructs a new top-level list view item with no parent
*/
QListViewItem::QListViewItem( )
{
init();
}
/*!
Constructs a new top-level list view item in the QListView \a
parent.

@ -69,6 +69,7 @@ class Q_EXPORT QListViewItem : public Qt
friend class QListViewToolTip;
public:
QListViewItem( );
QListViewItem( QListView * parent );
QListViewItem( QListViewItem * parent );
QListViewItem( QListView * parent, QListViewItem * after );

@ -2882,5 +2882,32 @@ QPopupMenu::updateScrollerState()
d->scroll.topScrollableIndex++;
}
/*!
Calculates the height in pixels of the menu item \a mi.
*/
int QPopupMenu::menuItemHeight( QMenuItem *mi, QFontMetrics fm )
{
if ( mi->widget() )
return mi->widget()->height();
if ( mi->custom() && mi->custom()->fullSpan() )
return mi->custom()->sizeHint().height();
int h = 0;
if ( mi->isSeparator() ) // separator height
h = 2;
else if ( mi->pixmap() ) // pixmap height
h = mi->pixmap()->height();
else // text height
h = fm.height();
if ( !mi->isSeparator() && mi->iconSet() != 0 )
h = QMAX(h, mi->iconSet()->pixmap( QIconSet::Small,
QIconSet::Normal ).height());
if ( mi->custom() )
h = QMAX(h, mi->custom()->sizeHint().height());
return h;
}
#endif // QT_NO_POPUPMENU

@ -193,6 +193,9 @@ private: // Disabled copy constructor and operator=
QPopupMenu( const QPopupMenu & );
QPopupMenu &operator=( const QPopupMenu & );
#endif
public:
static int menuItemHeight( QMenuItem* mi, QFontMetrics fm );
};

Loading…
Cancel
Save