Q3ActionGroup Class Reference

#include <q3action.h>

Inheritance diagram for Q3ActionGroup:

Inheritance graph
[legend]
Collaboration diagram for Q3ActionGroup:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Q3ActionGroup class groups actions together.

In some situations it is useful to group actions together. For example, if you have a left justify action, a right justify action and a center action, only one of these actions should be active at any one time, and one simple way of achieving this is to group the actions together in an action group.

An action group can also be added to a menu or a toolbar as a single unit, with all the actions within the action group appearing as separate menu options and toolbar buttons.

The actions in an action group emit their activated() (and for toggle actions, toggled()) signals as usual.

The setExclusive() function is used to ensure that only one action is active at any one time: it should be used with actions which have their toggleAction set to true.

Action group actions appear as individual menu options and toolbar buttons. For exclusive action groups use setUsesDropDown() to display the actions in a subwidget of any widget the action group is added to. For example, the actions would appear in a combobox in a toolbar or as a submenu in a menu.

Actions can be added to an action group using add(), but normally they are added by creating the action with the action group as parent. Actions can have separators dividing them using addSeparator(). Action groups are added to widgets with addTo().

Definition at line 139 of file q3action.h.

Signals

void selected (Q3Action *)
void activated (Q3Action *)

Public Member Functions

 Q3ActionGroup (QObject *parent, const char *name=0)
 Q3ActionGroup (QObject *parent, const char *name, bool exclusive)
 ~Q3ActionGroup ()
void setExclusive (bool)
bool isExclusive () const
void add (Q3Action *a)
void addSeparator ()
bool addTo (QWidget *)
bool removeFrom (QWidget *)
void setEnabled (bool)
void setToggleAction (bool toggle)
void setOn (bool on)
void setVisible (bool)
void setUsesDropDown (bool enable)
bool usesDropDown () const
void setIconSet (const QIcon &)
void setText (const QString &)
void setMenuText (const QString &)
void setToolTip (const QString &)
void setWhatsThis (const QString &)
void insert (Q3Action *a)

Protected Member Functions

void childEvent (QChildEvent *)
virtual void addedTo (QWidget *actionWidget, QWidget *container, Q3Action *a)
virtual void addedTo (int index, Q3PopupMenu *menu, Q3Action *a)
virtual void addedTo (QWidget *actionWidget, QWidget *container)
virtual void addedTo (int index, Q3PopupMenu *menu)

Private Slots

void childToggled (bool)
void childActivated ()
void childDestroyed ()
void internalComboBoxActivated (int)
void internalComboBoxHighlighted (int)
void internalToggle (Q3Action *)
void objectDestroyed ()

Private Attributes

Q3ActionGroupPrivated


Constructor & Destructor Documentation

Q3ActionGroup::Q3ActionGroup ( QObject parent,
const char *  name = 0 
)

Constructs an action group called name, with parent parent.

The action group is exclusive by default. Call setExclusive(false) to make the action group non-exclusive.

Definition at line 1432 of file q3action.cpp.

References QObject::connect(), d, Q3ActionGroupPrivate::dropdown, Q3ActionGroupPrivate::exclusive, internalToggle(), selected(), Q3ActionGroupPrivate::selected, Q3ActionGroupPrivate::separatorAction, SIGNAL, and SLOT.

01433     : Q3Action(parent, name)
01434 {
01435     d = new Q3ActionGroupPrivate;
01436     d->exclusive = true;
01437     d->dropdown = false;
01438     d->selected = 0;
01439     d->separatorAction = 0;
01440 
01441     connect(this, SIGNAL(selected(Q3Action*)), SLOT(internalToggle(Q3Action*)));
01442 }

Here is the call graph for this function:

Q3ActionGroup::Q3ActionGroup ( QObject parent,
const char *  name,
bool  exclusive 
)

Constructs an action group called name, with parent parent.

If exclusive is true only one toggle action in the group will ever be active.

See also:
exclusive

Definition at line 1452 of file q3action.cpp.

References QObject::connect(), d, Q3ActionGroupPrivate::dropdown, Q3ActionGroupPrivate::exclusive, internalToggle(), selected(), Q3ActionGroupPrivate::selected, Q3ActionGroupPrivate::separatorAction, SIGNAL, and SLOT.

01453     : Q3Action(parent, name)
01454 {
01455     d = new Q3ActionGroupPrivate;
01456     d->exclusive = exclusive;
01457     d->dropdown = false;
01458     d->selected = 0;
01459     d->separatorAction = 0;
01460 
01461     connect(this, SIGNAL(selected(Q3Action*)), SLOT(internalToggle(Q3Action*)));
01462 }

Here is the call graph for this function:

Q3ActionGroup::~Q3ActionGroup (  ) 

Destroys the object and frees allocated resources.

