update the menu at childAdded/removed
This commit is contained in:
parent
edf08a8cdb
commit
e121edf7d8
@ -83,7 +83,7 @@ void QMenuProxy::setVisualParent(QObject *parent)
|
|||||||
action->setMenu(m_menu);
|
action->setMenu(m_menu);
|
||||||
m_menu->clear();
|
m_menu->clear();
|
||||||
foreach(QMenuItem* item, m_items) {
|
foreach(QMenuItem* item, m_items) {
|
||||||
m_menu->addAction (item);
|
m_menu->addAction(item);
|
||||||
}
|
}
|
||||||
m_menu->updateGeometry();
|
m_menu->updateGeometry();
|
||||||
}
|
}
|
||||||
@ -100,6 +100,7 @@ bool QMenuProxy::event(QEvent *event)
|
|||||||
QMenuItem *mi = qobject_cast<QMenuItem *>(ce->child());
|
QMenuItem *mi = qobject_cast<QMenuItem *>(ce->child());
|
||||||
//FIXME: linear complexity here
|
//FIXME: linear complexity here
|
||||||
if (mi && !m_items.contains(mi)) {
|
if (mi && !m_items.contains(mi)) {
|
||||||
|
m_menu->addAction(mi);
|
||||||
m_items << mi;
|
m_items << mi;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -111,6 +112,7 @@ bool QMenuProxy::event(QEvent *event)
|
|||||||
|
|
||||||
//FIXME: linear complexity here
|
//FIXME: linear complexity here
|
||||||
if (mi) {
|
if (mi) {
|
||||||
|
m_menu->removeAction(mi);
|
||||||
m_items.removeAll(mi);
|
m_items.removeAll(mi);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -133,11 +135,13 @@ void QMenuProxy::addMenuItem(const QString &text)
|
|||||||
{
|
{
|
||||||
QMenuItem *item = new QMenuItem(this);
|
QMenuItem *item = new QMenuItem(this);
|
||||||
item->setText(text);
|
item->setText(text);
|
||||||
|
m_menu->addAction(item);
|
||||||
m_items << item;
|
m_items << item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMenuProxy::addMenuItem(QMenuItem *item)
|
void QMenuProxy::addMenuItem(QMenuItem *item)
|
||||||
{
|
{
|
||||||
|
m_menu->addAction(item);
|
||||||
m_items << item;
|
m_items << item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user