summaryrefslogtreecommitdiffstats
path: root/src/styles
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-12-22 03:17:30 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-12-22 03:17:30 -0600
commitd1b6b7be7d5bc7754a143b424295a267bbdafdbd (patch)
tree20ee69ce981cd5ba62c65bb35b21188cd7b83246 /src/styles
parentf4193c940cdc34284e19cf4cb0687c1a8e81a458 (diff)
downloadqt3-d1b6b7be7d5bc7754a143b424295a267bbdafdbd.tar.gz
qt3-d1b6b7be7d5bc7754a143b424295a267bbdafdbd.zip
Repair performance regression accidentally introduced with new style API
Diffstat (limited to 'src/styles')
-rw-r--r--src/styles/qcommonstyle.cpp314
1 files changed, 205 insertions, 109 deletions
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp
index 1de0b7a..f6319a4 100644
--- a/src/styles/qcommonstyle.cpp
+++ b/src/styles/qcommonstyle.cpp
@@ -147,6 +147,7 @@ static QString QButton_static_string("QButton");
static QString QTabBar_static_string("QTabBar");
static QString QTitleBar_static_string("QTitleBar");
static QString QToolBox_static_string("QToolBox");
+static QString QToolBar_static_string("QToolBar");
static QString QProgressBar_static_string("QProgressBar");
static QString QPopupMenu_static_string("QPopupMenu");
static QString QComboBox_static_string("QComboBox");
@@ -159,17 +160,48 @@ static QString QDialogButtons_static_string("QDialogButtons");
static QString QSpinWidget_static_string("QSpinWidget");
static QString QListView_static_string("QListView");
static QString QDockWindow_static_string("QDockWindow");
+static QString QTabWidget_static_string("QTabWidget");
static QString QFrame_static_string("QFrame");
+static QString QWidget_static_string("QWidget");
+
+static QStyleControlElementData* QStyleControlElementData_null = NULL;
#include <qmetaobject.h>
+// Keep in sync with duplicate definition in qobject.cpp
+class QStyleControlElementDataPrivate {
+ public:
+ bool isQPushButton;
+ bool isQToolButton;
+ bool isQButton;
+ bool isQTabBar;
+ bool isQTitleBar;
+ bool isQToolBox;
+ bool isQToolBar;
+ bool isQProgressBar;
+ bool isQPopupMenu;
+ bool isQComboBox;
+ bool isQCheckBox;
+ bool isQRadioButton;
+ bool isQHeader;
+ bool isQScrollBar;
+ bool isQSlider;
+ bool isQDialogButtons;
+ bool isQSpinWidget;
+ bool isQListView;
+ bool isQDockWindow;
+ bool isQTabWidget;
+ bool isQFrame;
+ bool isQWidget;
+};
+
QStringList getObjectTypeListForObject(const QObject* object) {
QStringList objectTypes;
if (object) {
QMetaObject* objectMetaObject = object->metaObject();
const char* name;
-
+
while (objectMetaObject) {
name = objectMetaObject->className();
objectTypes.append(QString(name));
@@ -180,12 +212,54 @@ QStringList getObjectTypeListForObject(const QObject* object) {
return objectTypes;
}
-QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields) {
+void determineObjectTypes(const QObject* object, QStyleControlElementData &ceData, QStyleControlElementDataPrivate* ceDataPrivate) {
+ ceData.widgetObjectTypes = getObjectTypeListForObject(object);
+
+ // Increase speed on repeated calls by checking object types here and caching them
+ ceDataPrivate->isQPushButton = ceData.widgetObjectTypes.containsYesNo(QPushButton_static_string);
+ ceDataPrivate->isQToolButton = ceData.widgetObjectTypes.containsYesNo(QToolButton_static_string);
+ ceDataPrivate->isQButton = ceData.widgetObjectTypes.containsYesNo(QButton_static_string);
+ ceDataPrivate->isQTabBar = ceData.widgetObjectTypes.containsYesNo(QTabBar_static_string);
+ ceDataPrivate->isQTitleBar = ceData.widgetObjectTypes.containsYesNo(QTitleBar_static_string);
+ ceDataPrivate->isQToolBox = ceData.widgetObjectTypes.containsYesNo(QToolBox_static_string);
+ ceDataPrivate->isQToolBar = ceData.widgetObjectTypes.containsYesNo(QToolBar_static_string);
+ ceDataPrivate->isQProgressBar = ceData.widgetObjectTypes.containsYesNo(QProgressBar_static_string);
+ ceDataPrivate->isQPopupMenu = ceData.widgetObjectTypes.containsYesNo(QPopupMenu_static_string);
+ ceDataPrivate->isQComboBox = ceData.widgetObjectTypes.containsYesNo(QComboBox_static_string);
+ ceDataPrivate->isQCheckBox = ceData.widgetObjectTypes.containsYesNo(QCheckBox_static_string);
+ ceDataPrivate->isQRadioButton = ceData.widgetObjectTypes.containsYesNo(QRadioButton_static_string);
+ ceDataPrivate->isQHeader = ceData.widgetObjectTypes.containsYesNo(QHeader_static_string);
+ ceDataPrivate->isQScrollBar = ceData.widgetObjectTypes.containsYesNo(QScrollBar_static_string);
+ ceDataPrivate->isQSlider = ceData.widgetObjectTypes.containsYesNo(QSlider_static_string);
+ ceDataPrivate->isQDialogButtons = ceData.widgetObjectTypes.containsYesNo(QDialogButtons_static_string);
+ ceDataPrivate->isQSpinWidget = ceData.widgetObjectTypes.containsYesNo(QSpinWidget_static_string);
+ ceDataPrivate->isQListView = ceData.widgetObjectTypes.containsYesNo(QListView_static_string);
+ ceDataPrivate->isQDockWindow = ceData.widgetObjectTypes.containsYesNo(QDockWindow_static_string);
+ ceDataPrivate->isQTabWidget = ceData.widgetObjectTypes.containsYesNo(QTabWidget_static_string);
+ ceDataPrivate->isQFrame = ceData.widgetObjectTypes.containsYesNo(QFrame_static_string);
+ ceDataPrivate->isQWidget = ceData.widgetObjectTypes.containsYesNo(QWidget_static_string);
+}
+
+void updateObjectTypeListIfNeeded(const QObject* object) {
+ QStyleControlElementData &ceData = *(const_cast<QObject*>(object)->controlElementDataObject());
+ QStyleControlElementDataPrivate* ceDataPrivate = const_cast<QObject*>(object)->controlElementDataPrivateObject();
+
+ // This is much faster than (ceData.widgetObjectTypes[0] != QString(object->metaObject()->className())) due to QString constructor/destructor overhead
+ // Casting to const also increases speed by preventing unneeded calls to detach()
+ if ((ceData.widgetObjectTypes.isEmpty()) || (strcmp(const_cast<const QStringList&>(ceData.widgetObjectTypes)[0].ascii(), object->metaObject()->className()) != 0)) {
+ determineObjectTypes(object, ceData, ceDataPrivate);
+ }
+}
+
+QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, const QStyleOption& opt, bool populateReliantFields) {
QStyle::ControlElementFlags cef = QStyle::CEF_None;
if (object) {
- if (objectTypeList.contains(QPushButton_static_string)) {
- const QPushButton *button = dynamic_cast<const QPushButton*>(object);
+ QStyleControlElementDataPrivate* ceDataPrivate = const_cast<QObject*>(object)->controlElementDataPrivateObject();
+ updateObjectTypeListIfNeeded(object);
+
+ if (ceDataPrivate->isQPushButton) {
+ const QPushButton *button = static_cast<const QPushButton*>(object);
if (button) {
if (button->isDefault()) cef = cef | QStyle::CEF_IsDefault;
if (button->autoDefault()) cef = cef | QStyle::CEF_AutoDefault;
@@ -194,8 +268,8 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec
if (button->isFlat()) cef = cef | QStyle::CEF_IsFlat;
}
}
- if (objectTypeList.contains(QToolButton_static_string)) {
- const QToolButton *button = dynamic_cast<const QToolButton*>(object);
+ if (ceDataPrivate->isQToolButton) {
+ const QToolButton *button = static_cast<const QToolButton*>(object);
if (button) {
if (button->isToggleButton()) cef = cef | QStyle::CEF_BiState;
if (button->usesTextLabel()) cef = cef | QStyle::CEF_UsesTextLabel;
@@ -203,65 +277,67 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec
if (button->popup()) cef = cef | QStyle::CEF_HasPopupMenu;
}
}
- if (objectTypeList.contains(QButton_static_string)) {
- const QButton *button = dynamic_cast<const QButton*>(object);
+ if (ceDataPrivate->isQButton) {
+ const QButton *button = static_cast<const QButton*>(object);
if (button) {
if (button->isDown()) cef = cef | QStyle::CEF_IsDown;
if (button->isOn()) cef = cef | QStyle::CEF_IsOn;
if (button->isToggleButton()) cef = cef | QStyle::CEF_BiState;
}
}
- if (objectTypeList.contains(QTabBar_static_string)) {
- const QTabBar *tb = dynamic_cast<const QTabBar*>(object);
+ if (ceDataPrivate->isQTabBar) {
+ const QTabBar *tb = static_cast<const QTabBar*>(object);
QTab * t = opt.tab();
if ((t) && (tb)) {
if (t->identifier() == tb->currentTab()) cef = cef | QStyle::CEF_IsActive;
}
}
- if (objectTypeList.contains(QTitleBar_static_string)) {
- const QTitleBar *tb = dynamic_cast<const QTitleBar*>(object);
+ if (ceDataPrivate->isQTitleBar) {
+ const QTitleBar *tb = static_cast<const QTitleBar*>(object);
if (tb) {
if (tb->isActive()) cef = cef | QStyle::CEF_IsActive;
}
}
- if (objectTypeList.contains(QToolBox_static_string)) {
- const QToolBox *tb = dynamic_cast<const QToolBox*>(object);
+ if (ceDataPrivate->isQToolBox) {
+ const QToolBox *tb = static_cast<const QToolBox*>(object);
if (tb) {
if (!tb->currentItem()) cef = cef | QStyle::CEF_IsContainerEmpty;
}
}
- if (objectTypeList.contains(QProgressBar_static_string)) {
- const QProgressBar *pb = dynamic_cast<const QProgressBar*>(object);
+ if (ceDataPrivate->isQProgressBar) {
+ const QProgressBar *pb = static_cast<const QProgressBar*>(object);
if (pb) {
if (pb->centerIndicator()) cef = cef | QStyle::CEF_CenterIndicator;
if (pb->indicatorFollowsStyle()) cef = cef | QStyle::CEF_IndicatorFollowsStyle;
}
}
- if (objectTypeList.contains(QPopupMenu_static_string)) {
- const QPopupMenu *pm = dynamic_cast<const QPopupMenu*>(object);
+ if (ceDataPrivate->isQPopupMenu) {
+ const QPopupMenu *pm = static_cast<const QPopupMenu*>(object);
if (pm) {
if (pm->isCheckable()) cef = cef | QStyle::CEF_IsCheckable;
}
}
- if (objectTypeList.contains(QComboBox_static_string)) {
- const QComboBox *cb = dynamic_cast<const QComboBox*>(object);
+ if (ceDataPrivate->isQComboBox) {
+ const QComboBox *cb = static_cast<const QComboBox*>(object);
if (cb) {
if (cb->editable()) cef = cef | QStyle::CEF_IsEditable;
}
}
// Generic flags
- const QWidget* widget = dynamic_cast<const QWidget*>(object);
- if (widget) {
- if (widget->isEnabled()) cef = cef | QStyle::CEF_IsEnabled;
- if (widget->parentWidget()) cef = cef | QStyle::CEF_HasParentWidget;
- if (widget->focusProxy()) cef = cef | QStyle::CEF_HasFocusProxy;
- if (widget->hasFocus()) cef = cef | QStyle::CEF_HasFocus;
- if (widget->hasMouse()) cef = cef | QStyle::CEF_HasMouse;
- if (populateReliantFields) {
- if (widget->isActiveWindow()) cef = cef | QStyle::CEF_IsActiveWindow;
- if (widget->isTopLevel()) cef = cef | QStyle::CEF_IsTopLevel;
- if (widget->isVisible()) cef = cef | QStyle::CEF_IsVisible;
- if (widget->isShown()) cef = cef | QStyle::CEF_IsShown;
+ if (ceDataPrivate->isQWidget) {
+ const QWidget* widget = static_cast<const QWidget*>(object);
+ if (widget) {
+ if (widget->isEnabled()) cef = cef | QStyle::CEF_IsEnabled;
+ if (widget->parentWidget()) cef = cef | QStyle::CEF_HasParentWidget;
+ if (widget->focusProxy()) cef = cef | QStyle::CEF_HasFocusProxy;
+ if (widget->hasFocus()) cef = cef | QStyle::CEF_HasFocus;
+ if (widget->hasMouse()) cef = cef | QStyle::CEF_HasMouse;
+ if (populateReliantFields) {
+ if (widget->isActiveWindow()) cef = cef | QStyle::CEF_IsActiveWindow;
+ if (widget->isTopLevel()) cef = cef | QStyle::CEF_IsTopLevel;
+ if (widget->isVisible()) cef = cef | QStyle::CEF_IsVisible;
+ if (widget->isShown()) cef = cef | QStyle::CEF_IsShown;
+ }
}
}
}
@@ -272,16 +348,18 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec
return cef;
}
-QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields) {
+const QStyleControlElementData &populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields) {
return populateControlElementDataFromWidget(widget, opt, populateReliantFields, false);
}
-QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields, bool populateMinimumNumberOfFields) {
- QStyleControlElementData ceData;
-
+const QStyleControlElementData &populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields, bool populateMinimumNumberOfFields) {
if (widget) {
+ QStyleControlElementData &ceData = *(const_cast<QWidget*>(widget)->controlElementDataObject());
+ QStyleControlElementDataPrivate* ceDataPrivate = const_cast<QWidget*>(widget)->controlElementDataPrivateObject();
+
ceData.isNull = false;
- ceData.widgetObjectTypes = getObjectTypeListForObject(widget);
+ updateObjectTypeListIfNeeded(widget);
+
ceData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields;
if (!populateMinimumNumberOfFields) {
const QPixmap* erasePixmap = widget->backgroundPixmap();
@@ -316,8 +394,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.name = widget->name();
ceData.caption = widget->caption();
if (!populateMinimumNumberOfFields) {
- if (ceData.widgetObjectTypes.contains(QPushButton_static_string)) {
- const QPushButton *button = dynamic_cast<const QPushButton*>(widget);
+ if (ceDataPrivate->isQPushButton) {
+ const QPushButton *button = static_cast<const QPushButton*>(widget);
if (button) {
QIconSet* iconSet = 0;
const QPixmap* fgPixmap = 0;
@@ -331,8 +409,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QToolButton_static_string)) {
- const QToolButton *button = dynamic_cast<const QToolButton*>(widget);
+ if (ceDataPrivate->isQToolButton) {
+ const QToolButton *button = static_cast<const QToolButton*>(widget);
if (button) {
const QPixmap* fgPixmap = 0;
ceData.iconSet = button->iconSet();
@@ -345,8 +423,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.popupDelay = button->popupDelay();
}
}
- if (ceData.widgetObjectTypes.contains(QCheckBox_static_string)) {
- const QCheckBox *button = dynamic_cast<const QCheckBox*>(widget);
+ if (ceDataPrivate->isQCheckBox) {
+ const QCheckBox *button = static_cast<const QCheckBox*>(widget);
if (button) {
const QPixmap* fgPixmap = 0;
fgPixmap = button->pixmap();
@@ -355,8 +433,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QRadioButton_static_string)) {
- const QRadioButton *button = dynamic_cast<const QRadioButton*>(widget);
+ if (ceDataPrivate->isQRadioButton) {
+ const QRadioButton *button = static_cast<const QRadioButton*>(widget);
if (button) {
const QPixmap* fgPixmap = 0;
fgPixmap = button->pixmap();
@@ -365,8 +443,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QButton_static_string)) {
- const QButton *button = dynamic_cast<const QButton*>(widget);
+ if (ceDataPrivate->isQButton) {
+ const QButton *button = static_cast<const QButton*>(widget);
if (button) {
ceData.text = button->text();
const QPixmap* paletteBgPixmap = 0;
@@ -376,8 +454,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QTabBar_static_string)) {
- const QTabBar *tb = dynamic_cast<const QTabBar*>(widget);
+ if (ceDataPrivate->isQTabBar) {
+ const QTabBar *tb = static_cast<const QTabBar*>(widget);
if (tb) {
ceData.tabBarData.tabCount = tb->count();
ceData.tabBarData.currentTabIndex = tb->currentTab();
@@ -390,33 +468,38 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.tabBarData.identIndexMap[currentTab->identifier()] = tb->indexOf(currentTab->identifier());
}
}
- const QTabWidget *tw = dynamic_cast<const QTabWidget*>(tb->parent());
- if (tw) {
+ updateObjectTypeListIfNeeded(tb->parent());
+ if ((const_cast<QObject*>(tb->parent())->controlElementDataPrivateObject())->isQTabWidget) {
+ const QTabWidget *tw = static_cast<const QTabWidget*>(tb->parent());
QWidget *cw;
cw = tw->cornerWidget(Qt::TopLeft);
- if(cw) {
- ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes = getObjectTypeListForObject(cw);
+ if (cw) {
+ updateObjectTypeListIfNeeded(cw);
+ ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes = (const_cast<QWidget*>(cw)->controlElementDataObject())->widgetObjectTypes;
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopLeft].geometry = cw->geometry();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopLeft].rect = cw->rect();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopLeft].pos = cw->pos();
}
cw = tw->cornerWidget(Qt::TopRight);
- if(cw) {
- ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopRight].widgetObjectTypes = getObjectTypeListForObject(cw);
+ if (cw) {
+ updateObjectTypeListIfNeeded(cw);
+ ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopRight].widgetObjectTypes = (const_cast<QWidget*>(cw)->controlElementDataObject())->widgetObjectTypes;
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopRight].geometry = cw->geometry();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopRight].rect = cw->rect();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopRight].pos = cw->pos();
}
cw = tw->cornerWidget(Qt::BottomLeft);
- if(cw) {
- ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomLeft].widgetObjectTypes = getObjectTypeListForObject(cw);
+ if (cw) {
+ updateObjectTypeListIfNeeded(cw);
+ ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomLeft].widgetObjectTypes = (const_cast<QWidget*>(cw)->controlElementDataObject())->widgetObjectTypes;
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomLeft].geometry = cw->geometry();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomLeft].rect = cw->rect();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomLeft].pos = cw->pos();
}
cw = tw->cornerWidget(Qt::BottomRight);
- if(cw) {
- ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomRight].widgetObjectTypes = getObjectTypeListForObject(cw);
+ if (cw) {
+ updateObjectTypeListIfNeeded(cw);
+ ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomRight].widgetObjectTypes = (const_cast<QWidget*>(cw)->controlElementDataObject())->widgetObjectTypes;
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomRight].geometry = cw->geometry();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomRight].rect = cw->rect();
ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomRight].pos = cw->pos();
@@ -424,8 +507,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QToolBox_static_string)) {
- const QToolBox *tb = dynamic_cast<const QToolBox*>(widget);
+ if (ceDataPrivate->isQToolBox) {
+ const QToolBox *tb = static_cast<const QToolBox*>(widget);
if (tb) {
const QWidget* currentItem = tb->currentItem();
if (currentItem) {
@@ -433,8 +516,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QProgressBar_static_string)) {
- const QProgressBar *pb = dynamic_cast<const QProgressBar*>(widget);
+ if (ceDataPrivate->isQProgressBar) {
+ const QProgressBar *pb = static_cast<const QProgressBar*>(widget);
if (pb) {
ceData.currentStep = pb->progress();
ceData.totalSteps = pb->totalSteps();
@@ -443,8 +526,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.orientation = pb->orientation();
}
}
- if (ceData.widgetObjectTypes.contains(QHeader_static_string)) {
- const QHeader *header = dynamic_cast<const QHeader*>(widget);
+ if (ceDataPrivate->isQHeader) {
+ const QHeader *header = static_cast<const QHeader*>(widget);
if (header) {
int section = opt.headerSection();
QIconSet* iconSet = 0;
@@ -456,8 +539,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
// Complex Controls
- if (ceData.widgetObjectTypes.contains(QScrollBar_static_string)) {
- const QScrollBar *sb = dynamic_cast<const QScrollBar*>(widget);
+ if (ceDataPrivate->isQScrollBar) {
+ const QScrollBar *sb = static_cast<const QScrollBar*>(widget);
if (sb) {
ceData.orientation = sb->orientation();
ceData.minSteps = sb->minValue();
@@ -471,8 +554,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QSlider_static_string)) {
- const QSlider *sl = dynamic_cast<const QSlider*>(widget);
+ if (ceDataPrivate->isQSlider) {
+ const QSlider *sl = static_cast<const QSlider*>(widget);
if (sl) {
ceData.orientation = sl->orientation();
ceData.minSteps = sl->minValue();
@@ -488,8 +571,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QDialogButtons_static_string)) {
- const QDialogButtons *dlgbtns = dynamic_cast<const QDialogButtons*>(widget);
+ if (ceDataPrivate->isQDialogButtons) {
+ const QDialogButtons *dlgbtns = static_cast<const QDialogButtons*>(widget);
if (dlgbtns) {
ceData.orientation = dlgbtns->orientation();
ceData.dlgVisibleButtons = dlgbtns->visibleButtons();
@@ -499,11 +582,11 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.dlgVisibleSizeHints[btns[i]] = dlgbtns->sizeHint(btns[i]);
}
}
-
+
}
}
- if (ceData.widgetObjectTypes.contains(QTitleBar_static_string)) {
- const QTitleBar *tb = dynamic_cast<const QTitleBar*>(widget);
+ if (ceDataPrivate->isQTitleBar) {
+ const QTitleBar *tb = static_cast<const QTitleBar*>(widget);
if (tb) {
ceData.titleBarData.hasWindow = !!(tb->window());
if (populateReliantFields) {
@@ -515,8 +598,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.titleBarData.visibleText = tb->visibleText();
}
}
- if (ceData.widgetObjectTypes.contains(QSpinWidget_static_string)) {
- const QSpinWidget *sw = dynamic_cast<const QSpinWidget*>(widget);
+ if (ceDataPrivate->isQSpinWidget) {
+ const QSpinWidget *sw = static_cast<const QSpinWidget*>(widget);
if (sw) {
ceData.spinWidgetData.buttonSymbols = sw->buttonSymbols();
ceData.spinWidgetData.upRect = sw->upRect();
@@ -525,14 +608,15 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.spinWidgetData.downEnabled = sw->isDownEnabled();
}
}
- if (ceData.widgetObjectTypes.contains(QListView_static_string)) {
- const QListView *lv = dynamic_cast<const QListView*>(widget);
+ if (ceDataPrivate->isQListView) {
+ const QListView *lv = static_cast<const QListView*>(widget);
if (lv) {
ceData.listViewData.rootDecorated = lv->rootIsDecorated();
ceData.listViewData.itemMargin = lv->itemMargin();
QWidget* viewport = lv->viewport();
if (viewport) {
- ceData.viewportData.widgetObjectTypes = getObjectTypeListForObject(viewport);
+ updateObjectTypeListIfNeeded(viewport);
+ ceData.viewportData.widgetObjectTypes = (const_cast<QWidget*>(viewport)->controlElementDataObject())->widgetObjectTypes;
ceData.viewportData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields;
const QPixmap* erasePixmap = viewport->backgroundPixmap();
if (erasePixmap) {
@@ -567,29 +651,31 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
}
}
- if (ceData.widgetObjectTypes.contains(QComboBox_static_string)) {
- const QComboBox *cb = dynamic_cast<const QComboBox*>(widget);
+ if (ceDataPrivate->isQComboBox) {
+ const QComboBox *cb = static_cast<const QComboBox*>(widget);
if (cb) {
const QLineEdit* lineEdit = cb->lineEdit();
if (lineEdit) {
- ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, ceData.widgetObjectTypes, QStyleOption::Default);
+ ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, QStyleOption::Default);
}
const QListBox* listBox = cb->listBox();
if (listBox) {
- ceData.comboBoxListBoxFlags = getControlElementFlagsForObject(listBox, ceData.widgetObjectTypes, QStyleOption::Default);
+ ceData.comboBoxListBoxFlags = getControlElementFlagsForObject(listBox, QStyleOption::Default);
}
}
}
- if (ceData.widgetObjectTypes.contains(QFrame_static_string)) {
- const QFrame *frame = dynamic_cast<const QFrame*>(widget);
+ if (ceDataPrivate->isQFrame) {
+ const QFrame *frame = static_cast<const QFrame*>(widget);
if (frame) {
ceData.frameStyle = frame->frameStyle();
}
}
-
+
const QWidget* parentWidget = widget->parentWidget();
if (parentWidget) {
- ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget);
+ updateObjectTypeListIfNeeded(parentWidget);
+ ceData.parentWidgetData.widgetObjectTypes = (const_cast<QWidget*>(parentWidget)->controlElementDataObject())->widgetObjectTypes;
+ QStyleControlElementDataPrivate* parentWidgetCEDataPrivate = const_cast<QWidget*>(parentWidget)->controlElementDataPrivateObject();
ceData.parentWidgetData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields;
const QPixmap* erasePixmap = parentWidget->backgroundPixmap();
if (erasePixmap) {
@@ -621,9 +707,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.parentWidgetData.font = parentWidget->font();
ceData.parentWidgetData.name = parentWidget->name();
ceData.parentWidgetData.caption = parentWidget->caption();
-
- const QDockWindow * dw = dynamic_cast<const QDockWindow*>(parentWidget);
- if (dw) {
+
+ if (parentWidgetCEDataPrivate->isQDockWindow) {
+ const QDockWindow * dw = static_cast<const QDockWindow*>(parentWidget);
if (dw->area()) {
ceData.dwData.hasDockArea = true;
ceData.dwData.areaOrientation = dw->area()->orientation();
@@ -633,15 +719,17 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
ceData.dwData.closeEnabled = dw->isCloseEnabled();
}
- const QToolBar * toolbar = dynamic_cast<const QToolBar*>(parentWidget);
- if (toolbar) {
+ if (parentWidgetCEDataPrivate->isQToolBar) {
+ const QToolBar * toolbar = static_cast<const QToolBar*>(parentWidget);
ceData.toolBarData.orientation = toolbar->orientation();
}
- ceData.parentWidgetFlags = getControlElementFlagsForObject(parentWidget, ceData.parentWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields);
+ ceData.parentWidgetFlags = getControlElementFlagsForObject(parentWidget, QStyleOption::Default, populateReliantFields);
}
const QWidget* topLevelWidget = widget->topLevelWidget();
if (topLevelWidget) {
- ceData.topLevelWidgetData.widgetObjectTypes = getObjectTypeListForObject(topLevelWidget);
+ updateObjectTypeListIfNeeded(topLevelWidget);
+ ceData.topLevelWidgetData.widgetObjectTypes = (const_cast<QWidget*>(topLevelWidget)->controlElementDataObject())->widgetObjectTypes;
+ QStyleControlElementDataPrivate* topLevelWidgetCEDataPrivate = const_cast<QWidget*>(topLevelWidget)->controlElementDataPrivateObject();
ceData.topLevelWidgetData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields;
const QPixmap* erasePixmap = topLevelWidget->backgroundPixmap();
if (erasePixmap) {
@@ -673,9 +761,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.topLevelWidgetData.font = topLevelWidget->font();
ceData.topLevelWidgetData.name = topLevelWidget->name();
ceData.topLevelWidgetData.caption = topLevelWidget->caption();
-
- const QDockWindow * dw = dynamic_cast<const QDockWindow*>(topLevelWidget);
- if (dw) {
+
+ if (topLevelWidgetCEDataPrivate->isQDockWindow) {
+ const QDockWindow * dw = static_cast<const QDockWindow*>(topLevelWidget);
if (dw->area()) {
ceData.dwData.hasDockArea = true;
ceData.dwData.areaOrientation = dw->area()->orientation();
@@ -685,13 +773,13 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
}
ceData.dwData.closeEnabled = dw->isCloseEnabled();
}
- const QToolBar * toolbar = dynamic_cast<const QToolBar*>(topLevelWidget);
- if (toolbar) {
+ if (topLevelWidgetCEDataPrivate->isQToolBar) {
+ const QToolBar * toolbar = static_cast<const QToolBar*>(topLevelWidget);
ceData.toolBarData.orientation = toolbar->orientation();
}
- ceData.topLevelWidgetFlags = getControlElementFlagsForObject(topLevelWidget, ceData.topLevelWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields);
+ ceData.topLevelWidgetFlags = getControlElementFlagsForObject(topLevelWidget, QStyleOption::Default, populateReliantFields);
}
-
+
QCheckListItem *item = opt.checkListItem();
if (item) {
ceData.checkListItemData.dataValid = true;
@@ -703,16 +791,24 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
ceData.checkListItemData.dataValid = false;
}
}
- }
- return ceData;
+ return ceData;
+ }
+ else {
+ if (!QStyleControlElementData_null) {
+ QStyleControlElementData_null = new QStyleControlElementData();
+ }
+ QStyleControlElementData &ceData = *QStyleControlElementData_null;
+ return ceData;
+ }
}
-QStyleControlElementData populateControlElementDataFromApplication(const QApplication* app, const QStyleOption&, bool) {
- QStyleControlElementData ceData;
+const QStyleControlElementData &populateControlElementDataFromApplication(const QApplication* app, const QStyleOption&, bool) {
+ QStyleControlElementData &ceData = *(const_cast<QApplication*>(app)->controlElementDataObject());
if (app) {
- ceData.widgetObjectTypes = getObjectTypeListForObject(app);
+ updateObjectTypeListIfNeeded(app);
+ ceData.widgetObjectTypes = (const_cast<QApplication*>(app)->controlElementDataObject())->widgetObjectTypes;
ceData.palette = app->palette();
ceData.font = app->font();
}
@@ -1179,7 +1275,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe,
activePainter = 0;
}
-void qt_style_erase_region(QPainter* p, const QRegion& region, QStyleControlElementData ceData) {
+void qt_style_erase_region(QPainter* p, const QRegion& region, const QStyleControlElementData &ceData) {
QRegion reg = region;
QPoint offset = ceData.bgOffset;
@@ -2797,7 +2893,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleControlElementData &ceD
if ( ceData.wflags & WStyle_Tool ) {
ret = QMAX( QFontMetrics(ceData.font).lineSpacing(), 16 );
#ifndef QT_NO_MAINWINDOW
- } else if ( ceData.widgetObjectTypes.contains(QDockWindow_static_string) ) {
+ } else if ( ceData.widgetObjectTypes.containsYesNo(QDockWindow_static_string) ) {
ret = QMAX( QFontMetrics(ceData.font).lineSpacing(), 13 );
#endif
} else {
@@ -2945,7 +3041,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleControlElementData &ceD
#ifndef QT_NO_TABBAR
case PM_TabBarTabVSpace:
{
- if ( ceData.widgetObjectTypes.contains(QTabBar_static_string) && ( ceData.tabBarData.shape == QTabBar::RoundedAbove ||
+ if ( ceData.widgetObjectTypes.containsYesNo(QTabBar_static_string) && ( ceData.tabBarData.shape == QTabBar::RoundedAbove ||
ceData.tabBarData.shape == QTabBar::RoundedBelow ) )
ret = 10;
else