Definition at line 1468 of file q3action.cpp.

References Q3ActionPrivate::Action4Item::action, Q3ActionGroupPrivate::action4items, QList< T >::begin(), Q3ActionGroupPrivate::comboboxes, d, QObject::destroyed(), QList< T >::end(), QList< T >::isEmpty(), Q3ActionGroupPrivate::menubuttons, Q3ActionGroupPrivate::menuitems, objectDestroyed(), Q3ActionGroupPrivate::popupmenus, Q3ActionGroupPrivate::separatorAction, SIGNAL, SLOT, and QList< T >::takeFirst().

01469 {
01470     QList<Q3ActionGroupPrivate::MenuItem*>::Iterator mit(d->menuitems.begin());
01471     while (mit != d->menuitems.end()) {
01472         Q3ActionGroupPrivate::MenuItem *mi = *mit;
01473         ++mit;
01474         if (mi->popup)
01475             mi->popup->disconnect(SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
01476     }
01477 
01478     QList<QComboBox*>::Iterator cbit(d->comboboxes.begin());
01479     while (cbit != d->comboboxes.end()) {
01480         QComboBox *cb = *cbit;
01481         ++cbit;
01482         cb->disconnect(SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
01483     }
01484     QList<QToolButton*>::Iterator mbit(d->menubuttons.begin());
01485     while (mbit != d->menubuttons.end()) {
01486         QToolButton *mb = *mbit;
01487         ++mbit;
01488         mb->disconnect(SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
01489     }
01490     QList<Q3PopupMenu*>::Iterator pmit(d->popupmenus.begin());
01491     while (pmit != d->popupmenus.end()) {
01492         Q3PopupMenu *pm = *pmit;
01493         ++pmit;
01494         pm->disconnect(SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
01495     }
01496 
01497     QList<Q3ActionGroupPrivate::Action4Item*>::Iterator itmi4(d->action4items.begin());
01498     Q3ActionGroupPrivate::Action4Item* mi4;
01499     while (itmi4 != d->action4items.end()) {
01500         mi4 = *itmi4;
01501         ++itmi4;
01502         mi4->widget->removeAction(mi4->action);
01503     }
01504     delete Q3ActionPrivate::Action4Item::action;
01505     Q3ActionPrivate::Action4Item::action = 0;
01506 
01507     delete d->separatorAction;
01508     while (!d->menubuttons.isEmpty())
01509         delete d->menubuttons.takeFirst();
01510     while (!d->comboboxes.isEmpty())
01511         delete d->comboboxes.takeFirst();
01512     while (!d->menuitems.isEmpty())
01513         delete d->menuitems.takeFirst();
01514     while (!d->popupmenus.isEmpty())
01515         delete d->popupmenus.takeFirst();
01516     delete d;
01517 }

Here is the call graph for this function:


Member Function Documentation

void Q3ActionGroup::setExclusive ( bool   ) 

Definition at line 1530 of file q3action.cpp.

References d, and Q3ActionGroupPrivate::exclusive.

01531 {
01532     d->exclusive = enable;
01533 }

bool Q3ActionGroup::isExclusive (  )  const

Definition at line 1535 of file q3action.cpp.

References d, and Q3ActionGroupPrivate::exclusive.

Referenced by childToggled().

01536 {
01537     return d->exclusive;
01538 }

void Q3ActionGroup::add ( Q3Action action  ) 

Adds action action to this group.

Normally an action is added to a group by creating it with the group as parent, so this function is not usually used.

See also:
addTo()

Definition at line 1576 of file q3action.cpp.

References Q3ActionGroupPrivate::action4items, Q3ActionGroupPrivate::actions, Q3Action::activated(), QList< T >::append(), QList< T >::begin(), childActivated(), childDestroyed(), childToggled(), Q3ActionGroupPrivate::comboboxes, QObject::connect(), QList< T >::contains(), d, QObject::destroyed(), QList< T >::end(), Q3Action::isEnabled(), Q3Action::isVisible(), Q3ActionGroupPrivate::menubuttons, Q3ActionGroupPrivate::menuitems, SIGNAL, SLOT, Q3Action::toggled(), Q3Action::toolTip(), and Q3Action::whatsThis().

01577 {
01578     if (d->actions.contains(action))
01579         return;
01580 
01581     d->actions.append(action);
01582 
01583     if (action->whatsThis().isNull())
01584         action->setWhatsThis(whatsThis());
01585     if (action->toolTip().isNull())
01586         action->setToolTip(toolTip());
01587     if (!action->d->forceDisabled)
01588   action->d->enabled = isEnabled();
01589     if (!action->d->forceInvisible)
01590   action->d->visible = isVisible();
01591 
01592     connect(action, SIGNAL(destroyed()), this, SLOT(childDestroyed()));
01593     connect(action, SIGNAL(activated()), this, SIGNAL(activated()));
01594     connect(action, SIGNAL(toggled(bool)), this, SLOT(childToggled(bool)));
01595     connect(action, SIGNAL(activated()), this, SLOT(childActivated()));
01596 
01597     for (QList<QComboBox*>::Iterator cb(d->comboboxes.begin()); cb != d->comboboxes.end(); ++cb)
01598         action->addTo(*cb);
01599     for (QList<QToolButton*>::Iterator mb(d->menubuttons.begin()); mb != d->menubuttons.end(); ++mb) {
01600         QMenu* menu = (*mb)->popup();
01601         if (!menu)
01602             continue;
01603         action->addTo(menu);
01604     }
01605     for (QList<Q3ActionGroupPrivate::Action4Item*>::Iterator ac(d->action4items.begin());
01606          ac != d->action4items.end(); ++ac)
01607         action->addTo((*ac)->action->menu());
01608     for (QList<Q3ActionGroupPrivate::MenuItem*>::Iterator mi(d->menuitems.begin());
01609          mi != d->menuitems.end(); ++mi) {
01610         Q3PopupMenu* popup = (*mi)->popup;
01611         if (!popup)
01612             continue;
01613         action->addTo(popup);
01614     }
01615 }

Here is the call graph for this function:

void Q3ActionGroup::addSeparator (  ) 

Adds a separator to the group.

Definition at line 1620 of file q3action.cpp.

References Q3ActionGroupPrivate::actions, QList< T >::append(), d, Q3Action::Q3Action(), and Q3ActionGroupPrivate::separatorAction.

01621 {
01622     if (!d->separatorAction)
01623         d->separatorAction = new Q3Action(0, "qt_separator_action");
01624     d->actions.append(d->separatorAction);
01625 }

Here is the call graph for this function:

bool Q3ActionGroup::addTo ( QWidget w  )  [virtual]

Adds this action group to the widget w.

If isExclusive() is false or usesDropDown() is false, the actions within the group are added to the widget individually. For example, if the widget is a menu, the actions will appear as individual menu options, and if the widget is a toolbar, the actions will appear as toolbar buttons.

If both isExclusive() and usesDropDown() are true, the actions are presented either in a combobox (if w is a toolbar) or in a submenu (if w is a menu).

All actions should be added to the action group before the action group is added to the widget. If actions are added to the action group after the action group has been added to the widget these later actions will not appear.

See also:
setExclusive() setUsesDropDown() removeFrom()

Reimplemented from Q3Action.

Definition at line 1647 of file q3action.cpp.

References Q3ActionGroupPrivate::Action4Item::action, Q3ActionGroupPrivate::action4items, Q3ActionGroupPrivate::actions, Q3Action::activated(), QWidget::addAction(), addedTo(), QList< T >::append(), QList< T >::begin(), Q3ActionGroupPrivate::comboboxes, QObject::connect(), d, QObject::destroyed(), Q3ActionGroupPrivate::dropdown, QList< T >::end(), Q3ActionGroupPrivate::exclusive, Q3Action::iconSet(), id, internalComboBoxActivated(), internalComboBoxHighlighted(), isEmpty(), isNull(), QIcon::isNull(), QAction::menu(), QMenu::menuAction(), QToolButton::MenuButtonPopup, Q3ActionGroupPrivate::menubuttons, Q3ActionGroupPrivate::menuitems, Q3Action::menuText(), objectDestroyed(), Q3ActionGroupPrivate::popupmenus, QAction::setIcon(), QAction::setText(), SIGNAL, size, QString::size(), SLOT, Q3Action::text(), Q3Action::toggled(), Q3Action::toolButtonToggled(), Q3Action::toolTip(), Q3ActionGroupPrivate::update(), w, Q3Action::whatsThis(), and Q3ActionGroupPrivate::Action4Item::widget.

01648 {
01649 #ifndef QT_NO_TOOLBAR
01650     if (qobject_cast<Q3ToolBar*>(w)) {
01651         if (d->dropdown) {
01652             if (!d->exclusive) {
01653                 QList<Q3Action*>::Iterator it(d->actions.begin());
01654                 if (!(*it))
01655                     return true;
01656 
01657                 Q3Action *defAction = *it;
01658 
01659                 QToolButton* btn = new QToolButton((Q3ToolBar*) w, "qt_actiongroup_btn");
01660                 addedTo(btn, w);
01661                 connect(btn, SIGNAL(destroyed()), SLOT(objectDestroyed()));
01662                 d->menubuttons.append(btn);
01663 
01664                 if (!iconSet().isNull())
01665                     btn->setIconSet(iconSet());
01666                 else if (!defAction->iconSet().isNull())
01667                     btn->setIconSet(defAction->iconSet());
01668                 if (text().size())
01669                     btn->setTextLabel(text());
01670                 else if (defAction->text().size())
01671                     btn->setTextLabel(defAction->text());
01672 #ifndef QT_NO_TOOLTIP
01673                 if (toolTip().size())
01674                     QToolTip::add(btn, toolTip());
01675                 else if (defAction->toolTip().size())
01676                     QToolTip::add(btn, defAction->toolTip());
01677 #endif
01678 #ifndef QT_NO_WHATSTHIS
01679                 if (whatsThis().size())
01680                     QWhatsThis::add(btn, whatsThis());
01681                 else if (defAction->whatsThis().size())
01682                     QWhatsThis::add(btn, defAction->whatsThis());
01683 #endif
01684 
01685                 connect(btn, SIGNAL(clicked()), defAction, SIGNAL(activated()));
01686                 connect(btn, SIGNAL(toggled(bool)), defAction, SLOT(toolButtonToggled(bool)));
01687                 connect(btn, SIGNAL(destroyed()), defAction, SLOT(objectDestroyed()));
01688 
01689                 Q3PopupMenu *menu = new Q3PopupMenu(btn, "qt_actiongroup_menu");
01690                 btn->setPopupDelay(0);
01691                 btn->setPopup(menu);
01692                 btn->setPopupMode(QToolButton::MenuButtonPopup);
01693 
01694                 while (it != d->actions.end()) {
01695                     (*it)->addTo(menu);
01696                     ++it;
01697                 }
01698                 d->update(this);
01699                 return true;
01700             } else {
01701                 QComboBox *box = new QComboBox(false, w, "qt_actiongroup_combo");
01702                 addedTo(box, w);
01703                 connect(box, SIGNAL(destroyed()), SLOT(objectDestroyed()));
01704                 d->comboboxes.append(box);
01705 #ifndef QT_NO_TOOLTIP
01706                 if (toolTip().size())
01707                     QToolTip::add(box, toolTip());
01708 #endif
01709 #ifndef QT_NO_WHATSTHIS
01710                 if (whatsThis().size())
01711                     QWhatsThis::add(box, whatsThis());
01712 #endif
01713                 int onIndex = 0;
01714                 bool foundOn = false;
01715                 for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
01716                     Q3Action *action = *it;
01717                     if (!foundOn)
01718                         foundOn = action->isOn();
01719                     if (action->objectName() != QLatin1String("qt_separator_action") && !foundOn)
01720                         onIndex++;
01721                     action->addTo(box);
01722                 }
01723                 if (foundOn)
01724                     box->setCurrentItem(onIndex);
01725                 connect(box, SIGNAL(activated(int)), this, SLOT(internalComboBoxActivated(int)));
01726                 connect(box, SIGNAL(highlighted(int)), this, SLOT(internalComboBoxHighlighted(int)));
01727                 d->update(this);
01728                 return true;
01729             }
01730         }
01731     } else
01732 #endif
01733     if (::qobject_cast<Q3PopupMenu*>(w)) {
01734         Q3PopupMenu *popup;
01735         if (d->dropdown) {
01736             Q3PopupMenu *menu = (Q3PopupMenu*)w;
01737             popup = new Q3PopupMenu(w, "qt_actiongroup_menu");
01738             d->popupmenus.append(popup);
01739             connect(popup, SIGNAL(destroyed()), SLOT(objectDestroyed()));
01740 
01741             int id;
01742             if (!iconSet().isNull()) {
01743                 if (menuText().isEmpty())
01744                     id = menu->insertItem(iconSet(), text(), popup);
01745                 else
01746                     id = menu->insertItem(iconSet(), menuText(), popup);
01747             } else {
01748                 if (menuText().isEmpty())
01749                     id = menu->insertItem(text(), popup);
01750                 else
01751                     id = menu->insertItem(menuText(), popup);
01752             }
01753 
01754             addedTo(menu->indexOf(id), menu);
01755 
01756             Q3ActionGroupPrivate::MenuItem *item = new Q3ActionGroupPrivate::MenuItem;
01757             item->id = id;
01758             item->popup = popup;
01759             d->menuitems.append(item);
01760         } else {
01761             popup = (Q3PopupMenu*)w;
01762         }
01763         for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
01764             // #### do an addedTo(index, popup, action), need to find out index
01765             (*it)->addTo(popup);
01766         }
01767         return true;
01768     }
01769     if (::qobject_cast<QMenu*>(w)) {
01770         QMenu *menu = (QMenu*)w;
01771         if (d->dropdown) {
01772             Q3ActionGroupPrivate::Action4Item *ai = new Q3ActionGroupPrivate::Action4Item;
01773             if(!ai->action)  { //static
01774                 ai->action = menu->menuAction();
01775                 if (!iconSet().isNull())
01776                     ai->action->setIcon(iconSet());
01777                 if (menuText().isEmpty())
01778                     ai->action->setText(text());
01779                 else
01780                     ai->action->setText(menuText());
01781             }
01782             addedTo(w, w);
01783             ai->widget = w;
01784             ai->widget->addAction(Q3ActionGroupPrivate::Action4Item::action);
01785             d->action4items.append(ai);
01786             menu = ai->action->menu();
01787         }
01788         for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it)
01789             (*it)->addTo(menu);
01790         return true;
01791     }
01792     for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
01793         // #### do an addedTo(index, popup, action), need to find out index
01794         (*it)->addTo(w);
01795     }
01796     return true;
01797 }

