summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2011-04-14 09:26:34 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2011-04-14 09:26:34 (GMT)
commit56c3de426d97ab7c8fbb3f5766e1872d6f2e91e9 (patch)
tree0324344f42b474c77a745aa524f947a5c10414f4 /src
parent3d188ffae259584c4351c5fa766a49da9b189112 (diff)
downloadQt-56c3de426d97ab7c8fbb3f5766e1872d6f2e91e9.zip
Qt-56c3de426d97ab7c8fbb3f5766e1872d6f2e91e9.tar.gz
Qt-56c3de426d97ab7c8fbb3f5766e1872d6f2e91e9.tar.bz2
Fix copyright and a few codestyle mistakes
Reviewed-By: Trust-Me Merge-Request: 916
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qmenubar.cpp194
-rw-r--r--src/gui/widgets/qmenubarimpl.cpp18
-rw-r--r--src/gui/widgets/qmenubarimpl_p.h15
3 files changed, 113 insertions, 114 deletions
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 556c192..357c0fa 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -122,8 +122,8 @@ QSize QMenuBarExtension::sizeHint() const
*/
QAction *QMenuBarPrivate::actionAt(QPoint p) const
{
- for(int i = 0; i < actions.size(); ++i) {
- if(actionRect(actions.at(i)).contains(p))
+ for (int i = 0; i < actions.size(); ++i) {
+ if (actionRect(actions.at(i)).contains(p))
return actions.at(i);
}
return 0;
@@ -171,12 +171,12 @@ bool QMenuBarPrivate::isVisible(QAction *action)
void QMenuBarPrivate::updateGeometries()
{
Q_Q(QMenuBar);
- if(!itemsDirty)
+ if (!itemsDirty)
return;
int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2);
int q_start = -1;
- if(impl->allowCornerWidgets() && (leftWidget || rightWidget)) {
+ if (impl->allowCornerWidgets() && (leftWidget || rightWidget)) {
int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q)
+ q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q)
@@ -199,7 +199,7 @@ void QMenuBarPrivate::updateGeometries()
}
#ifndef QT_NO_SHORTCUT
- if(!impl->shortcutsHandledByNativeMenuBar() && itemsDirty) {
+ if (!impl->shortcutsHandledByNativeMenuBar() && itemsDirty) {
for(int j = 0; j < shortcutIndexMap.size(); ++j)
q->releaseShortcut(shortcutIndexMap.value(j));
shortcutIndexMap.resize(0); // faster than clear
@@ -207,7 +207,7 @@ void QMenuBarPrivate::updateGeometries()
shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
}
#endif
- if(q->isNativeMenuBar()) {//nothing to see here folks, move along..
+ if (q->isNativeMenuBar()) {//nothing to see here folks, move along..
itemsDirty = false;
return;
}
@@ -282,7 +282,7 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const
void QMenuBarPrivate::focusFirstAction()
{
- if(!currentAction) {
+ if (!currentAction) {
updateGeometries();
int index = 0;
while (index < actions.count() && actionRects.at(index).isNull()) ++index;
@@ -299,16 +299,16 @@ void QMenuBarPrivate::setKeyboardMode(bool b)
return;
}
keyboardState = b;
- if(b) {
+ if (b) {
QWidget *fw = QApplication::focusWidget();
if (fw != q)
keyboardFocusWidget = fw;
focusFirstAction();
q->setFocus(Qt::MenuBarFocusReason);
} else {
- if(!popupState)
+ if (!popupState)
setCurrentAction(0);
- if(keyboardFocusWidget) {
+ if (keyboardFocusWidget) {
if (QApplication::focusWidget() == q)
keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason);
keyboardFocusWidget = 0;
@@ -320,7 +320,7 @@ void QMenuBarPrivate::setKeyboardMode(bool b)
void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
{
Q_Q(QMenuBar);
- if(!action || !action->menu() || closePopupMode)
+ if (!action || !action->menu() || closePopupMode)
return;
popupState = true;
if (action->isEnabled() && action->menu()->isEnabled()) {
@@ -360,10 +360,10 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
pos.rx() += actionWidth;
}
- if(!defaultPopDown || (fitUp && !fitDown))
+ if (!defaultPopDown || (fitUp && !fitDown))
pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
activeMenu->popup(pos);
- if(activateFirst)
+ if (activateFirst)
activeMenu->d_func()->setFirstActionActive();
}
q->update(actionRect(action));
@@ -371,7 +371,7 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst)
{
- if(currentAction == action && popup == popupState)
+ if (currentAction == action && popup == popupState)
return;
autoReleaseTimer.stop();
@@ -379,7 +379,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat
doChildEffects = (popup && !activeMenu);
Q_Q(QMenuBar);
QWidget *fw = 0;
- if(QMenu *menu = activeMenu) {
+ if (QMenu *menu = activeMenu) {
activeMenu = 0;
if (popup) {
fw = q->window()->focusWidget();
@@ -388,7 +388,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat
menu->hide();
}
- if(currentAction)
+ if (currentAction)
q->update(actionRect(currentAction));
popupState = popup;
@@ -398,7 +398,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat
currentAction = action;
if (action) {
activateAction(action, QAction::Hover);
- if(popup)
+ if (popup)
popupAction(action, activateFirst);
q->update(actionRect(action));
#ifndef QT_NO_STATUSTIP
@@ -416,7 +416,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
{
Q_Q(const QMenuBar);
- if(!itemsDirty)
+ if (!itemsDirty)
return;
//let's reinitialize the buffer
@@ -435,13 +435,13 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
for(int i = 0; i < actions.count(); i++) {
QAction *action = actions.at(i);
- if(!action->isVisible())
+ if (!action->isVisible())
continue;
QSize sz;
//calc what I think the size is..
- if(action->isSeparator()) {
+ i f(action->isSeparator()) {
if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q))
separator = i;
continue; //we don't really position these!
@@ -460,10 +460,10 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
q->initStyleOption(&opt, action);
sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q);
- if(!sz.isEmpty()) {
+ if (!sz.isEmpty()) {
{ //update the separator state
int iWidth = sz.width() + itemSpacing;
- if(separator == -1)
+ if (separator == -1)
separator_start += iWidth;
else
separator_len += iWidth;
@@ -488,9 +488,9 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
rect.setHeight(max_item_height);
//move
- if(separator != -1 && i >= separator) { //after the separator
+ if (separator != -1 && i >= separator) { //after the separator
int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin);
- if(left < separator_start) { //wrap
+ if (left < separator_start) { //wrap
separator_start = x = hmargin;
y += max_item_height;
}
@@ -517,9 +517,9 @@ void QMenuBarPrivate::activateAction(QAction *action, QAction::ActionEvent actio
if (action_e == QAction::Hover)
action->showStatusText(q);
-// if(action_e == QAction::Trigger)
+// if (action_e == QAction::Trigger)
// emit q->activated(action);
-// else if(action_e == QAction::Hover)
+// else if (action_e == QAction::Hover)
// emit q->highlighted(action);
}
@@ -1011,7 +1011,7 @@ void QMenuBar::paintEvent(QPaintEvent *e)
QRect adjustedActionRect = d->actionRect(action);
if (adjustedActionRect.isEmpty() || !d->isVisible(action))
continue;
- if(!e->rect().intersects(adjustedActionRect))
+ if (!e->rect().intersects(adjustedActionRect))
continue;
emptyArea -= adjustedActionRect;
@@ -1022,7 +1022,7 @@ void QMenuBar::paintEvent(QPaintEvent *e)
style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this);
}
//draw border
- if(int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)) {
+ if (int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)) {
QRegion borderReg;
borderReg += QRect(0, 0, fw, height()); //left
borderReg += QRect(width()-fw, 0, fw, height()); //right
@@ -1064,7 +1064,7 @@ void QMenuBar::setVisible(bool visible)
void QMenuBar::mousePressEvent(QMouseEvent *e)
{
Q_D(QMenuBar);
- if(e->button() != Qt::LeftButton)
+ if (e->button() != Qt::LeftButton)
return;
d->mouseDown = true;
@@ -1079,13 +1079,13 @@ void QMenuBar::mousePressEvent(QMouseEvent *e)
return;
}
- if(d->currentAction == action && d->popupState) {
- if(QMenu *menu = d->activeMenu) {
+ if (d->currentAction == action && d->popupState) {
+ if (QMenu *menu = d->activeMenu) {
d->activeMenu = 0;
menu->hide();
}
#ifdef Q_WS_WIN
- if((d->closePopupMode = style()->styleHint(QStyle::SH_MenuBar_DismissOnSecondClick)))
+ if ((d->closePopupMode = style()->styleHint(QStyle::SH_MenuBar_DismissOnSecondClick)))
update(d->actionRect(action));
#endif
} else {
@@ -1099,16 +1099,16 @@ void QMenuBar::mousePressEvent(QMouseEvent *e)
void QMenuBar::mouseReleaseEvent(QMouseEvent *e)
{
Q_D(QMenuBar);
- if(e->button() != Qt::LeftButton || !d->mouseDown)
+ if (e->button() != Qt::LeftButton || !d->mouseDown)
return;
d->mouseDown = false;
QAction *action = d->actionAt(e->pos());
- if((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) {
+ if ((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) {
//we set the current action before activating
//so that we let the leave event set the current back to 0
d->setCurrentAction(action, false);
- if(action)
+ if (action)
d->activateAction(action, QAction::Trigger);
}
d->closePopupMode = 0;
@@ -1122,15 +1122,15 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
Q_D(QMenuBar);
d->updateGeometries();
int key = e->key();
- if(isRightToLeft()) { // in reverse mode open/close key for submenues are reversed
- if(key == Qt::Key_Left)
+ if (isRightToLeft()) { // in reverse mode open/close key for submenues are reversed
+ if (key == Qt::Key_Left)
key = Qt::Key_Right;
- else if(key == Qt::Key_Right)
+ else if (key == Qt::Key_Right)
key = Qt::Key_Left;
}
- if(key == Qt::Key_Tab) //means right
+ if (key == Qt::Key_Tab) //means right
key = Qt::Key_Right;
- else if(key == Qt::Key_Backtab) //means left
+ else if (key == Qt::Key_Backtab) //means left
key = Qt::Key_Left;
bool key_consumed = false;
@@ -1140,11 +1140,11 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
case Qt::Key_Enter:
case Qt::Key_Space:
case Qt::Key_Return: {
- if(!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) || !d->currentAction)
+ if (!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) || !d->currentAction)
break;
- if(d->currentAction->menu()) {
+ if (d->currentAction->menu()) {
d->popupAction(d->currentAction, true);
- } else if(key == Qt::Key_Enter || key == Qt::Key_Return || key == Qt::Key_Space) {
+ } else if (key == Qt::Key_Enter || key == Qt::Key_Return || key == Qt::Key_Space) {
d->activateAction(d->currentAction, QAction::Trigger);
d->setCurrentAction(d->currentAction, false);
d->setKeyboardMode(false);
@@ -1154,7 +1154,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
case Qt::Key_Right:
case Qt::Key_Left: {
- if(d->currentAction) {
+ if (d->currentAction) {
int index = d->actions.indexOf(d->currentAction);
if (QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1)) {
d->setCurrentAction(nextAction, d->popupState, true);
@@ -1173,7 +1173,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
key_consumed = false;
}
- if(!key_consumed &&
+ if (!key_consumed &&
(!e->modifiers() ||
(e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().length()==1 && !d->popupState) {
int clashCount = 0;
@@ -1185,14 +1185,14 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
continue;
QAction *act = d->actions.at(i);
QString s = act->text();
- if(!s.isEmpty()) {
+ if (!s.isEmpty()) {
int ampersand = s.indexOf(QLatin1Char('&'));
- if(ampersand >= 0) {
- if(s[ampersand+1].toUpper() == c) {
+ if (ampersand >= 0) {
+ if (s[ampersand+1].toUpper() == c) {
clashCount++;
- if(!first)
+ if (!first)
first = act;
- if(act == d->currentAction)
+ if (act == d->currentAction)
currentSelected = act;
else if (!firstAfterCurrent && currentSelected)
firstAfterCurrent = act;
@@ -1202,18 +1202,18 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
}
}
QAction *next_action = 0;
- if(clashCount >= 1) {
- if(clashCount == 1 || !d->currentAction || (currentSelected && !firstAfterCurrent))
+ if (clashCount >= 1) {
+ if (clashCount == 1 || !d->currentAction || (currentSelected && !firstAfterCurrent))
next_action = first;
else
next_action = firstAfterCurrent;
}
- if(next_action) {
+ if (next_action) {
key_consumed = true;
d->setCurrentAction(next_action, true, true);
}
}
- if(key_consumed)
+ if (key_consumed)
e->accept();
else
e->ignore();
@@ -1239,7 +1239,7 @@ void QMenuBar::mouseMoveEvent(QMouseEvent *e)
void QMenuBar::leaveEvent(QEvent *)
{
Q_D(QMenuBar);
- if((!hasFocus() && !d->popupState) ||
+ if ((!hasFocus() && !d->popupState) ||
(d->currentAction && d->currentAction->menu() == 0))
d->setCurrentAction(0);
}
@@ -1253,10 +1253,10 @@ void QMenuBar::actionEvent(QActionEvent *e)
d->itemsDirty = true;
d->impl->actionEvent(e);
- if(e->type() == QEvent::ActionAdded) {
+ if (e->type() == QEvent::ActionAdded) {
connect(e->action(), SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
connect(e->action(), SIGNAL(hovered()), this, SLOT(_q_actionHovered()));
- } else if(e->type() == QEvent::ActionRemoved) {
+ } else if (e->type() == QEvent::ActionRemoved) {
e->action()->disconnect(this);
}
if (isVisible()) {
@@ -1271,7 +1271,7 @@ void QMenuBar::actionEvent(QActionEvent *e)
void QMenuBar::focusInEvent(QFocusEvent *)
{
Q_D(QMenuBar);
- if(d->keyboardState)
+ if (d->keyboardState)
d->focusFirstAction();
}
@@ -1281,7 +1281,7 @@ void QMenuBar::focusInEvent(QFocusEvent *)
void QMenuBar::focusOutEvent(QFocusEvent *)
{
Q_D(QMenuBar);
- if(!d->popupState) {
+ if (!d->popupState) {
d->setCurrentAction(0);
d->setKeyboardMode(false);
}
@@ -1371,10 +1371,10 @@ bool QMenuBar::autoGeometry() const
void QMenuBar::changeEvent(QEvent *e)
{
Q_D(QMenuBar);
- if(e->type() == QEvent::StyleChange) {
+ if (e->type() == QEvent::StyleChange) {
d->itemsDirty = true;
setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this));
- if(parentWidget())
+ if (parentWidget())
resize(parentWidget()->width(), heightForWidth(parentWidget()->width()));
d->updateGeometries();
} else if (e->type() == QEvent::ParentChange) {
@@ -1403,12 +1403,12 @@ bool QMenuBar::event(QEvent *e)
case QEvent::KeyPress: {
QKeyEvent *ke = (QKeyEvent*)e;
#if 0
- if(!d->keyboardState) { //all keypresses..
+ if (!d->keyboardState) { //all keypresses..
d->setCurrentAction(0);
return ;
}
#endif
- if(ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
+ if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
keyPressEvent(ke);
return true;
}
@@ -1426,7 +1426,7 @@ bool QMenuBar::event(QEvent *e)
#endif
case QEvent::Show:
#ifdef QT3_SUPPORT
- if(QWidget *p = parentWidget()) {
+ if (QWidget *p = parentWidget()) {
// If itemsDirty == true, updateGeometries sends the MenubarUpdated event.
if (!d->itemsDirty) {
QMenubarUpdatedEvent menubarUpdated(this);
@@ -1448,7 +1448,7 @@ bool QMenuBar::event(QEvent *e)
#ifdef QT3_SUPPORT
case QEvent::Hide: {
- if(QWidget *p = parentWidget()) {
+ if (QWidget *p = parentWidget()) {
QMenubarUpdatedEvent menubarUpdated(this);
QApplication::sendEvent(p, &menubarUpdated);
}
@@ -1584,7 +1584,7 @@ QSize QMenuBar::minimumSizeHint() const
const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
- if(as_gui_menubar) {
+ if (as_gui_menubar) {
int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width();
d->calcActionRects(w - (2 * fw), 0);
for (int i = 0; ret.isNull() && i < d->actions.count(); ++i)
@@ -1595,20 +1595,20 @@ QSize QMenuBar::minimumSizeHint() const
}
int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
if (d->impl->allowCornerWidgets()) {
- if(d->leftWidget) {
+ if (d->leftWidget) {
QSize sz = d->leftWidget->minimumSizeHint();
ret.setWidth(ret.width() + sz.width());
- if(sz.height() + margin > ret.height())
+ if (sz.height() + margin > ret.height())
ret.setHeight(sz.height() + margin);
}
- if(d->rightWidget) {
+ if (d->rightWidget) {
QSize sz = d->rightWidget->minimumSizeHint();
ret.setWidth(ret.width() + sz.width());
- if(sz.height() + margin > ret.height())
+ if (sz.height() + margin > ret.height())
ret.setHeight(sz.height() + margin);
}
}
- if(as_gui_menubar) {
+ if (as_gui_menubar) {
QStyleOptionMenuItem opt;
opt.rect = rect();
opt.menuRect = rect();
@@ -1638,7 +1638,7 @@ QSize QMenuBar::sizeHint() const
const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
- if(as_gui_menubar) {
+ if (as_gui_menubar) {
const int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width();
d->calcActionRects(w - (2 * fw), 0);
for (int i = 0; i < d->actionRects.count(); ++i) {
@@ -1650,21 +1650,21 @@ QSize QMenuBar::sizeHint() const
ret += QSize(fw + hmargin, fw + vmargin);
}
int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
- if(d->impl->allowCornerWidgets()) {
- if(d->leftWidget) {
+ if (d->impl->allowCornerWidgets()) {
+ if (d->leftWidget) {
QSize sz = d->leftWidget->sizeHint();
ret.setWidth(ret.width() + sz.width());
- if(sz.height() + margin > ret.height())
+ if (sz.height() + margin > ret.height())
ret.setHeight(sz.height() + margin);
}
- if(d->rightWidget) {
+ if (d->rightWidget) {
QSize sz = d->rightWidget->sizeHint();
ret.setWidth(ret.width() + sz.width());
- if(sz.height() + margin > ret.height())
+ if (sz.height() + margin > ret.height())
ret.setHeight(sz.height() + margin);
}
}
- if(as_gui_menubar) {
+ if (as_gui_menubar) {
QStyleOptionMenuItem opt;
opt.rect = rect();
opt.menuRect = rect();
@@ -1692,7 +1692,7 @@ int QMenuBar::heightForWidth(int) const
const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
- if(as_gui_menubar) {
+ if (as_gui_menubar) {
for (int i = 0; i < d->actionRects.count(); ++i)
height = qMax(height, d->actionRects.at(i).height());
if (height) //there is at least one non-null item
@@ -1701,13 +1701,13 @@ int QMenuBar::heightForWidth(int) const
height += 2*vmargin;
}
int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
- if(d->impl->allowCornerWidgets()) {
- if(d->leftWidget)
+ if (d->impl->allowCornerWidgets()) {
+ if (d->leftWidget)
height = qMax(d->leftWidget->sizeHint().height() + margin, height);
- if(d->rightWidget)
+ if (d->rightWidget)
height = qMax(d->rightWidget->sizeHint().height() + margin, height);
}
- if(as_gui_menubar) {
+ if (as_gui_menubar) {
QStyleOptionMenuItem opt;
opt.init(this);
opt.menuRect = rect();
@@ -1814,13 +1814,11 @@ void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner)
return;
}
- if(!d->impl->allowCornerWidgets()) {
+ if (!d->impl->allowCornerWidgets()) {
d->updateCornerWidgetToolBar();
- } else {
- if (w) {
- w->setParent(this);
- w->installEventFilter(this);
- }
+ } else if (w) {
+ w->setParent(this);
+ w->installEventFilter(this);
}
d->_q_updateLayout();
@@ -1974,17 +1972,17 @@ int QMenuBar::insertAny(const QIcon *icon, const QString *text, const QObject *r
const QKeySequence *shortcut, const QMenu *popup, int id, int index)
{
QAction *act = popup ? popup->menuAction() : new QAction(this);
- if(id != -1)
+ if (id != -1)
static_cast<QMenuItem*>(act)->setId(id);
- if(icon)
+ if (icon)
act->setIcon(*icon);
- if(text)
+ if (text)
act->setText(*text);
- if(shortcut)
+ if (shortcut)
act->setShortcut(*shortcut);
- if(receiver && member)
+ if (receiver && member)
QObject::connect(act, SIGNAL(triggered(bool)), receiver, member);
- if(index == -1 || index >= actions().count())
+ if (index == -1 || index >= actions().count())
addAction(act);
else
insertAction(actions().value(index), act);
@@ -2006,7 +2004,7 @@ int QMenuBar::insertSeparator(int index)
{
QAction *act = new QAction(this);
act->setSeparator(true);
- if(index == -1 || index >= actions().count())
+ if (index == -1 || index >= actions().count())
addAction(act);
else
insertAction(actions().value(index), act);
@@ -2018,7 +2016,7 @@ int QMenuBar::insertSeparator(int index)
*/
bool QMenuBar::setItemParameter(int id, int param)
{
- if(QAction *act = findActionForId(id)) {
+ if (QAction *act = findActionForId(id)) {
act->d_func()->param = param;
return true;
}
@@ -2030,7 +2028,7 @@ bool QMenuBar::setItemParameter(int id, int param)
*/
int QMenuBar::itemParameter(int id) const
{
- if(QAction *act = findActionForId(id))
+ if (QAction *act = findActionForId(id))
return act->d_func()->param;
return id;
}
diff --git a/src/gui/widgets/qmenubarimpl.cpp b/src/gui/widgets/qmenubarimpl.cpp
index 4f2ad72..d402507 100644
--- a/src/gui/widgets/qmenubarimpl.cpp
+++ b/src/gui/widgets/qmenubarimpl.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include "qmenubarimpl_p.h"
#ifndef QT_NO_MENUBAR
@@ -75,16 +76,15 @@ void QMenuBarImpl::init(QMenuBar *_menuBar)
#endif
#ifdef Q_WS_MAC
macCreateMenuBar(menuBar->parentWidget());
- if(adapter)
+ if (adapter)
menuBar->hide();
#endif
#ifdef Q_WS_WINCE
if (qt_wince_is_mobile()) {
wceCreateMenuBar(menuBar->parentWidget());
- if(adapter)
+ if (adapter)
menuBar->hide();
- }
- else {
+ } else {
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);
}
#endif
@@ -106,11 +106,11 @@ void QMenuBarImpl::actionEvent(QActionEvent *e)
{
#if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60)
if (adapter) {
- if(e->type() == QEvent::ActionAdded)
+ if (e->type() == QEvent::ActionAdded)
adapter->addAction(e->action(), e->before());
- else if(e->type() == QEvent::ActionRemoved)
+ else if (e->type() == QEvent::ActionRemoved)
adapter->removeAction(e->action());
- else if(e->type() == QEvent::ActionChanged)
+ else if (e->type() == QEvent::ActionChanged)
adapter->syncAction(e->action());
}
#else
@@ -251,7 +251,7 @@ QMenuBarImplFactoryInterface *qt_guiMenuBarImplFactory()
QFactoryLoader loader(QMenuBarImplFactoryInterface_iid, QLatin1String("/menubar"));
factory = qobject_cast<QMenuBarImplFactoryInterface *>(loader.instance(QLatin1String("default")));
#endif // QT_NO_LIBRARY
- if(!factory) {
+ if (!factory) {
static QMenuBarImplFactory def;
factory = &def;
}
diff --git a/src/gui/widgets/qmenubarimpl_p.h b/src/gui/widgets/qmenubarimpl_p.h
index 08ac6a0..749c395 100644
--- a/src/gui/widgets/qmenubarimpl_p.h
+++ b/src/gui/widgets/qmenubarimpl_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#ifndef QMENUBARIMPL_P_H
#define QMENUBARIMPL_P_H
@@ -91,9 +92,9 @@ private:
void removeAction(QMacMenuAction *);
inline void removeAction(QAction *a) { removeAction(findAction(a)); }
inline QMacMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
+ for (int i = 0; i < actionItems.size(); i++) {
QMacMenuAction *act = actionItems[i];
- if(a == act->action)
+ if (a == act->action)
return act;
}
return 0;
@@ -131,9 +132,9 @@ private:
void rebuild();
inline void removeAction(QAction *a) { removeAction(findAction(a)); }
inline QWceMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
+ for (int i = 0; i < actionItems.size(); i++) {
QWceMenuAction *act = actionItems[i];
- if(a == act->action)
+ if (a == act->action)
return act;
}
return 0;
@@ -161,9 +162,9 @@ private:
void rebuild();
inline void removeAction(QAction *a) { removeAction(findAction(a)); }
inline QSymbianMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
+ for (int i = 0; i < actionItems.size(); i++) {
QSymbianMenuAction *act = actionItems[i];
- if(a == act->action)
+ if (a == act->action)
return act;
}
return 0;