Remove QT3_SUPPORT code from QMenu classes

Change-Id: I22df8f96ddca9784d6487a59a0c780ca9641fe23
Reviewed-on: http://codereview.qt-project.org/4434
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Liang Qi <liang.qi@nokia.com>
This commit is contained in:
Morten Sorvig 2011-09-07 11:44:00 +02:00 committed by Liang Qi
parent 6f65a55fa9
commit 9abb38f5a6
8 changed files with 0 additions and 1485 deletions

View File

@ -69,9 +69,6 @@
#include <private/qpushbutton_p.h>
#include <private/qaction_p.h>
#include <private/qsoftkeymanager_p.h>
#ifdef QT3_SUPPORT
#include <qmenudata.h>
#endif // QT3_SUPPORT
#ifdef Q_WS_X11
# include <private/qt_x11_p.h>
@ -578,9 +575,6 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
#ifndef QT_NO_STATUSTIP
QAction *previousAction = currentAction;
#endif
#ifdef QT3_SUPPORT
emitHighlighted = action;
#endif
currentAction = action;
if (action) {
@ -1012,9 +1006,6 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)
{
QBoolBlocker guard(activationRecursionGuard);
#ifdef QT3_SUPPORT
const int actionId = q_func()->findIdForAction(action);
#endif
if(self)
action->activate(action_e);
@ -1029,28 +1020,13 @@ void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedSt
emit qmenu->triggered(action);
} else if (action_e == QAction::Hover) {
emit qmenu->hovered(action);
#ifdef QT3_SUPPORT
if (emitHighlighted) {
emit qmenu->highlighted(actionId);
emitHighlighted = false;
}
#endif
}
#ifndef QT_NO_MENUBAR
} else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) {
if (action_e == QAction::Trigger) {
emit qmenubar->triggered(action);
#ifdef QT3_SUPPORT
emit qmenubar->activated(actionId);
#endif
} else if (action_e == QAction::Hover) {
emit qmenubar->hovered(action);
#ifdef QT3_SUPPORT
if (emitHighlighted) {
emit qmenubar->highlighted(actionId);
emitHighlighted = false;
}
#endif
}
break; //nothing more..
#endif
@ -1130,15 +1106,7 @@ void QMenuPrivate::_q_actionTriggered()
Q_Q(QMenu);
if (QAction *action = qobject_cast<QAction *>(q->sender())) {
QWeakPointer<QAction> actionGuard = action;
#ifdef QT3_SUPPORT
//we store it here because the action might be deleted/changed by connected slots
const int id = q->findIdForAction(action);
#endif
emit q->triggered(action);
#ifdef QT3_SUPPORT
emit q->activated(id);
#endif
if (!activationRecursionGuard && actionGuard) {
//in case the action has not been activated by the mouse
//we check the parent hierarchy
@ -1164,17 +1132,7 @@ void QMenuPrivate::_q_actionHovered()
{
Q_Q(QMenu);
if (QAction * action = qobject_cast<QAction *>(q->sender())) {
#ifdef QT3_SUPPORT
//we store it here because the action might be deleted/changed by connected slots
const int id = q->findIdForAction(action);
#endif
emit q->hovered(action);
#ifdef QT3_SUPPORT
if (emitHighlighted) {
emit q->highlighted(id);
emitHighlighted = false;
}
#endif
}
}
@ -3133,429 +3091,6 @@ void QMenu::setSeparatorsCollapsible(bool collapse)
d->platformMenu->syncSeparatorsCollapsible(collapse);
}
#ifdef QT3_SUPPORT
int QMenu::insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
const QKeySequence *shortcut, const QMenu *popup, int id, int index)
{
QAction *act = popup ? popup->menuAction() : new QAction(this);
if (id != -1)
static_cast<QMenuItem*>(act)->setId(id);
if (icon)
act->setIcon(*icon);
if (text)
act->setText(*text);
if (shortcut)
act->setShortcut(*shortcut);
if (receiver && member)
QObject::connect(act, SIGNAL(activated(int)), receiver, member);
if (index == -1 || index >= actions().count())
addAction(act);
else
insertAction(actions().value(index), act);
return findIdForAction(act);
}
/*!
Use insertAction() or one of the addAction() overloads instead.
*/
int QMenu::insertItem(QMenuItem *item, int id, int index)
{
if (index == -1 || index >= actions().count())
addAction(item);
else
insertAction(actions().value(index), item);
if (id > -1)
item->d_func()->id = id;
return findIdForAction(item);
}
/*!
Use the insertSeparator() overload that takes a QAction *
parameter instead.
*/
int QMenu::insertSeparator(int index)
{
QAction *act = new QAction(this);
act->setSeparator(true);
if (index == -1 || index >= actions().count())
addAction(act);
else
insertAction(actions().value(index), act);
return findIdForAction(act);
}
QAction *QMenu::findActionForId(int id) const
{
Q_D(const QMenu);
for (int i = 0; i < d->actions.size(); ++i) {
QAction *act = d->actions.at(i);
if (findIdForAction(act)== id)
return act;
}
return 0;
}
/*!
Use QAction and actions() instead.
*/
QMenuItem *QMenu::findPopup( QMenu *popup, int *index )
{
QList<QAction *> list = actions();
for (int i = 0; i < list.size(); ++i) {
QAction *act = list.at(i);
if (act->menu() == popup) {
QMenuItem *item = static_cast<QMenuItem *>(act);
if (index)
*index = act->d_func()->id;
return item;
}
}
return 0;
}
/*!
Use QAction::setData() instead.
*/
bool QMenu::setItemParameter(int id, int param)
{
if (QAction *act = findActionForId(id)) {
act->d_func()->param = param;
return true;
}
return false;
}
/*!
Use QAction::data() instead.
*/
int QMenu::itemParameter(int id) const
{
if (QAction *act = findActionForId(id))
return act->d_func()->param;
return id;
}
/*!
Use actions instead.
*/
void QMenu::setId(int index, int id)
{
if(QAction *act = actions().value(index))
act->d_func()->id = id;
}
/*!
Use style()->pixelMetric(QStyle::PM_MenuPanelWidth, this) instead.
*/
int QMenu::frameWidth() const
{
return style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);
}
int QMenu::findIdForAction(QAction *act) const
{
if (!act)
return -1;
return act->d_func()->id;
}
#endif // QT3_SUPPORT
/*!
\fn uint QMenu::count() const
Use actions().count() instead.
*/
/*!
\fn int QMenu::insertItem(const QString &text, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index)
Use insertAction() or one of the addAction() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QIcon& icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index)
Use insertAction() or one of the addAction() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index)
Use insertAction() or one of the addAction() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QString &text, int id, int index)
Use insertAction() or one of the addAction() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QIcon& icon, const QString &text, int id, int index)
Use insertAction() or one of the addAction() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QString &text, QMenu *popup, int id, int index)
Use insertMenu() or one of the addMenu() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id, int index)
Use insertMenu() or one of the addMenu() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QPixmap &pixmap, int id, int index)
Use insertAction() or one of the addAction() overloads instead.
*/
/*!
\fn int QMenu::insertItem(const QPixmap &pixmap, QMenu *popup, int id, int index)
Use insertMenu() or one of the addMenu() overloads instead.
*/
/*!
\fn void QMenu::removeItem(int id)
Use removeAction() instead.
*/
/*!
\fn void QMenu::removeItemAt(int index)
Use removeAction() instead.
*/
/*!
\fn QKeySequence QMenu::accel(int id) const
Use shortcut() on the relevant QAction instead.
*/
/*!
\fn void QMenu::setAccel(const QKeySequence& key, int id)
Use setShortcut() on the relevant QAction instead.
*/
/*!
\fn QIcon QMenu::iconSet(int id) const
Use icon() on the relevant QAction instead.
*/
/*!
\fn QString QMenu::text(int id) const
Use text() on the relevant QAction instead.
*/
/*!
\fn QPixmap QMenu::pixmap(int id) const
Use QPixmap(icon()) on the relevant QAction instead.
*/
/*!
\fn void QMenu::setWhatsThis(int id, const QString &w)
Use setWhatsThis() on the relevant QAction instead.
*/
/*!
\fn QString QMenu::whatsThis(int id) const
Use whatsThis() on the relevant QAction instead.
*/
/*!
\fn void QMenu::changeItem(int id, const QString &text)
Use setText() on the relevant QAction instead.
*/
/*!
\fn void QMenu::changeItem(int id, const QPixmap &pixmap)
Use setText() on the relevant QAction instead.
*/
/*!
\fn void QMenu::changeItem(int id, const QIcon &icon, const QString &text)
Use setIcon() and setText() on the relevant QAction instead.
*/
/*!
\fn bool QMenu::isItemActive(int id) const
Use activeAction() instead.
*/
/*!
\fn bool QMenu::isItemEnabled(int id) const
Use isEnabled() on the relevant QAction instead.
*/
/*!
\fn void QMenu::setItemEnabled(int id, bool enable)
Use setEnabled() on the relevant QAction instead.
*/
/*!
\fn bool QMenu::isItemChecked(int id) const
Use isChecked() on the relevant QAction instead.
*/
/*!
\fn void QMenu::setItemChecked(int id, bool check)
Use setChecked() on the relevant QAction instead.
*/
/*!
\fn bool QMenu::isItemVisible(int id) const
Use isVisible() on the relevant QAction instead.
*/
/*!
\fn void QMenu::setItemVisible(int id, bool visible)
Use setVisible() on the relevant QAction instead.
*/
/*!
\fn QRect QMenu::itemGeometry(int index)
Use actionGeometry() on the relevant QAction instead.
*/
/*!
\fn QFont QMenu::itemFont(int id) const
Use font() on the relevant QAction instead.
*/
/*!
\fn void QMenu::setItemFont(int id, const QFont &font)
Use setFont() on the relevant QAction instead.
*/
/*!
\fn int QMenu::indexOf(int id) const
Use actions().indexOf(action) on the relevant QAction instead.
*/
/*!
\fn int QMenu::idAt(int index) const
Use actions instead.
*/
/*!
\fn void QMenu::activateItemAt(int index)
Use activate() on the relevant QAction instead.
*/
/*!
\fn bool QMenu::connectItem(int id, const QObject *receiver, const char* member)
Use connect() on the relevant QAction instead.
*/
/*!
\fn bool QMenu::disconnectItem(int id,const QObject *receiver, const char* member)
Use disconnect() on the relevant QAction instead.
*/
/*!
\fn QMenuItem *QMenu::findItem(int id) const
Use actions instead.
*/
/*!
\fn void QMenu::popup(const QPoint & pos, int indexAtPoint)
Use popup() on the relevant QAction instead.
*/
/*!
\fn int QMenu::insertTearOffHandle(int a, int b)
Use setTearOffEnabled() instead.
*/
/*!
\fn int QMenu::itemAtPos(const QPoint &p, bool ignoreSeparator)
Use actions instead.
*/
/*!
\fn int QMenu::columns() const
Use columnCount() instead.
*/
/*!
\fn int QMenu::itemHeight(int index)
Use actionGeometry(actions().value(index)).height() instead.
*/
/*!
\fn int QMenu::itemHeight(QMenuItem *mi)
Use actionGeometry() instead.
*/
/*!
\fn void QMenu::activated(int itemId);
Use triggered() instead.
*/
/*!
\fn void QMenu::highlighted(int itemId);
Use hovered() instead.
*/
/*!
\fn void QMenu::setCheckable(bool checkable)
Not necessary anymore. The \a checkable parameter is ignored.
*/
/*!
\fn bool QMenu::isCheckable() const
Not necessary anymore. Always returns true.
*/
/*!
\fn void QMenu::setActiveItem(int id)
Use setActiveAction() instead.
*/
QT_END_NAMESPACE
// for private slots