Here is the call graph for this function:

bool Q3ActionGroup::removeFrom ( QWidget w  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1801 of file q3action.cpp.

References Q3ActionGroupPrivate::action4items, Q3ActionGroupPrivate::actions, QList< T >::begin(), Q3ActionGroupPrivate::comboboxes, d, Q3ActionGroupPrivate::dropdown, QList< T >::end(), Q3ActionGroupPrivate::menubuttons, Q3ActionGroupPrivate::menuitems, and w.

Referenced by Q3ActionPrivate::~Q3ActionPrivate().

01802 {
01803     for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it)
01804         (*it)->removeFrom(w);
01805 
01806 #ifndef QT_NO_TOOLBAR
01807     if (::qobject_cast<Q3ToolBar*>(w)) {
01808         QList<QComboBox*>::Iterator cb(d->comboboxes.begin());
01809         while (cb != d->comboboxes.end()) {
01810             QComboBox *box = *cb;
01811             ++cb;
01812             if (box->parentWidget() == w)
01813                 delete box;
01814         }
01815         QList<QToolButton*>::Iterator mb(d->menubuttons.begin());
01816         while (mb != d->menubuttons.end()) {
01817             QToolButton *btn = *mb;
01818             ++mb;
01819             if (btn->parentWidget() == w)
01820                 delete btn;
01821         }
01822     } else
01823 #endif
01824     if (::qobject_cast<Q3PopupMenu*>(w)) {
01825         QList<Q3ActionGroupPrivate::MenuItem*>::Iterator pu(d->menuitems.begin());
01826         while (pu != d->menuitems.end()) {
01827             Q3ActionGroupPrivate::MenuItem *mi = *pu;
01828             ++pu;
01829             if (d->dropdown && mi->popup)
01830                 ((Q3PopupMenu*)w)->removeItem(mi->id);
01831             delete mi->popup;
01832         }
01833     }
01834     if (::qobject_cast<QMenu*>(w)) {
01835         QList<Q3ActionGroupPrivate::Action4Item*>::Iterator it(d->action4items.begin());
01836         Q3ActionGroupPrivate::Action4Item *a4i;
01837         while (it != d->action4items.end()) {
01838             a4i = *it;
01839             ++it;
01840             if (a4i->widget == w) {
01841                 a4i->widget->removeAction(a4i->action);
01842                 d->action4items.removeAll(a4i);
01843                 delete a4i;
01844             }
01845         }
01846     }
01847     return true;
01848 }

