From 294ec2ee1fca27847ba0e913a3b11f7382e0492e Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 31 Oct 2012 23:30:20 -0500 Subject: Add parent toolbar information to style info structs --- src/kernel/qstyle.h | 6 ++++++ src/styles/qcommonstyle.cpp | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 341473e..111a987 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -178,6 +178,11 @@ class QStyleControlElementDockWidgetData { Qt::Orientation areaOrientation; }; +class QStyleControlElementToolBarWidgetData { + public: + Qt::Orientation orientation; +}; + class QStyleControlElementGenericWidgetData { public: QStringList widgetObjectTypes; @@ -270,6 +275,7 @@ class Q_EXPORT QStyleControlElementData { Q_UINT32 frameStyle; QRect sliderRect; QPainter* activePainter; + QStyleControlElementToolBarWidgetData toolBarData; public: QStyleControlElementData(); diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 3a1a8d8..1cc2540 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -576,6 +576,10 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid } ceData.dwData.closeEnabled = dw->isCloseEnabled(); } + const QToolBar * toolbar = dynamic_cast(parentWidget); + if (toolbar) { + ceData.toolBarData.orientation = toolbar->orientation(); + } } QCheckListItem *item = opt.checkListItem(); -- cgit v1.2.1 From 180abfff4d31bc8db66fea92cf070ff21b7a5e2f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 1 Nov 2012 22:50:23 -0500 Subject: Add accessor methods to list view items and popup menus for styling --- src/widgets/qlistview.cpp | 9 +++++++++ src/widgets/qlistview.h | 1 + src/widgets/qpopupmenu.cpp | 27 +++++++++++++++++++++++++++ src/widgets/qpopupmenu.h | 3 +++ 4 files changed, 40 insertions(+) (limited to 'src') diff --git a/src/widgets/qlistview.cpp b/src/widgets/qlistview.cpp index 304ad18..385ad04 100644 --- a/src/widgets/qlistview.cpp +++ b/src/widgets/qlistview.cpp @@ -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. diff --git a/src/widgets/qlistview.h b/src/widgets/qlistview.h index e5dc0e4..ba0dae7 100644 --- a/src/widgets/qlistview.h +++ b/src/widgets/qlistview.h @@ -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 ); diff --git a/src/widgets/qpopupmenu.cpp b/src/widgets/qpopupmenu.cpp index f20cbfc..086c423 100644 --- a/src/widgets/qpopupmenu.cpp +++ b/src/widgets/qpopupmenu.cpp @@ -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 diff --git a/src/widgets/qpopupmenu.h b/src/widgets/qpopupmenu.h index 0609731..7569381 100644 --- a/src/widgets/qpopupmenu.h +++ b/src/widgets/qpopupmenu.h @@ -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 ); }; -- cgit v1.2.1