View File

@ -48,10 +48,6 @@
#include <QtWidgets/qaction.h>
#include <QtWidgets/qplatformmenu_qpa.h>
#ifdef QT3_SUPPORT
#include <QtGui/qpixmap.h>
#endif
#ifdef Q_WS_WINCE
#include <windef.h> // for HMENU
#endif
@ -66,9 +62,6 @@ QT_MODULE(Gui)
class QMenuPrivate;
class QStyleOptionMenuItem;
#ifdef QT3_SUPPORT
class QMenuItem;
#endif
class Q_WIDGETS_EXPORT QMenu : public QWidget
{
@ -191,215 +184,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
Q_PRIVATE_SLOT(d_func(), void _q_overrideMenuActionDestroyed())
#ifdef QT3_SUPPORT
public:
//menudata
inline QT3_SUPPORT uint count() const { return actions().count(); }
inline QT3_SUPPORT int insertItem(const QString &text, const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
return insertAny(0, &text, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text,
const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
return insertAny(&icon, &text, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QString &text, int id=-1, int index=-1) {
return insertAny(0, &text, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, int id=-1, int index=-1) {
return insertAny(&icon, &text, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QString &text, QMenu *popup, int id=-1, int index=-1) {
return insertAny(0, &text, 0, 0, 0, popup, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id=-1, int index=-1) {
return insertAny(&icon, &text, 0, 0, 0, popup, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, int id=-1, int index=-1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, QMenu *popup, int id=-1, int index=-1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, 0, 0, 0, popup, id, index);
}
QT3_SUPPORT int insertItem(QMenuItem *item, int id=-1, int index=-1);
QT3_SUPPORT int insertSeparator(int index=-1);
inline QT3_SUPPORT void removeItem(int id) {
if(QAction *act = findActionForId(id))
removeAction(act); }
inline QT3_SUPPORT void removeItemAt(int index) {
if(QAction *act = actions().value(index))
removeAction(act); }
#ifndef QT_NO_SHORTCUT
inline QT3_SUPPORT QKeySequence accel(int id) const {
if(QAction *act = findActionForId(id))
return act->shortcut();
return QKeySequence(); }
inline QT3_SUPPORT void setAccel(const QKeySequence& key, int id) {
if(QAction *act = findActionForId(id))
act->setShortcut(key);
}
#endif
inline QT3_SUPPORT QIcon iconSet(int id) const {
if(QAction *act = findActionForId(id))
return act->icon();
return QIcon(); }
inline QT3_SUPPORT QString text(int id) const {
if(QAction *act = findActionForId(id))
return act->text();
return QString(); }
inline QT3_SUPPORT QPixmap pixmap(int id) const {
if(QAction *act = findActionForId(id))
return act->icon().pixmap(QSize(22, 22));
return QPixmap(); }
inline QT3_SUPPORT void setWhatsThis(int id, const QString &w) {
if(QAction *act = findActionForId(id))
act->setWhatsThis(w); }
inline QT3_SUPPORT QString whatsThis(int id) const {
if(QAction *act = findActionForId(id))
return act->whatsThis();
return QString(); }
inline QT3_SUPPORT void changeItem(int id, const QString &text) {
if(QAction *act = findActionForId(id))
act->setText(text); }
inline QT3_SUPPORT void changeItem(int id, const QPixmap &pixmap) {
if(QAction *act = findActionForId(id))
act->setIcon(QIcon(pixmap)); }
inline QT3_SUPPORT void changeItem(int id, const QIcon &icon, const QString &text) {
if(QAction *act = findActionForId(id)) {
act->setIcon(icon);
act->setText(text);
}
}
inline QT3_SUPPORT void setActiveItem(int id) {
setActiveAction(findActionForId(id));
}
inline QT3_SUPPORT bool isItemActive(int id) const {
return findActionForId(id) == activeAction();
}
inline QT3_SUPPORT bool isItemEnabled(int id) const {
if(QAction *act = findActionForId(id))
return act->isEnabled();
return false; }
inline QT3_SUPPORT void setItemEnabled(int id, bool enable) {
if(QAction *act = findActionForId(id))
act->setEnabled(enable);
}
inline QT3_SUPPORT bool isItemChecked(int id) const {
if(QAction *act = findActionForId(id))
return act->isChecked();
return false;
}
inline QT3_SUPPORT void setItemChecked(int id, bool check) {
if(QAction *act = findActionForId(id)) {
act->setCheckable(true);
act->setChecked(check);
}
}
inline QT3_SUPPORT bool isItemVisible(int id) const {
if(QAction *act = findActionForId(id))
return act->isVisible();
return false;
}
inline QT3_SUPPORT void setItemVisible(int id, bool visible) {
if(QAction *act = findActionForId(id))
act->setVisible(visible);
}
inline QT3_SUPPORT QRect itemGeometry(int index) {
if(QAction *act = actions().value(index))
return actionGeometry(act);
return QRect();
}
inline QT3_SUPPORT QFont itemFont(int id) const {
if(QAction *act = findActionForId(id))
return act->font();
return QFont();
}
inline QT3_SUPPORT void setItemFont(int id, const QFont &font) {
if(QAction *act = findActionForId(id))
act->setFont(font);
}
inline QT3_SUPPORT int indexOf(int id) const {
return actions().indexOf(findActionForId(id));
}
inline QT3_SUPPORT int idAt(int index) const {
return findIdForAction(actions().value(index));
}
QT3_SUPPORT void setId (int index, int id);
inline QT3_SUPPORT void activateItemAt(int index) {
if(QAction *ret = actions().value(index))
ret->activate(QAction::Trigger);
}
inline QT3_SUPPORT bool connectItem(int id, const QObject *receiver, const char* member) {
if(QAction *act = findActionForId(id)) {
QObject::connect(act, SIGNAL(activated(int)), receiver, member);
return true;
}
return false;
}
inline QT3_SUPPORT bool disconnectItem(int id,const QObject *receiver, const char* member) {
if(QAction *act = findActionForId(id)) {
QObject::disconnect(act, SIGNAL(triggered()), receiver, member);
return true;
}
return false;
}
inline QT3_SUPPORT QMenuItem *findItem(int id) const {
return reinterpret_cast<QMenuItem*>(findActionForId(id));
}
inline QT3_SUPPORT void setCheckable(bool){}
inline QT3_SUPPORT bool isCheckable() const {return true;}
QT3_SUPPORT QMenuItem *findPopup( QMenu *popup, int *index );
QT3_SUPPORT bool setItemParameter(int id, int param);
QT3_SUPPORT int itemParameter(int id) const;
//frame
QT3_SUPPORT int frameWidth() const;
//popupmenu
inline QT3_SUPPORT void popup(const QPoint & pos, int indexAtPoint) { popup(pos, actions().value(indexAtPoint)); }
inline QT3_SUPPORT int insertTearOffHandle(int = 0, int = 0) {
setTearOffEnabled(true);
return -1;
}
protected:
inline QT3_SUPPORT int itemAtPos(const QPoint &p, bool ignoreSeparator = true) {
QAction *ret = actionAt(p);
if(ignoreSeparator && ret && ret->isSeparator())
return -1;
return findIdForAction(ret);
}
inline QT3_SUPPORT int columns() const { return columnCount(); }
inline QT3_SUPPORT int itemHeight(int index) {
return actionGeometry(actions().value(index)).height();
}
inline QT3_SUPPORT int itemHeight(QMenuItem *mi) {
return actionGeometry(reinterpret_cast<QAction *>(mi)).height();
}
Q_SIGNALS:
QT_MOC_COMPAT void activated(int itemId);
QT_MOC_COMPAT void highlighted(int itemId);
private:
int insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
const QKeySequence *shorcut, const QMenu *popup, int id, int index);
QAction *findActionForId(int id) const;
int findIdForAction(QAction*) const;
#endif
protected:
QMenu(QMenuPrivate &dd, QWidget* parent = 0);

View File

@ -258,9 +258,6 @@ public:
QPlatformMenu *platformMenu;
QPointer<QAction> actionAboutToTrigger;
#ifdef QT3_SUPPORT
bool emitHighlighted;
#endif
#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
struct QWceMenuPrivate {

View File

@ -548,9 +548,6 @@ void QMenuBarPrivate::_q_actionHovered()
QAccessible::updateAccessibility(q, actionIndex, QAccessible::Selection);
}
#endif //QT_NO_ACCESSIBILITY
#ifdef QT3_SUPPORT
emit q->highlighted(q->findIdForAction(action));
#endif
}
}
@ -746,9 +743,6 @@ void QMenuBarPrivate::init()
#endif
q->setBackgroundRole(QPalette::Button);
oldWindow = oldParent = 0;
#ifdef QT3_SUPPORT
doAutoResize = false;
#endif
#ifdef QT_SOFTKEYS_ENABLED
menuBarAction = 0;
#endif
@ -791,18 +785,6 @@ QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0)
d->init();
}
#ifdef QT3_SUPPORT
/*!
Use one of the constructors that doesn't take the \a name
argument and then use setObjectName() instead.
*/
QMenuBar::QMenuBar(QWidget *parent, const char *name) : QWidget(*new QMenuBarPrivate, parent, 0)
{
Q_D(QMenuBar);
d->init();
setObjectName(QString::fromAscii(name));
}
#endif
/*!
Destroys the menu bar.
@ -1412,38 +1394,6 @@ void QMenuBarPrivate::handleReparent()
#endif // Q_WS_S60
}
#ifdef QT3_SUPPORT
/*!
Sets whether the menu bar should automatically resize itself
when its parent widget is resized.
This feature is provided to help porting to Qt 4. We recommend
against using it in new code.
\sa autoGeometry()
*/
void QMenuBar::setAutoGeometry(bool b)
{
Q_D(QMenuBar);
d->doAutoResize = b;
}
/*!
Returns true if the menu bar automatically resizes itself
when its parent widget is resized; otherwise returns false.
This feature is provided to help porting to Qt 4. We recommend
against using it in new code.
\sa setAutoGeometry()
*/
bool QMenuBar::autoGeometry() const
{
Q_D(const QMenuBar);
return d->doAutoResize;
}
#endif
/*!
\reimp
*/
@ -1504,15 +1454,6 @@ bool QMenuBar::event(QEvent *e)
} break;
#endif
case QEvent::Show:
#ifdef QT3_SUPPORT
if(QWidget *p = parentWidget()) {
// If itemsDirty == true, updateGeometries sends the MenubarUpdated event.
if (!d->itemsDirty) {
QMenubarUpdatedEvent menubarUpdated(this);
QApplication::sendEvent(p, &menubarUpdated);
}
}
#endif
d->_q_updateLayout();
break;
case QEvent::ShortcutOverride: {
@ -1525,14 +1466,6 @@ bool QMenuBar::event(QEvent *e)
}
break;
#ifdef QT3_SUPPORT
case QEvent::Hide: {
if(QWidget *p = parentWidget()) {
QMenubarUpdatedEvent menubarUpdated(this);
QApplication::sendEvent(p, &menubarUpdated);
}
} break;
#endif
#ifndef QT_NO_WHATSTHIS
case QEvent::QueryWhatsThis:
@ -1559,14 +1492,6 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event)
{
Q_D(QMenuBar);
if (object == parent() && object) {
#ifdef QT3_SUPPORT
if (d->doAutoResize && event->type() == QEvent::Resize) {
QResizeEvent *e = (QResizeEvent *)event;
int w = e->size().width();
setGeometry(0, y(), w, heightForWidth(w));
return false;
}
#endif
if (event->type() == QEvent::ParentChange) //GrandparentChange
d->handleReparent();
}
@ -2026,100 +1951,6 @@ QAction *QMenuBar::defaultAction() const
\sa triggered(), QAction::hovered()
*/
#ifdef QT3_SUPPORT
/*!
Use style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, this)
instead.
*/
int QMenuBar::frameWidth() const
{
return style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
}
int QMenuBar::insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
const QKeySequence *shortcut, const QMenu *popup, int id, int index)
{
QAction *act = popup ? popup->menuAction() : new QAction(this);
if(id != -1)
static_cast<QMenuItem*>(act)->setId(id);
if(icon)
act->setIcon(*icon);
if(text)
act->setText(*text);
if(shortcut)
act->setShortcut(*shortcut);
if(receiver && member)
QObject::connect(act, SIGNAL(triggered(bool)), receiver, member);
if(index == -1 || index >= actions().count())
addAction(act);
else
insertAction(actions().value(index), act);
return findIdForAction(act);
}
/*!
\since 4.2
Use addSeparator() or insertAction() instead.
\oldcode
menuBar->insertSeparator();
\newcode
menuBar->addSeparator();
\endcode
*/
int QMenuBar::insertSeparator(int index)
{
QAction *act = new QAction(this);
act->setSeparator(true);
if(index == -1 || index >= actions().count())
addAction(act);
else
insertAction(actions().value(index), act);
return findIdForAction(act);
}
/*!
Use QAction::setData() instead.
*/
bool QMenuBar::setItemParameter(int id, int param)
{
if(QAction *act = findActionForId(id)) {
act->d_func()->param = param;
return true;
}
return false;
}
/*!
Use QAction::data() instead.
*/
int QMenuBar::itemParameter(int id) const
{
if(QAction *act = findActionForId(id))
return act->d_func()->param;
return id;
}
QAction *QMenuBar::findActionForId(int id) const
{
QList<QAction *> list = actions();
for (int i = 0; i < list.size(); ++i) {
QAction *act = list.at(i);
if (findIdForAction(act) == id)
return act;
}
return 0;
}
int QMenuBar::findIdForAction(QAction *act) const
{
Q_ASSERT(act);
return act->d_func()->id;
}
#endif
/*!
\enum QMenuBar::Separator
@ -2139,255 +1970,6 @@ int QMenuBar::findIdForAction(QAction *act) const
\sa QMenu::addAction(), QWidget::addAction(), QWidget::actions()
*/
/*!
\fn uint QMenuBar::count() const
Use actions().count() instead.
*/
/*!
\fn int QMenuBar::insertItem(const QString &text, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index)
Use one of the insertAction() or addAction() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QIcon& icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index)
Use one of the insertAction() or addAction() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index)
Use one of the insertAction(), addAction(), insertMenu(), or
addMenu() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QString &text, int id, int index)
Use one of the insertAction() or addAction() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QIcon& icon, const QString &text, int id, int index)
Use one of the insertAction(), addAction(), insertMenu(), or
addMenu() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QString &text, QMenu *popup, int id, int index)
Use one of the insertMenu(), or addMenu() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id, int index)
Use one of the insertMenu(), or addMenu() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QPixmap &pixmap, int id, int index)
Use one of the insertAction(), addAction(), insertMenu(), or
addMenu() overloads instead.
*/
/*!
\fn int QMenuBar::insertItem(const QPixmap &pixmap, QMenu *popup, int id, int index)
Use one of the insertMenu(), or addMenu() overloads instead.
*/
/*!
\fn void QMenuBar::removeItem(int id)
Use removeAction() instead.
*/
/*!
\fn void QMenuBar::removeItemAt(int index)
Use removeAction() instead.
*/
/*!
\fn QKeySequence QMenuBar::accel(int id) const
Use shortcut() on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::setAccel(const QKeySequence& key, int id)
Use setShortcut() on the relevant QAction instead.
*/
/*!
\fn QIcon QMenuBar::iconSet(int id) const
Use icon() on the relevant QAction instead.
*/
/*!
\fn QString QMenuBar::text(int id) const
Use text() on the relevant QAction instead.
*/
/*!
\fn QPixmap QMenuBar::pixmap(int id) const
Use QPixmap(icon()) on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::setWhatsThis(int id, const QString &w)
Use setWhatsThis() on the relevant QAction instead.
*/
/*!
\fn QString QMenuBar::whatsThis(int id) const
Use whatsThis() on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::changeItem(int id, const QString &text)
Use setText() on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::changeItem(int id, const QPixmap &pixmap)
Use setText() on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::changeItem(int id, const QIcon &icon, const QString &text)
Use setIcon() and setText() on the relevant QAction instead.
*/
/*!
\fn bool QMenuBar::isItemActive(int id) const
Use activeAction() instead.
*/
/*!
\fn bool QMenuBar::isItemEnabled(int id) const
Use isEnabled() on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::setItemEnabled(int id, bool enable)
Use setEnabled() on the relevant QAction instead.
*/
/*!
\fn bool QMenuBar::isItemChecked(int id) const
Use isChecked() on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::setItemChecked(int id, bool check)
Use setChecked() on the relevant QAction instead.
*/
/*!
\fn bool QMenuBar::isItemVisible(int id) const
Use isVisible() on the relevant QAction instead.
*/
/*!
\fn void QMenuBar::setItemVisible(int id, bool visible)
Use setVisible() on the relevant QAction instead.
*/
/*!
\fn int QMenuBar::indexOf(int id) const
Use actions().indexOf(action) on the relevant QAction instead.
*/
/*!
\fn int QMenuBar::idAt(int index) const
Use actions instead.
*/
/*!
\fn void QMenuBar::activateItemAt(int index)
Use activate() on the relevant QAction instead.
*/
/*!
\fn bool QMenuBar::connectItem(int id, const QObject *receiver, const char* member)
Use connect() on the relevant QAction instead.
*/
/*!
\fn bool QMenuBar::disconnectItem(int id,const QObject *receiver, const char* member)
Use disconnect() on the relevant QAction instead.
*/
/*!
\fn QMenuItem *QMenuBar::findItem(int id) const
Use actions instead.
*/
/*!
\fn Separator QMenuBar::separator() const
This function is provided only to make old code compile.
*/
/*!
\fn void QMenuBar::setSeparator(Separator sep)
This function is provided only to make old code compile.
*/
/*!
\fn QRect QMenuBar::itemRect(int index)
Use actionGeometry() on the relevant QAction instead.
*/
/*!
\fn int QMenuBar::itemAtPos(const QPoint &p)
There is no equivalent way to achieve this in Qt 4.
*/
/*!
\fn void QMenuBar::activated(int itemId);
Use triggered() instead.
*/
/*!
\fn void QMenuBar::highlighted(int itemId);
Use hovered() instead.
*/
/*!
\fn void QMenuBar::setFrameRect(QRect)
\internal
@ -2461,22 +2043,6 @@ int QMenuBar::findIdForAction(QAction *act) const
\internal
*/
/*!
\fn void QMenuBar::setMargin(int margin)
Sets the width of the margin around the contents of the widget to \a margin.
Use QWidget::setContentsMargins() instead.
\sa margin(), QWidget::setContentsMargins()
*/
/*!
\fn int QMenuBar::margin() const
Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
*/
/*!
\fn void QMenuBar::setMidLineWidth(int)
\internal

View File

@ -145,195 +145,6 @@ protected:
bool event(QEvent *);
void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
#ifdef QT3_SUPPORT
public:
QT3_SUPPORT_CONSTRUCTOR QMenuBar(QWidget *parent, const char *name);
inline QT3_SUPPORT uint count() const { return actions().count(); }
inline QT3_SUPPORT int insertItem(const QString &text, const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
return insertAny(0, &text, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text,
const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
return insertAny(&icon, &text, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member,
const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, receiver, member, &shortcut, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QString &text, int id=-1, int index=-1) {
return insertAny(0, &text, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, int id=-1, int index=-1) {
return insertAny(&icon, &text, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QString &text, QMenu *popup, int id=-1, int index=-1) {
return insertAny(0, &text, 0, 0, 0, popup, id, index);
}
inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id=-1, int index=-1) {
return insertAny(&icon, &text, 0, 0, 0, popup, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, int id=-1, int index=-1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, 0, 0, 0, 0, id, index);
}
inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, QMenu *popup, int id=-1, int index=-1) {
QIcon icon(pixmap);
return insertAny(&icon, 0, 0, 0, 0, popup, id, index);
}
QT3_SUPPORT int insertSeparator(int index=-1);
inline QT3_SUPPORT void removeItem(int id) {
if(QAction *act = findActionForId(id))
removeAction(act); }
inline QT3_SUPPORT void removeItemAt(int index) {
if(QAction *act = actions().value(index))
removeAction(act); }
#ifndef QT_NO_SHORTCUT
inline QT3_SUPPORT QKeySequence accel(int id) const {
if(QAction *act = findActionForId(id))
return act->shortcut();
return QKeySequence(); }
inline QT3_SUPPORT void setAccel(const QKeySequence& key, int id) {
if(QAction *act = findActionForId(id))
act->setShortcut(key);
}
#endif
inline QT3_SUPPORT QIcon iconSet(int id) const {
if(QAction *act = findActionForId(id))
return act->icon();
return QIcon(); }
inline QT3_SUPPORT QString text(int id) const {
if(QAction *act = findActionForId(id))
return act->text();
return QString(); }
inline QT3_SUPPORT QPixmap pixmap(int id) const {
if(QAction *act = findActionForId(id))
return act->icon().pixmap(QSize(22,22));
return QPixmap(); }
inline QT3_SUPPORT void setWhatsThis(int id, const QString &w) {
if(QAction *act = findActionForId(id))
act->setWhatsThis(w); }
inline QT3_SUPPORT QString whatsThis(int id) const {
if(QAction *act = findActionForId(id))
return act->whatsThis();
return QString(); }
inline QT3_SUPPORT void changeItem(int id, const QString &text) {
if(QAction *act = findActionForId(id))
act->setText(text); }
inline QT3_SUPPORT void changeItem(int id, const QPixmap &pixmap) {
if(QAction *act = findActionForId(id))
act->setIcon(QIcon(pixmap)); }
inline QT3_SUPPORT void changeItem(int id, const QIcon &icon, const QString &text) {
if(QAction *act = findActionForId(id)) {
act->setIcon(icon);
act->setText(text);
}
}
inline QT3_SUPPORT bool isItemActive(int id) const { return findActionForId(id) == activeAction(); }
inline QT3_SUPPORT bool isItemEnabled(int id) const {
if(QAction *act = findActionForId(id))
return act->isEnabled();
return false; }
inline QT3_SUPPORT void setItemEnabled(int id, bool enable) {
if(QAction *act = findActionForId(id))
act->setEnabled(enable); }
inline QT3_SUPPORT bool isItemChecked(int id) const {
if(QAction *act = findActionForId(id))
return act->isChecked();
return false; }
inline QT3_SUPPORT void setItemChecked(int id, bool check) {
if(QAction *act = findActionForId(id))
act->setChecked(check); }
inline QT3_SUPPORT bool isItemVisible(int id) const {
if(QAction *act = findActionForId(id))
return act->isVisible();
return false; }
inline QT3_SUPPORT void setItemVisible(int id, bool visible) {
if(QAction *act = findActionForId(id))
act->setVisible(visible); }
inline QT3_SUPPORT int indexOf(int id) const { return actions().indexOf(findActionForId(id)); }
inline QT3_SUPPORT int idAt(int index) const {
return index >= 0 && index < actions().size()
? findIdForAction(actions().at(index))
: -1;
}
inline QT3_SUPPORT void activateItemAt(int index) {
if(QAction *ret = actions().value(index))
setActiveAction(ret);
}
inline QT3_SUPPORT bool connectItem(int id, const QObject *receiver, const char* member) {
if(QAction *act = findActionForId(id)) {
QObject::connect(act, SIGNAL(triggered()), receiver, member);
return true;
}
return false;
}
inline QT3_SUPPORT bool disconnectItem(int id,const QObject *receiver, const char* member) {
if(QAction *act = findActionForId(id)) {
QObject::disconnect(act, SIGNAL(triggered()), receiver, member);
return true;
}
return false;
}
inline QT3_SUPPORT QMenuItem *findItem(int id) const {
return (QMenuItem*)findActionForId(id);
}
QT3_SUPPORT bool setItemParameter(int id, int param);
QT3_SUPPORT int itemParameter(int id) const;
//frame
QT3_SUPPORT int frameWidth() const;
QT3_SUPPORT void setFrameRect(QRect) {}
QT3_SUPPORT QRect frameRect() const { return QRect(); }
enum DummyFrame { Box, Sunken, Plain, Raised, MShadow, NoFrame, Panel, StyledPanel,
HLine, VLine, GroupBoxPanel, WinPanel, ToolBarPanel, MenuBarPanel,
PopupPanel, LineEditPanel, TabWidgetPanel, MShape };
QT3_SUPPORT void setFrameShadow(DummyFrame) {}
QT3_SUPPORT DummyFrame frameShadow() const { return Plain; }
QT3_SUPPORT void setFrameShape(DummyFrame) {}
QT3_SUPPORT DummyFrame frameShape() const { return NoFrame; }
QT3_SUPPORT void setFrameStyle(int) {}
QT3_SUPPORT int frameStyle() const { return 0; }
QT3_SUPPORT void setLineWidth(int) {}
QT3_SUPPORT int lineWidth() const { return 0; }
QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
QT3_SUPPORT int margin() const
{ int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
QT3_SUPPORT void setMidLineWidth(int) {}
QT3_SUPPORT int midLineWidth() const { return 0; }
//menubar
enum Separator { Never=0, InWindowsStyle=1 };
inline QT3_SUPPORT Separator separator() const { return InWindowsStyle; }
inline QT3_SUPPORT void setSeparator(Separator) { }
QT3_SUPPORT void setAutoGeometry(bool);
QT3_SUPPORT bool autoGeometry() const;
Q_SIGNALS:
QT_MOC_COMPAT void activated(int itemId);
QT_MOC_COMPAT void highlighted(int itemId);
protected:
inline QT3_SUPPORT QRect itemRect(int index) {
if(QAction *act = actions().value(index))
return actionGeometry(act);
return QRect();
}
inline QT3_SUPPORT int itemAtPos(const QPoint &p) {
return findIdForAction(actionAt(p));
}
private:
QAction *findActionForId(int id) const;
int insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
const QKeySequence *shorcut, const QMenu *popup, int id, int index);
int findIdForAction(QAction*) const;
#endif
private:
Q_DECLARE_PRIVATE(QMenuBar)
Q_DISABLE_COPY(QMenuBar)

View File

@ -1,96 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmenudata.h"
#ifdef QT3_SUPPORT
#include <qaction.h>
#include <private/qaction_p.h>
QT_BEGIN_NAMESPACE
/*!
\class QMenuItem
\brief The QMenuItem class represents an item in a menu.
\compat
Use QAction instead.
*/
/*!
\compat
Constructs a new menu item.
*/
QMenuItem::QMenuItem() : QAction((QWidget*)0)
{
}
void QMenuItem::setId(int id)
{
d_func()->param = d_func()->id = id;
}
/*!
\compat
Returns the menu item's ID.
*/
int QMenuItem::id() const
{
return d_func()->id;
}
void QMenuItem::setSignalValue(int param)
{
d_func()->param = param;
}
/*!
\compat
Returns the signal value for the menu item.
*/
int QMenuItem::signalValue() const
{
return d_func()->param;
}
QT_END_NAMESPACE
#endif