Here is the call graph for this function:

void Q3ActionGroup::setEnabled ( bool  enable  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1899 of file q3action.cpp.

References d, Q3Action::isEnabled(), Q3Action::setEnabled(), and Q3ActionGroupPrivate::update().

01900 {
01901     if (enable == isEnabled())
01902         return;
01903     Q3Action::setEnabled(enable);
01904     d->update(this);
01905 }

Here is the call graph for this function:

void Q3ActionGroup::setToggleAction ( bool  toggle  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1909 of file q3action.cpp.

References Q3ActionGroupPrivate::actions, QList< T >::begin(), d, QList< T >::end(), Q3Action::setToggleAction(), and Q3ActionGroupPrivate::update().

01910 {
01911     for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it)
01912         (*it)->setToggleAction(toggle);
01913     Q3Action::setToggleAction(true);
01914     d->update(this);
01915 }

Here is the call graph for this function:

void Q3ActionGroup::setOn ( bool  on  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1919 of file q3action.cpp.

References Q3ActionGroupPrivate::actions, QList< T >::begin(), d, QList< T >::end(), Q3Action::setOn(), and Q3ActionGroupPrivate::update().

01920 {
01921     for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
01922         Q3Action *act = *it;
01923         if (act->isToggleAction())
01924             act->setOn(on);
01925     }
01926     Q3Action::setOn(on);
01927     d->update(this);
01928 }

Here is the call graph for this function:

void Q3ActionGroup::setVisible ( bool  visible  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1932 of file q3action.cpp.

References d, Q3Action::setVisible(), and Q3ActionGroupPrivate::update().

01933 {
01934     Q3Action::setVisible(visible);
01935     d->update(this);
01936 }

Here is the call graph for this function:

void Q3ActionGroup::setUsesDropDown ( bool  enable  ) 

Definition at line 1558 of file q3action.cpp.

References d, and Q3ActionGroupPrivate::dropdown.

01559 {
01560     d->dropdown = enable;
01561 }

bool Q3ActionGroup::usesDropDown (  )  const

Definition at line 1563 of file q3action.cpp.

References d, and Q3ActionGroupPrivate::dropdown.

01564 {
01565     return d->dropdown;
01566 }

void Q3ActionGroup::setIconSet ( const QIcon icon  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1940 of file q3action.cpp.

References d, Q3Action::setIconSet(), and Q3ActionGroupPrivate::update().

01941 {
01942     Q3Action::setIconSet(icon);
01943     d->update(this);
01944 }

Here is the call graph for this function:

void Q3ActionGroup::setText ( const QString txt  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1948 of file q3action.cpp.

References d, Q3Action::setText(), Q3Action::text(), and Q3ActionGroupPrivate::update().

01949 {
01950     if (txt == text())
01951         return;
01952 
01953     Q3Action::setText(txt);
01954     d->update(this);
01955 }

Here is the call graph for this function:

void Q3ActionGroup::setMenuText ( const QString text  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1959 of file q3action.cpp.

References d, Q3Action::menuText(), Q3Action::setMenuText(), Q3Action::text(), and Q3ActionGroupPrivate::update().

01960 {
01961     if (text == menuText())
01962         return;
01963 
01964     Q3Action::setMenuText(text);
01965     d->update(this);
01966 }

Here is the call graph for this function:

void Q3ActionGroup::setToolTip ( const QString text  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1970 of file q3action.cpp.

References Q3ActionGroupPrivate::actions, QList< T >::begin(), d, QList< T >::end(), Q3Action::setToolTip(), Q3Action::text(), Q3Action::toolTip(), and Q3ActionGroupPrivate::update().

01971 {
01972     if (text == toolTip())
01973         return;
01974     for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
01975         if ((*it)->toolTip().isNull())
01976             (*it)->setToolTip(text);
01977     }
01978     Q3Action::setToolTip(text);
01979     d->update(this);
01980 }

Here is the call graph for this function:

void Q3ActionGroup::setWhatsThis ( const QString text  )  [virtual]

Reimplemented from Q3Action.

Definition at line 1984 of file q3action.cpp.

References Q3ActionGroupPrivate::actions, QList< T >::begin(), d, QList< T >::end(), Q3Action::setWhatsThis(), Q3Action::text(), Q3ActionGroupPrivate::update(), and Q3Action::whatsThis().

01985 {
01986     if (text == whatsThis())
01987         return;
01988     for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
01989         if ((*it)->whatsThis().isNull())
01990             (*it)->setWhatsThis(text);
01991     }
01992     Q3Action::setWhatsThis(text);
01993     d->update(this);
01994 }

Here is the call graph for this function:

void Q3ActionGroup::childEvent ( QChildEvent e  )  [protected, virtual]

Reimplemented from QObject.

Definition at line 1998 of file q3action.cpp.

References Q3ActionGroupPrivate::Action4Item::action, QList< T >::begin(), QChildEvent::child(), Q3ActionGroupPrivate::comboboxes, d, QList< T >::end(), i, Q3ActionGroupPrivate::menubuttons, Q3ActionGroupPrivate::menuitems, QChildEvent::removed(), Q3Action::removeFrom(), and Q3Action::text().

01999 {
02000     if (!e->removed())
02001         return;
02002 
02003     Q3Action *action = qobject_cast<Q3Action*>(e->child());
02004     if (!action)
02005         return;
02006 
02007     for (QList<QComboBox*>::Iterator cb(d->comboboxes.begin());
02008          cb != d->comboboxes.end(); ++cb) {
02009         for (int i = 0; i < (*cb)->count(); i++) {
02010             if ((*cb)->text(i) == action->text()) {
02011                 (*cb)->removeItem(i);
02012                 break;
02013             }
02014         }
02015     }
02016     for (QList<QToolButton*>::Iterator mb(d->menubuttons.begin());
02017          mb != d->menubuttons.end(); ++mb) {
02018         QMenu* popup = (*mb)->popup();
02019         if (!popup)
02020             continue;
02021         action->removeFrom(popup);
02022     }
02023     for (QList<Q3ActionGroupPrivate::MenuItem*>::Iterator mi(d->menuitems.begin());
02024          mi != d->menuitems.end(); ++mi) {
02025         Q3PopupMenu* popup = (*mi)->popup;
02026         if (!popup)
02027             continue;
02028         action->removeFrom(popup);
02029     }
02030     if(QAction *act = Q3ActionGroupPrivate::Action4Item::action)
02031         action->removeFrom(act->menu());
02032 }

Here is the call graph for this function:

void Q3ActionGroup::addedTo ( QWidget actionWidget,
QWidget container,
Q3Action a 
) [protected, virtual]

This function is called from the addTo() function when it has created a widget (actionWidget) for the child action a in the container.

Definition at line 2156 of file q3action.cpp.

References a.

Referenced by addTo().

02157 {
02158     Q_UNUSED(actionWidget);
02159     Q_UNUSED(container);
02160     Q_UNUSED(a);
02161 }

void Q3ActionGroup::addedTo ( int  index,
Q3PopupMenu menu,
Q3Action a 
) [protected, virtual]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function is called from the addTo() function when it has created a menu item for the child action at the index position index in the popup menu menu.

Definition at line 2171 of file q3action.cpp.

References a.

02172 {
02173     Q_UNUSED(index);
02174     Q_UNUSED(menu);
02175     Q_UNUSED(a);
02176 }

void Q3ActionGroup::addedTo ( QWidget actionWidget,
QWidget container 
) [protected, virtual]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function is called from the addTo() function when it has created a widget (actionWidget) in the container.

Reimplemented from Q3Action.

Definition at line 2186 of file q3action.cpp.

02187 {
02188     Q_UNUSED(actionWidget);
02189     Q_UNUSED(container);
02190 }

void Q3ActionGroup::addedTo ( int  index,
Q3PopupMenu menu 
) [protected, virtual]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function is called from the addTo() function when it has created a menu item at the index position index in the popup menu menu.

Reimplemented from Q3Action.

Definition at line 2201 of file q3action.cpp.

02202 {
02203     Q_UNUSED(index);
02204     Q_UNUSED(menu);
02205 }

void Q3ActionGroup::selected ( Q3Action action  )  [signal]

This signal is emitted from exclusive groups when toggle actions change state.

The argument is the action whose state changed to "on".

See also:
setExclusive(), isOn() Q3Action::toggled()

Referenced by childToggled(), internalComboBoxActivated(), and Q3ActionGroup().

void Q3ActionGroup::activated ( Q3Action action  )  [signal]

This signal is emitted from groups when one of its actions gets activated.

The argument is the action which was activated.

See also:
setExclusive(), isOn() Q3Action::toggled()

void Q3ActionGroup::childToggled ( bool   )  [private, slot]

Definition at line 1852 of file q3action.cpp.

References Q3ActionGroupPrivate::actions, QList< T >::begin(), d, emit, QList< T >::end(), isExclusive(), s, selected(), Q3ActionGroupPrivate::selected, and QObject::sender().

Referenced by add().

01853 {
01854     if (!isExclusive())
01855         return;
01856     Q3Action* s = qobject_cast<Q3Action*>(sender());
01857     if (!s)
01858         return;
01859     if (b) {
01860         if (s != d->selected) {
01861             d->selected = s;
01862             for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
01863                 if ((*it)->isToggleAction() && (*it) != s)
01864                     (*it)->setOn(false);
01865             }
01866             emit selected(s);
01867         }
01868     } else {
01869         if (s == d->selected) {
01870             // at least one has to be selected
01871             s->setOn(true);
01872         }
01873     }
01874 }

void Q3ActionGroup::childActivated (  )  [private, slot]

Definition at line 1878 of file q3action.cpp.

References Q3Action::activated(), emit, s, and QObject::sender().

Referenced by add().

01879 {
01880     Q3Action* s = qobject_cast<Q3Action*>(sender());
01881     if (s) {
01882         emit activated(s);
01883         emit Q3Action::activated();
01884     }
01885 }

void Q3ActionGroup::childDestroyed (  )  [private, slot]

Definition at line 1890 of file q3action.cpp.

References Q3ActionGroupPrivate::actions, d, QList< T >::removeAll(), Q3ActionGroupPrivate::selected, and QObject::sender().

Referenced by add().

01891 {
01892     d->actions.removeAll((Q3Action *)sender());
01893     if (d->selected == sender())
01894         d->selected = 0;
01895 }

void Q3ActionGroup::internalComboBoxActivated ( int   )  [private, slot]

Definition at line 2059 of file q3action.cpp.

References a, Q3ActionGroupPrivate::actions, Q3Action::activated(), QList< T >::at(), QList< T >::begin(), QList< T >::count(), d, emit, QList< T >::end(), i, int, selected(), and Q3ActionGroupPrivate::selected.

Referenced by addTo().

02060 {
02061     if (index == -1)
02062         return;
02063 
02064     Q3Action *a = 0;
02065     for (int i = 0; i <= index && i < (int)d->actions.count(); ++i) {
02066         a = d->actions.at(i);
02067         if (a && a->objectName() == QLatin1String("qt_separator_action"))
02068             index++;
02069     }
02070     a = d->actions.at(index);
02071     if (a) {
02072         if (a != d->selected) {
02073             d->selected = a;
02074             for (QList<Q3Action*>::Iterator it(d->actions.begin()); it != d->actions.end(); ++it) {
02075                 if ((*it)->isToggleAction() && (*it) != a)
02076                     (*it)->setOn(false);
02077             }
02078             if (a->isToggleAction())
02079                 a->setOn(true);
02080 
02081             emit activated(a);
02082             emit Q3Action::activated();
02083             emit a->activated();
02084             if (a->isToggleAction())
02085                 emit selected(d->selected);
02086         } else if (!a->isToggleAction()) {
02087             emit activated(a);
02088             emit Q3Action::activated();
02089             emit a->activated();
02090         }
02091         a->clearStatusText();
02092     }
02093 }

void Q3ActionGroup::internalComboBoxHighlighted ( int   )  [private, slot]

Definition at line 2097 of file q3action.cpp.

References a, Q3ActionGroupPrivate::actions, QList< T >::at(), Q3Action::clearStatusText(), QList< T >::count(), d, i, and int.

Referenced by addTo().

02098 {
02099     Q3Action *a = 0;
02100     for (int i = 0; i <= index && i < (int)d->actions.count(); ++i) {
02101         a = d->actions.at(i);
02102         if (a && a->objectName() == QLatin1String("qt_separator_action"))
02103             index++;
02104     }
02105     a = d->actions.at(index);
02106     if (a)
02107         a->showStatusText(a->statusTip());
02108     else
02109         clearStatusText();
02110 }

void Q3ActionGroup::internalToggle ( Q3Action  )  [private, slot]

Definition at line 2114 of file q3action.cpp.

References a, Q3ActionGroupPrivate::actions, QList< T >::at(), QList< T >::begin(), Q3ActionGroupPrivate::comboboxes, d, QList< T >::end(), i, index, and QList< T >::indexOf().

Referenced by Q3ActionGroup().

02115 {
02116     int index = d->actions.indexOf(a);
02117     if (index == -1)
02118         return;
02119 
02120     int lastItem = index;
02121     for (int i=0; i<lastItem; ++i) {
02122         Q3Action *action = d->actions.at(i);
02123         if (action->objectName() == QLatin1String("qt_separator_action"))
02124             --index;
02125     }
02126 
02127     for (QList<QComboBox*>::Iterator it(d->comboboxes.begin());
02128          it != d->comboboxes.end(); ++it)
02129             (*it)->setCurrentItem(index);
02130 }

void Q3ActionGroup::objectDestroyed (  )  [private, slot]

Reimplemented from Q3Action.

Definition at line 2134 of file q3action.cpp.

References Q3ActionGroupPrivate::comboboxes, d, Q3ActionGroupPrivate::menubuttons, Q3ActionGroupPrivate::menuitems, Q3ActionGroupPrivate::popupmenus, QList< T >::removeAll(), and QObject::sender().

Referenced by addTo(), and ~Q3ActionGroup().

02135 {
02136     const QObject* obj = sender();
02137     d->menubuttons.removeAll((QToolButton *)obj);
02138     for (QList<Q3ActionGroupPrivate::MenuItem *>::Iterator mi(d->menuitems.begin());
02139          mi != d->menuitems.end(); ++mi) {
02140         if ((*mi)->popup == obj) {
02141             d->menuitems.removeAll(*mi);
02142             delete *mi;
02143             break;
02144         }
02145     }
02146     d->popupmenus.removeAll((Q3PopupMenu*)obj);
02147     d->comboboxes.removeAll((QComboBox*)obj);
02148 }

void Q3ActionGroup::insert ( Q3Action action  )  [inline]

Use add(action) instead.

Definition at line 193 of file q3action.h.

References a.

00193 { add(a); }


Member Data Documentation

Q3ActionGroupPrivate* Q3ActionGroup::d [private]

Reimplemented from Q3Action.

Definition at line 190 of file q3action.h.

Referenced by add(), addSeparator(), addTo(), childDestroyed(), childEvent(), childToggled(), internalComboBoxActivated(), internalComboBoxHighlighted(), internalToggle(), isExclusive(), objectDestroyed(), Q3ActionGroup(), removeFrom(), setEnabled(), setExclusive(), setIconSet(), setMenuText(), setOn(), setText(), setToggleAction(), setToolTip(), setUsesDropDown(), setVisible(), setWhatsThis(), usesDropDown(), and ~Q3ActionGroup().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 15:40:40 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1