diff options
Diffstat (limited to 'src/styles/qcommonstyle.cpp')
-rw-r--r-- | src/styles/qcommonstyle.cpp | 761 |
1 files changed, 385 insertions, 376 deletions
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index a0e64d0..a44ee9f 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -251,421 +251,430 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec } 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; if (widget) { + ceData.isNull = false; ceData.widgetObjectTypes = getObjectTypeListForObject(widget); - ceData.allDataPopulated = populateReliantFields; - const QPixmap* erasePixmap = widget->backgroundPixmap(); - if (erasePixmap) { - ceData.bgPixmap = *erasePixmap; - } - if (populateReliantFields) { - ceData.bgBrush = widget->backgroundBrush(); + ceData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields; + if (!populateMinimumNumberOfFields) { + const QPixmap* erasePixmap = widget->backgroundPixmap(); + if (erasePixmap) { + ceData.bgPixmap = *erasePixmap; + } + if (populateReliantFields) { + ceData.bgBrush = widget->backgroundBrush(); + ceData.windowState = (Qt::WindowState)(widget->windowState()); + } } ceData.wflags = widget->getWFlags(); - if (populateReliantFields) { - ceData.windowState = (Qt::WindowState)(widget->windowState()); - } - ceData.bgColor = widget->eraseColor(); - ceData.bgOffset = widget->backgroundOffset(); - ceData.backgroundMode = widget->backgroundMode(); - if (populateReliantFields) { - ceData.fgColor = widget->foregroundColor(); - ceData.colorGroup = widget->colorGroup(); - ceData.paletteBgColor = widget->paletteBackgroundColor(); - } - ceData.geometry = widget->geometry(); - ceData.rect = widget->rect(); - ceData.pos = widget->pos(); - const QPixmap* icon = widget->icon(); - if (icon) { - ceData.icon = *icon; + if (!populateMinimumNumberOfFields) { + ceData.bgColor = widget->eraseColor(); + ceData.bgOffset = widget->backgroundOffset(); + ceData.backgroundMode = widget->backgroundMode(); + if (populateReliantFields) { + ceData.fgColor = widget->foregroundColor(); + ceData.colorGroup = widget->colorGroup(); + ceData.paletteBgColor = widget->paletteBackgroundColor(); + } + ceData.geometry = widget->geometry(); + ceData.rect = widget->rect(); + ceData.pos = widget->pos(); + const QPixmap* icon = widget->icon(); + if (icon) { + ceData.icon = *icon; + } + ceData.palette = widget->palette(); + ceData.font = widget->font(); } - ceData.palette = widget->palette(); - ceData.font = widget->font(); ceData.name = widget->name(); ceData.caption = widget->caption(); - if (ceData.widgetObjectTypes.contains("QPushButton")) { - const QPushButton *button = dynamic_cast<const QPushButton*>(widget); - if (button) { - QIconSet* iconSet = 0; - const QPixmap* fgPixmap = 0; - iconSet = button->iconSet(); - fgPixmap = button->pixmap(); - if (iconSet) { - ceData.iconSet = *iconSet; - } - if (fgPixmap) { - ceData.fgPixmap = *fgPixmap; + if (!populateMinimumNumberOfFields) { + if (ceData.widgetObjectTypes.contains("QPushButton")) { + const QPushButton *button = dynamic_cast<const QPushButton*>(widget); + if (button) { + QIconSet* iconSet = 0; + const QPixmap* fgPixmap = 0; + iconSet = button->iconSet(); + fgPixmap = button->pixmap(); + if (iconSet) { + ceData.iconSet = *iconSet; + } + if (fgPixmap) { + ceData.fgPixmap = *fgPixmap; + } } } - } - if (ceData.widgetObjectTypes.contains("QToolButton")) { - const QToolButton *button = dynamic_cast<const QToolButton*>(widget); - if (button) { - const QPixmap* fgPixmap = 0; - ceData.iconSet = button->iconSet(); - fgPixmap = button->pixmap(); - if (fgPixmap) { - ceData.fgPixmap = *fgPixmap; + if (ceData.widgetObjectTypes.contains("QToolButton")) { + const QToolButton *button = dynamic_cast<const QToolButton*>(widget); + if (button) { + const QPixmap* fgPixmap = 0; + ceData.iconSet = button->iconSet(); + fgPixmap = button->pixmap(); + if (fgPixmap) { + ceData.fgPixmap = *fgPixmap; + } + ceData.textLabel = button->textLabel(); + ceData.toolButtonTextPosition = button->textPosition(); + ceData.popupDelay = button->popupDelay(); } - ceData.textLabel = button->textLabel(); - ceData.toolButtonTextPosition = button->textPosition(); - ceData.popupDelay = button->popupDelay(); } - } - if (ceData.widgetObjectTypes.contains("QCheckBox")) { - const QCheckBox *button = dynamic_cast<const QCheckBox*>(widget); - if (button) { - const QPixmap* fgPixmap = 0; - fgPixmap = button->pixmap(); - if (fgPixmap) { - ceData.fgPixmap = *fgPixmap; + if (ceData.widgetObjectTypes.contains("QCheckBox")) { + const QCheckBox *button = dynamic_cast<const QCheckBox*>(widget); + if (button) { + const QPixmap* fgPixmap = 0; + fgPixmap = button->pixmap(); + if (fgPixmap) { + ceData.fgPixmap = *fgPixmap; + } } } - } - if (ceData.widgetObjectTypes.contains("QRadioButton")) { - const QRadioButton *button = dynamic_cast<const QRadioButton*>(widget); - if (button) { - const QPixmap* fgPixmap = 0; - fgPixmap = button->pixmap(); - if (fgPixmap) { - ceData.fgPixmap = *fgPixmap; + if (ceData.widgetObjectTypes.contains("QRadioButton")) { + const QRadioButton *button = dynamic_cast<const QRadioButton*>(widget); + if (button) { + const QPixmap* fgPixmap = 0; + fgPixmap = button->pixmap(); + if (fgPixmap) { + ceData.fgPixmap = *fgPixmap; + } } } - } - if (ceData.widgetObjectTypes.contains("QButton")) { - const QButton *button = dynamic_cast<const QButton*>(widget); - if (button) { - ceData.text = button->text(); - } - } - if (ceData.widgetObjectTypes.contains("QTabBar")) { - const QTabBar *tb = dynamic_cast<const QTabBar*>(widget); - if (tb) { - ceData.tabBarData.tabCount = tb->count(); - ceData.tabBarData.currentTabIndex = tb->currentTab(); - ceData.tabBarData.shape = tb->shape(); - ceData.tabBarData.identIndexMap.clear(); - const QTab* currentTab; - for (int i=0; i<tb->count(); ++i) { - currentTab = tb->tabAt(i); - if (currentTab) { - ceData.tabBarData.identIndexMap[currentTab->identifier()] = tb->indexOf(currentTab->identifier()); - } + if (ceData.widgetObjectTypes.contains("QButton")) { + const QButton *button = dynamic_cast<const QButton*>(widget); + if (button) { + ceData.text = button->text(); } - const QTabWidget *tw = dynamic_cast<const QTabWidget*>(tb->parent()); - if (tw) { - QWidget *cw; - cw = tw->cornerWidget(Qt::TopLeft); - if(cw) { - ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes = getObjectTypeListForObject(cw); - 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); - 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); - 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(); + } + if (ceData.widgetObjectTypes.contains("QTabBar")) { + const QTabBar *tb = dynamic_cast<const QTabBar*>(widget); + if (tb) { + ceData.tabBarData.tabCount = tb->count(); + ceData.tabBarData.currentTabIndex = tb->currentTab(); + ceData.tabBarData.shape = tb->shape(); + ceData.tabBarData.identIndexMap.clear(); + const QTab* currentTab; + for (int i=0; i<tb->count(); ++i) { + currentTab = tb->tabAt(i); + if (currentTab) { + ceData.tabBarData.identIndexMap[currentTab->identifier()] = tb->indexOf(currentTab->identifier()); + } } - cw = tw->cornerWidget(Qt::BottomRight); - if(cw) { - ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_BottomRight].widgetObjectTypes = getObjectTypeListForObject(cw); - 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(); + const QTabWidget *tw = dynamic_cast<const QTabWidget*>(tb->parent()); + if (tw) { + QWidget *cw; + cw = tw->cornerWidget(Qt::TopLeft); + if(cw) { + ceData.tabBarData.cornerWidgets[QStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes = getObjectTypeListForObject(cw); + 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); + 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); + 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); + 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(); + } } } } - } - if (ceData.widgetObjectTypes.contains("QToolBox")) { - const QToolBox *tb = dynamic_cast<const QToolBox*>(widget); - if (tb) { - const QWidget* currentItem = tb->currentItem(); - if (currentItem) { - ceData.activeItemPaletteBgColor = currentItem->paletteBackgroundColor(); + if (ceData.widgetObjectTypes.contains("QToolBox")) { + const QToolBox *tb = dynamic_cast<const QToolBox*>(widget); + if (tb) { + const QWidget* currentItem = tb->currentItem(); + if (currentItem) { + ceData.activeItemPaletteBgColor = currentItem->paletteBackgroundColor(); + } } } - } - if (ceData.widgetObjectTypes.contains("QProgressBar")) { - const QProgressBar *pb = dynamic_cast<const QProgressBar*>(widget); - if (pb) { - ceData.currentStep = pb->progress(); - ceData.totalSteps = pb->totalSteps(); - ceData.progressText = pb->progressString(); - ceData.percentageVisible = pb->percentageVisible(); - ceData.orientation = pb->orientation(); + if (ceData.widgetObjectTypes.contains("QProgressBar")) { + const QProgressBar *pb = dynamic_cast<const QProgressBar*>(widget); + if (pb) { + ceData.currentStep = pb->progress(); + ceData.totalSteps = pb->totalSteps(); + ceData.progressText = pb->progressString(); + ceData.percentageVisible = pb->percentageVisible(); + ceData.orientation = pb->orientation(); + } } - } - if (ceData.widgetObjectTypes.contains("QHeader")) { - const QHeader *header = dynamic_cast<const QHeader*>(widget); - if (header) { - int section = opt.headerSection(); - QIconSet* iconSet = 0; - iconSet = header->iconSet(section); - ceData.textLabel = header->label(section); - if (iconSet) { - ceData.iconSet = *iconSet; + if (ceData.widgetObjectTypes.contains("QHeader")) { + const QHeader *header = dynamic_cast<const QHeader*>(widget); + if (header) { + int section = opt.headerSection(); + QIconSet* iconSet = 0; + iconSet = header->iconSet(section); + ceData.textLabel = header->label(section); + if (iconSet) { + ceData.iconSet = *iconSet; + } } } - } - // Complex Controls - if (ceData.widgetObjectTypes.contains("QScrollBar")) { - const QScrollBar *sb = dynamic_cast<const QScrollBar*>(widget); - if (sb) { - ceData.orientation = sb->orientation(); - ceData.minSteps = sb->minValue(); - ceData.maxSteps = sb->maxValue(); - ceData.currentStep = sb->value(); - ceData.startStep = sb->sliderStart(); - ceData.lineStep = sb->lineStep(); - ceData.pageStep = sb->pageStep(); - if (populateReliantFields) { - ceData.sliderRect = sb->sliderRect(); + // Complex Controls + if (ceData.widgetObjectTypes.contains("QScrollBar")) { + const QScrollBar *sb = dynamic_cast<const QScrollBar*>(widget); + if (sb) { + ceData.orientation = sb->orientation(); + ceData.minSteps = sb->minValue(); + ceData.maxSteps = sb->maxValue(); + ceData.currentStep = sb->value(); + ceData.startStep = sb->sliderStart(); + ceData.lineStep = sb->lineStep(); + ceData.pageStep = sb->pageStep(); + if (populateReliantFields) { + ceData.sliderRect = sb->sliderRect(); + } } } - } - if (ceData.widgetObjectTypes.contains("QSlider")) { - const QSlider *sl = dynamic_cast<const QSlider*>(widget); - if (sl) { - ceData.orientation = sl->orientation(); - ceData.minSteps = sl->minValue(); - ceData.maxSteps = sl->maxValue(); - ceData.tickMarkSetting = sl->tickmarks(); - ceData.tickInterval = sl->tickInterval(); - ceData.currentStep = sl->value(); - ceData.startStep = sl->sliderStart(); - ceData.lineStep = sl->lineStep(); - ceData.pageStep = sl->pageStep(); - if (populateReliantFields) { - ceData.sliderRect = sl->sliderRect(); + if (ceData.widgetObjectTypes.contains("QSlider")) { + const QSlider *sl = dynamic_cast<const QSlider*>(widget); + if (sl) { + ceData.orientation = sl->orientation(); + ceData.minSteps = sl->minValue(); + ceData.maxSteps = sl->maxValue(); + ceData.tickMarkSetting = sl->tickmarks(); + ceData.tickInterval = sl->tickInterval(); + ceData.currentStep = sl->value(); + ceData.startStep = sl->sliderStart(); + ceData.lineStep = sl->lineStep(); + ceData.pageStep = sl->pageStep(); + if (populateReliantFields) { + ceData.sliderRect = sl->sliderRect(); + } } } - } - if (ceData.widgetObjectTypes.contains("QDialogButtons")) { - const QDialogButtons *dlgbtns = dynamic_cast<const QDialogButtons*>(widget); - if (dlgbtns) { - ceData.orientation = dlgbtns->orientation(); - ceData.dlgVisibleButtons = dlgbtns->visibleButtons(); - QDialogButtons::Button btns[] = { QDialogButtons::All, QDialogButtons::Reject, QDialogButtons::Accept, QDialogButtons::Apply, QDialogButtons::Retry, QDialogButtons::Ignore, QDialogButtons::Abort, QDialogButtons::Help }; - for(unsigned int i = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) { - if (ceData.dlgVisibleButtons & btns[i]) { - ceData.dlgVisibleSizeHints[btns[i]] = dlgbtns->sizeHint(btns[i]); + if (ceData.widgetObjectTypes.contains("QDialogButtons")) { + const QDialogButtons *dlgbtns = dynamic_cast<const QDialogButtons*>(widget); + if (dlgbtns) { + ceData.orientation = dlgbtns->orientation(); + ceData.dlgVisibleButtons = dlgbtns->visibleButtons(); + QDialogButtons::Button btns[] = { QDialogButtons::All, QDialogButtons::Reject, QDialogButtons::Accept, QDialogButtons::Apply, QDialogButtons::Retry, QDialogButtons::Ignore, QDialogButtons::Abort, QDialogButtons::Help }; + for(unsigned int i = 0; i < (sizeof(btns)/sizeof(btns[0])); i++) { + if (ceData.dlgVisibleButtons & btns[i]) { + ceData.dlgVisibleSizeHints[btns[i]] = dlgbtns->sizeHint(btns[i]); + } } + } - } - } - if (ceData.widgetObjectTypes.contains("QTitleBar")) { - const QTitleBar *tb = dynamic_cast<const QTitleBar*>(widget); - if (tb) { - ceData.titleBarData.hasWindow = !!(tb->window()); - if (populateReliantFields) { - if (ceData.titleBarData.hasWindow) { - ceData.titleBarData.windowState = (Qt::WindowState)(tb->window()->windowState()); + if (ceData.widgetObjectTypes.contains("QTitleBar")) { + const QTitleBar *tb = dynamic_cast<const QTitleBar*>(widget); + if (tb) { + ceData.titleBarData.hasWindow = !!(tb->window()); + if (populateReliantFields) { + if (ceData.titleBarData.hasWindow) { + ceData.titleBarData.windowState = (Qt::WindowState)(tb->window()->windowState()); + } + ceData.titleBarData.usesActiveColor = tb->usesActiveColor(); } - ceData.titleBarData.usesActiveColor = tb->usesActiveColor(); + ceData.titleBarData.visibleText = tb->visibleText(); } - ceData.titleBarData.visibleText = tb->visibleText(); } - } - if (ceData.widgetObjectTypes.contains("QSpinWidget")) { - const QSpinWidget *sw = dynamic_cast<const QSpinWidget*>(widget); - if (sw) { - ceData.spinWidgetData.buttonSymbols = sw->buttonSymbols(); - ceData.spinWidgetData.upRect = sw->upRect(); - ceData.spinWidgetData.downRect = sw->downRect(); - ceData.spinWidgetData.upEnabled = sw->isUpEnabled(); - ceData.spinWidgetData.downEnabled = sw->isDownEnabled(); + if (ceData.widgetObjectTypes.contains("QSpinWidget")) { + const QSpinWidget *sw = dynamic_cast<const QSpinWidget*>(widget); + if (sw) { + ceData.spinWidgetData.buttonSymbols = sw->buttonSymbols(); + ceData.spinWidgetData.upRect = sw->upRect(); + ceData.spinWidgetData.downRect = sw->downRect(); + ceData.spinWidgetData.upEnabled = sw->isUpEnabled(); + ceData.spinWidgetData.downEnabled = sw->isDownEnabled(); + } } - } - if (ceData.widgetObjectTypes.contains("QListView")) { - const QListView *lv = dynamic_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); - ceData.viewportData.allDataPopulated = populateReliantFields; - const QPixmap* erasePixmap = viewport->backgroundPixmap(); - if (erasePixmap) { - ceData.viewportData.bgPixmap = *erasePixmap; + if (ceData.widgetObjectTypes.contains("QListView")) { + const QListView *lv = dynamic_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); + ceData.viewportData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields; + const QPixmap* erasePixmap = viewport->backgroundPixmap(); + if (erasePixmap) { + ceData.viewportData.bgPixmap = *erasePixmap; + } + if (populateReliantFields) { + ceData.viewportData.bgBrush = viewport->backgroundBrush(); + } + if (populateReliantFields) { + ceData.viewportData.windowState = (Qt::WindowState)(widget->windowState()); + } + ceData.viewportData.wflags = viewport->getWFlags(); + ceData.viewportData.bgColor = viewport->eraseColor(); + ceData.viewportData.bgOffset = viewport->backgroundOffset(); + ceData.viewportData.backgroundMode = viewport->backgroundMode(); + if (populateReliantFields) { + ceData.viewportData.fgColor = viewport->foregroundColor(); + ceData.viewportData.colorGroup = viewport->colorGroup(); + ceData.viewportData.paletteBgColor = viewport->paletteBackgroundColor(); + } + ceData.viewportData.geometry = viewport->geometry(); + ceData.viewportData.rect = viewport->rect(); + ceData.viewportData.pos = viewport->pos(); + const QPixmap* icon = viewport->icon(); + if (icon) { + ceData.viewportData.icon = *icon; + } + ceData.viewportData.palette = viewport->palette(); + ceData.viewportData.font = viewport->font(); + ceData.viewportData.name = viewport->name(); + ceData.viewportData.caption = viewport->caption(); } - if (populateReliantFields) { - ceData.viewportData.bgBrush = viewport->backgroundBrush(); + } + } + if (ceData.widgetObjectTypes.contains("QComboBox")) { + const QComboBox *cb = dynamic_cast<const QComboBox*>(widget); + if (cb) { + const QLineEdit* lineEdit = cb->lineEdit(); + if (lineEdit) { + ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, ceData.widgetObjectTypes, QStyleOption::Default); } - ceData.viewportData.wflags = viewport->getWFlags(); - if (populateReliantFields) { - ceData.viewportData.windowState = (Qt::WindowState)(widget->windowState()); + const QListBox* listBox = cb->listBox(); + if (listBox) { + ceData.comboBoxListBoxFlags = getControlElementFlagsForObject(listBox, ceData.widgetObjectTypes, QStyleOption::Default); } - ceData.viewportData.bgColor = viewport->eraseColor(); - ceData.viewportData.bgOffset = viewport->backgroundOffset(); - ceData.viewportData.backgroundMode = viewport->backgroundMode(); - if (populateReliantFields) { - ceData.viewportData.fgColor = viewport->foregroundColor(); - ceData.viewportData.colorGroup = viewport->colorGroup(); - ceData.viewportData.paletteBgColor = viewport->paletteBackgroundColor(); + } + } + if (ceData.widgetObjectTypes.contains("QFrame")) { + const QFrame *frame = dynamic_cast<const QFrame*>(widget); + if (frame) { + ceData.frameStyle = frame->frameStyle(); + } + } + + const QWidget* parentWidget = widget->parentWidget(); + if (parentWidget) { + ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget); + ceData.parentWidgetData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields; + const QPixmap* erasePixmap = parentWidget->backgroundPixmap(); + if (erasePixmap) { + ceData.parentWidgetData.bgPixmap = *erasePixmap; + } + if (populateReliantFields) { + ceData.parentWidgetData.bgBrush = parentWidget->backgroundBrush(); + } + if (populateReliantFields) { + ceData.parentWidgetData.windowState = (Qt::WindowState)(widget->windowState()); + } + ceData.parentWidgetData.wflags = parentWidget->getWFlags(); + ceData.parentWidgetData.bgColor = parentWidget->eraseColor(); + ceData.parentWidgetData.bgOffset = parentWidget->backgroundOffset(); + ceData.parentWidgetData.backgroundMode = parentWidget->backgroundMode(); + if (populateReliantFields) { + ceData.parentWidgetData.fgColor = parentWidget->foregroundColor(); + ceData.parentWidgetData.colorGroup = parentWidget->colorGroup(); + ceData.parentWidgetData.paletteBgColor = parentWidget->paletteBackgroundColor(); + } + ceData.parentWidgetData.geometry = parentWidget->geometry(); + ceData.parentWidgetData.rect = parentWidget->rect(); + ceData.parentWidgetData.pos = parentWidget->pos(); + const QPixmap* icon = parentWidget->icon(); + if (icon) { + ceData.parentWidgetData.icon = *icon; + } + ceData.parentWidgetData.palette = parentWidget->palette(); + 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 (dw->area()) { + ceData.dwData.hasDockArea = true; + ceData.dwData.areaOrientation = dw->area()->orientation(); } - ceData.viewportData.geometry = viewport->geometry(); - ceData.viewportData.rect = viewport->rect(); - ceData.viewportData.pos = viewport->pos(); - const QPixmap* icon = viewport->icon(); - if (icon) { - ceData.viewportData.icon = *icon; + else { + ceData.dwData.hasDockArea = false; } - ceData.viewportData.palette = viewport->palette(); - ceData.viewportData.font = viewport->font(); - ceData.viewportData.name = viewport->name(); - ceData.viewportData.caption = viewport->caption(); + ceData.dwData.closeEnabled = dw->isCloseEnabled(); } + const QToolBar * toolbar = dynamic_cast<const QToolBar*>(parentWidget); + if (toolbar) { + ceData.toolBarData.orientation = toolbar->orientation(); + } + ceData.parentWidgetFlags = getControlElementFlagsForObject(parentWidget, ceData.parentWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields); } - } - if (ceData.widgetObjectTypes.contains("QComboBox")) { - const QComboBox *cb = dynamic_cast<const QComboBox*>(widget); - if (cb) { - const QLineEdit* lineEdit = cb->lineEdit(); - if (lineEdit) { - ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, ceData.widgetObjectTypes, QStyleOption::Default); + const QWidget* topLevelWidget = widget->topLevelWidget(); + if (topLevelWidget) { + ceData.topLevelWidgetData.widgetObjectTypes = getObjectTypeListForObject(topLevelWidget); + ceData.topLevelWidgetData.allDataPopulated = populateReliantFields & populateMinimumNumberOfFields; + const QPixmap* erasePixmap = topLevelWidget->backgroundPixmap(); + if (erasePixmap) { + ceData.topLevelWidgetData.bgPixmap = *erasePixmap; } - const QListBox* listBox = cb->listBox(); - if (listBox) { - ceData.comboBoxListBoxFlags = getControlElementFlagsForObject(listBox, ceData.widgetObjectTypes, QStyleOption::Default); + if (populateReliantFields) { + ceData.topLevelWidgetData.bgBrush = topLevelWidget->backgroundBrush(); } - } - } - if (ceData.widgetObjectTypes.contains("QFrame")) { - const QFrame *frame = dynamic_cast<const QFrame*>(widget); - if (frame) { - ceData.frameStyle = frame->frameStyle(); - } - } - - const QWidget* parentWidget = widget->parentWidget(); - if (parentWidget) { - ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget); - ceData.parentWidgetData.allDataPopulated = populateReliantFields; - const QPixmap* erasePixmap = parentWidget->backgroundPixmap(); - if (erasePixmap) { - ceData.parentWidgetData.bgPixmap = *erasePixmap; - } - if (populateReliantFields) { - ceData.parentWidgetData.bgBrush = parentWidget->backgroundBrush(); - } - ceData.parentWidgetData.wflags = parentWidget->getWFlags(); - if (populateReliantFields) { - ceData.parentWidgetData.windowState = (Qt::WindowState)(widget->windowState()); - } - ceData.parentWidgetData.bgColor = parentWidget->eraseColor(); - ceData.parentWidgetData.bgOffset = parentWidget->backgroundOffset(); - ceData.parentWidgetData.backgroundMode = parentWidget->backgroundMode(); - if (populateReliantFields) { - ceData.parentWidgetData.fgColor = parentWidget->foregroundColor(); - ceData.parentWidgetData.colorGroup = parentWidget->colorGroup(); - ceData.parentWidgetData.paletteBgColor = parentWidget->paletteBackgroundColor(); - } - ceData.parentWidgetData.geometry = parentWidget->geometry(); - ceData.parentWidgetData.rect = parentWidget->rect(); - ceData.parentWidgetData.pos = parentWidget->pos(); - const QPixmap* icon = parentWidget->icon(); - if (icon) { - ceData.parentWidgetData.icon = *icon; - } - ceData.parentWidgetData.palette = parentWidget->palette(); - 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 (dw->area()) { - ceData.dwData.hasDockArea = true; - ceData.dwData.areaOrientation = dw->area()->orientation(); + if (populateReliantFields) { + ceData.topLevelWidgetData.windowState = (Qt::WindowState)(widget->windowState()); } - else { - ceData.dwData.hasDockArea = false; + ceData.topLevelWidgetData.wflags = topLevelWidget->getWFlags(); + ceData.topLevelWidgetData.bgColor = topLevelWidget->eraseColor(); + ceData.topLevelWidgetData.bgOffset = topLevelWidget->backgroundOffset(); + ceData.topLevelWidgetData.backgroundMode = topLevelWidget->backgroundMode(); + if (populateReliantFields) { + ceData.topLevelWidgetData.fgColor = topLevelWidget->foregroundColor(); + ceData.topLevelWidgetData.colorGroup = topLevelWidget->colorGroup(); + ceData.topLevelWidgetData.paletteBgColor = topLevelWidget->paletteBackgroundColor(); } - ceData.dwData.closeEnabled = dw->isCloseEnabled(); - } - const QToolBar * toolbar = dynamic_cast<const QToolBar*>(parentWidget); - if (toolbar) { - ceData.toolBarData.orientation = toolbar->orientation(); - } - ceData.parentWidgetFlags = getControlElementFlagsForObject(parentWidget, ceData.parentWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields); - } - const QWidget* topLevelWidget = widget->topLevelWidget(); - if (topLevelWidget) { - ceData.topLevelWidgetData.widgetObjectTypes = getObjectTypeListForObject(topLevelWidget); - ceData.topLevelWidgetData.allDataPopulated = populateReliantFields; - const QPixmap* erasePixmap = topLevelWidget->backgroundPixmap(); - if (erasePixmap) { - ceData.topLevelWidgetData.bgPixmap = *erasePixmap; - } - if (populateReliantFields) { - ceData.topLevelWidgetData.bgBrush = topLevelWidget->backgroundBrush(); - } - ceData.topLevelWidgetData.wflags = topLevelWidget->getWFlags(); - if (populateReliantFields) { - ceData.topLevelWidgetData.windowState = (Qt::WindowState)(widget->windowState()); - } - ceData.topLevelWidgetData.bgColor = topLevelWidget->eraseColor(); - ceData.topLevelWidgetData.bgOffset = topLevelWidget->backgroundOffset(); - ceData.topLevelWidgetData.backgroundMode = topLevelWidget->backgroundMode(); - if (populateReliantFields) { - ceData.topLevelWidgetData.fgColor = topLevelWidget->foregroundColor(); - ceData.topLevelWidgetData.colorGroup = topLevelWidget->colorGroup(); - ceData.topLevelWidgetData.paletteBgColor = topLevelWidget->paletteBackgroundColor(); - } - ceData.topLevelWidgetData.geometry = topLevelWidget->geometry(); - ceData.topLevelWidgetData.rect = topLevelWidget->rect(); - ceData.topLevelWidgetData.pos = topLevelWidget->pos(); - const QPixmap* icon = topLevelWidget->icon(); - if (icon) { - ceData.topLevelWidgetData.icon = *icon; - } - ceData.topLevelWidgetData.palette = topLevelWidget->palette(); - 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 (dw->area()) { - ceData.dwData.hasDockArea = true; - ceData.dwData.areaOrientation = dw->area()->orientation(); + ceData.topLevelWidgetData.geometry = topLevelWidget->geometry(); + ceData.topLevelWidgetData.rect = topLevelWidget->rect(); + ceData.topLevelWidgetData.pos = topLevelWidget->pos(); + const QPixmap* icon = topLevelWidget->icon(); + if (icon) { + ceData.topLevelWidgetData.icon = *icon; } - else { - ceData.dwData.hasDockArea = false; + ceData.topLevelWidgetData.palette = topLevelWidget->palette(); + 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 (dw->area()) { + ceData.dwData.hasDockArea = true; + ceData.dwData.areaOrientation = dw->area()->orientation(); + } + else { + ceData.dwData.hasDockArea = false; + } + ceData.dwData.closeEnabled = dw->isCloseEnabled(); + } + const QToolBar * toolbar = dynamic_cast<const QToolBar*>(topLevelWidget); + if (toolbar) { + ceData.toolBarData.orientation = toolbar->orientation(); } - ceData.dwData.closeEnabled = dw->isCloseEnabled(); + ceData.topLevelWidgetFlags = getControlElementFlagsForObject(topLevelWidget, ceData.topLevelWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields); } - const QToolBar * toolbar = dynamic_cast<const QToolBar*>(topLevelWidget); - if (toolbar) { - ceData.toolBarData.orientation = toolbar->orientation(); + + QCheckListItem *item = opt.checkListItem(); + if (item) { + ceData.checkListItemData.dataValid = true; + ceData.checkListItemData.enabled = item->isEnabled(); + ceData.checkListItemData.hasParent = ( item->parent() && (item->parent()->rtti() == 1) && (((QCheckListItem*) item->parent())->type() == QCheckListItem::Controller) ); + ceData.checkListItemData.height = item->height(); + } + else { + ceData.checkListItemData.dataValid = false; } - ceData.topLevelWidgetFlags = getControlElementFlagsForObject(topLevelWidget, ceData.topLevelWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields); - } - - QCheckListItem *item = opt.checkListItem(); - if (item) { - ceData.checkListItemData.dataValid = true; - ceData.checkListItemData.enabled = item->isEnabled(); - ceData.checkListItemData.hasParent = ( item->parent() && (item->parent()->rtti() == 1) && (((QCheckListItem*) item->parent())->type() == QCheckListItem::Controller) ); - ceData.checkListItemData.height = item->height(); - } - else { - ceData.checkListItemData.dataValid = false; } } @@ -687,7 +696,7 @@ QStyleControlElementData populateControlElementDataFromApplication(const QApplic /*! \reimp */ void QCommonStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -1165,7 +1174,7 @@ void qt_style_erase_region(QPainter* p, const QRegion& region, QStyleControlElem /*! \reimp */ void QCommonStyle::drawControl( ControlElement element, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -1611,7 +1620,7 @@ void QCommonStyle::drawControl( ControlElement element, { QRect rect = r; - QIconSet* icon = &ceData.iconSet; + const QIconSet* icon = &ceData.iconSet; if ( icon ) { QPixmap pixmap = icon->pixmap( QIconSet::Small, flags & Style_Enabled ? @@ -1645,7 +1654,7 @@ void QCommonStyle::drawControl( ControlElement element, /*! \reimp */ void QCommonStyle::drawControlMask( ControlElement control, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QStyleOption& opt, @@ -1681,7 +1690,7 @@ void QCommonStyle::drawControlMask( ControlElement control, } /*! \reimp */ -QRect QCommonStyle::subRect(SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget) const +QRect QCommonStyle::subRect(SubRect r, const QStyleControlElementData &ceData, const ControlElementFlags elementFlags, const QWidget *widget) const { QRect rect, wrect(ceData.rect); @@ -1977,7 +1986,7 @@ QRect QCommonStyle::subRect(SubRect r, const QStyleControlElementData ceData, co /* I really need this and I don't want to expose it in QRangeControl.. */ -static int qPositionFromValue( QStyleControlElementData ceData, int logical_val, +static int qPositionFromValue( const QStyleControlElementData &ceData, int logical_val, int span ) { if ( span <= 0 || logical_val < ceData.minSteps || @@ -2010,7 +2019,7 @@ static int qPositionFromValue( QStyleControlElementData ceData, int logical_val, /*! \reimp */ void QCommonStyle::drawComplexControl( ComplexControl control, QPainter *p, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, @@ -2412,7 +2421,7 @@ void QCommonStyle::drawComplexControl( ComplexControl control, /*! \reimp */ void QCommonStyle::drawComplexControlMask( ComplexControl control, QPainter *p, - const QStyleControlElementData ceData, + const QStyleControlElementData &ceData, const ControlElementFlags elementFlags, const QRect &r, const QStyleOption& opt, @@ -2429,7 +2438,7 @@ void QCommonStyle::drawComplexControlMask( ComplexControl control, /*! \reimp */ QRect QCommonStyle::querySubControlMetrics( ComplexControl control, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, SubControl sc, const QStyleOption &opt, @@ -2663,7 +2672,7 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control, /*! \reimp */ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QPoint &pos, const QStyleOption& opt, @@ -2738,7 +2747,7 @@ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control, } /*! \reimp */ -int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget) const +int QCommonStyle::pixelMetric(PixelMetric m, const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QWidget *widget) const { int ret; @@ -2962,7 +2971,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, Co /*! \reimp */ QSize QCommonStyle::sizeFromContents(ContentsType contents, - QStyleControlElementData ceData, + const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QSize &contentsSize, const QStyleOption& opt, @@ -3132,7 +3141,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents, } /*! \reimp */ -int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget * w) const +int QCommonStyle::styleHint(StyleHint sh, const QStyleControlElementData &ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget * w) const { Q_UNUSED(w); @@ -3215,7 +3224,7 @@ int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, Contr } /*! \reimp */ -QPixmap QCommonStyle::stylePixmap(StylePixmap, QStyleControlElementData, ControlElementFlags, const QStyleOption&, const QWidget *) const +QPixmap QCommonStyle::stylePixmap(StylePixmap, const QStyleControlElementData&, ControlElementFlags, const QStyleOption&, const QWidget *) const { return QPixmap(); } |