View File

@ -1,80 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMENUDATA_H
#define QMENUDATA_H
#include <QtCore/qglobal.h>
#ifdef QT3_SUPPORT
#include <QtWidgets/qaction.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class Q_WIDGETS_EXPORT QMenuItem : public QAction
{
Q_OBJECT
public:
QMenuItem();
QT3_SUPPORT int id() const;
QT3_SUPPORT int signalValue() const;
private:
friend class QMenu;
friend class QMenuBar;
void setId(int);
void setSignalValue(int);
Q_DISABLE_COPY(QMenuItem)
};
QT_END_NAMESPACE
QT_END_HEADER
#endif
#endif // QMENUDATA_H

View File

@ -40,7 +40,6 @@ HEADERS += \
widgets/qmenu_p.h \
widgets/qmenubar.h \
widgets/qmenubar_p.h \
widgets/qmenudata.h \
widgets/qprogressbar.h \
widgets/qpushbutton.h \
widgets/qpushbutton_p.h \
@ -110,7 +109,6 @@ SOURCES += \
widgets/qmdisubwindow.cpp \
widgets/qmenu.cpp \
widgets/qmenubar.cpp \
widgets/qmenudata.cpp \
widgets/qprogressbar.cpp \
widgets/qpushbutton.cpp \
widgets/qradiobutton.cpp \