The ToolBox class provides a column of tabbed widget items. More...
#include <ToolBox.h>
Public Slots | |
void | setCurrentIndex (int index) |
Sets the index of the current item, or -1 if the toolbox is empty to index. | |
void | setCurrentWidget (QWidget *item) |
Sets the current item to be item. | |
Signals | |
void | currentChanged (int index) |
This signal is emitted when the current item changed. | |
Public Member Functions | |
int | addItem (QWidget *item, const QIcon &iconSet, const QString &label) |
Adds the widget item in a new tab at bottom of the toolbox. | |
int | addItem (QWidget *w, const QString &label) |
Adds the widget w in a new tab at bottom of the toolbox. | |
int | count () const |
Returns the number of items contained in the toolbox. | |
int | currentIndex () const |
Returns the index of the current item, or -1 if the toolbox is empty. | |
QWidget * | currentWidget () const |
Returns the toolbox's current item, or 0 if the toolbox is empty. | |
int | indexOf (QWidget *item) const |
Returns the index of item item, or -1 if the item does not exist. | |
int | insertItem (int index, QWidget *item, const QIcon &iconSet, const QString &label) |
Inserts the widget item at position index, or at the bottom of the toolbox if index is out of range. | |
int | insertItem (int index, QWidget *item, const QString &label) |
This is an overloaded member function, provided for convenience. | |
bool | isItemEnabled (int index) const |
Returns TRUE if the item at position index is enabled; otherwise returns FALSE. | |
QIcon | itemIcon (int index) const |
Returns the icon of the item at position index, or a null icon if index is out of range. | |
QString | itemText (int index) const |
Returns the label of the item at position index, or a null string if index is out of range. | |
QString | itemToolTip (int index) const |
Returns the tooltip of the item at position index, or a null string if index is out of range. | |
void | removeItem (int index) |
Removes the widget item from the toolbox. | |
void | setItemEnabled (int index, bool enabled) |
If enabled is TRUE then the item at position index is enabled; otherwise item index is disabled. | |
void | setItemIcon (int index, const QIcon &iconSet) |
Sets the icon of the item at position index to iconSet. | |
void | setItemText (int index, const QString &label) |
Sets the label of the item at position index to label. | |
void | setItemToolTip (int index, const QString &toolTip) |
Sets the tooltip of the item at position index to toolTip. | |
ToolBox (QWidget *parent=0) | |
Constructs a toolbox called name with parent parent and flags f. | |
QWidget * | widget (int index) const |
Returns the item at position index, or 0 if there is no such item. | |
virtual | ~ToolBox () |
Protected Member Functions | |
void | changeEvent (QEvent *e) |
If to a new language is switched this method gets called. |
The ToolBox class provides a column of tabbed widget items.
A toolbox is a widget that displays a column of tabs one above the other, with the current item displayed below the current tab. Every tab has an index position within the column of tabs. A tab's item is a QWidget.
Each item has an itemLabel(), an optional icon, itemIconSet(), an optional itemToolTip(), and a widget. The item's attributes can be changed with setItemLabel(), setItemIconSet() and setItemToolTip().
Items are added using addItem(), or inserted at particular positions using insertItem(). The total number of items is given by count(). Items can be deleted with delete, or removed from the toolbox with removeItem(). Combining removeItem() and insertItem() allows to move items to different positions.
The current item widget is returned by currentItem() and set with setCurrentItem(). If you prefer you can work in terms of indexes using currentIndex(), setCurrentIndex(), indexOf() and item().
The currentChanged() signal is emitted when the current item is changed.
Note: This class implements the same API as the QToolBox does provided by Qt unless removeItem(), which also deletes the item to be removed.
Definition at line 57 of file ToolBox.h.
ToolBox::ToolBox | ( | QWidget * | parent = 0 |
) |
Constructs a toolbox called name with parent parent and flags f.
Definition at line 39 of file ToolBox.cpp.
References draftlibs::fcgeo::connect(), and currentChanged().
ToolBox::~ToolBox | ( | ) | [virtual] |
Definition at line 49 of file ToolBox.cpp.
int ToolBox::addItem | ( | QWidget * | item, | |
const QIcon & | iconSet, | |||
const QString & | label | |||
) |
Adds the widget item in a new tab at bottom of the toolbox.
The new tab's label is set to label, and the iconSet is displayed to the left of the label. Returns the new tab's index.
Definition at line 67 of file ToolBox.cpp.
int ToolBox::addItem | ( | QWidget * | w, | |
const QString & | label | |||
) |
Adds the widget w in a new tab at bottom of the toolbox.
The new tab's label is set to label. Returns the new tab's index.
Definition at line 58 of file ToolBox.cpp.
Referenced by Gui::ToolBoxManager::setup().
void ToolBox::changeEvent | ( | QEvent * | e | ) | [protected] |
If to a new language is switched this method gets called.
Definition at line 225 of file ToolBox.cpp.
References count(), setItemText(), RobotExample::w, and widget().
int ToolBox::count | ( | ) | const |
Returns the number of items contained in the toolbox.
Definition at line 209 of file ToolBox.cpp.
Referenced by changeEvent(), Gui::ToolBoxManager::retranslate(), and Gui::ToolBoxManager::setup().
void Gui::DockWnd::ToolBox::currentChanged | ( | int | index | ) | [signal] |
This signal is emitted when the current item changed.
The new current item's index is passed in index, or -1 if there is no current item.
Referenced by ToolBox().
int ToolBox::currentIndex | ( | ) | const |
Returns the index of the current item, or -1 if the toolbox is empty.
Definition at line 185 of file ToolBox.cpp.
QWidget * ToolBox::currentWidget | ( | ) | const |
Returns the toolbox's current item, or 0 if the toolbox is empty.
Definition at line 169 of file ToolBox.cpp.
int ToolBox::indexOf | ( | QWidget * | item | ) | const |
Returns the index of item item, or -1 if the item does not exist.
Definition at line 201 of file ToolBox.cpp.
int ToolBox::insertItem | ( | int | index, | |
QWidget * | item, | |||
const QIcon & | iconSet, | |||
const QString & | label | |||
) |
Inserts the widget item at position index, or at the bottom of the toolbox if index is out of range.
The new item's label is set to label, and the iconSet is displayed to the left of the label. Returns the new item's index.
Definition at line 88 of file ToolBox.cpp.
int ToolBox::insertItem | ( | int | index, | |
QWidget * | item, | |||
const QString & | label | |||
) |
This is an overloaded member function, provided for convenience.
It behaves essentially like the above function.
Inserts the widget item at position index, or at the bottom of the toolbox if index is out of range. The new item's label is set to label. Returns the new item's index.
Definition at line 78 of file ToolBox.cpp.
bool ToolBox::isItemEnabled | ( | int | index | ) | const |
Returns TRUE if the item at position index is enabled; otherwise returns FALSE.
Definition at line 113 of file ToolBox.cpp.
QIcon ToolBox::itemIcon | ( | int | index | ) | const |
Returns the icon of the item at position index, or a null icon if index is out of range.
Definition at line 145 of file ToolBox.cpp.
QString ToolBox::itemText | ( | int | index | ) | const |
Returns the label of the item at position index, or a null string if index is out of range.
Definition at line 129 of file ToolBox.cpp.
QString ToolBox::itemToolTip | ( | int | index | ) | const |
Returns the tooltip of the item at position index, or a null string if index is out of range.
Definition at line 161 of file ToolBox.cpp.
void ToolBox::removeItem | ( | int | index | ) |
Removes the widget item from the toolbox.
Returns the removed widget's index, or -1 if the widget was not in this tool box.
Definition at line 97 of file ToolBox.cpp.
Referenced by Gui::ToolBoxManager::setup().
void ToolBox::setCurrentIndex | ( | int | index | ) | [slot] |
Sets the index of the current item, or -1 if the toolbox is empty to index.
Definition at line 217 of file ToolBox.cpp.
void ToolBox::setCurrentWidget | ( | QWidget * | item | ) | [slot] |
Sets the current item to be item.
Definition at line 177 of file ToolBox.cpp.
void ToolBox::setItemEnabled | ( | int | index, | |
bool | enabled | |||
) |
If enabled is TRUE then the item at position index is enabled; otherwise item index is disabled.
Definition at line 105 of file ToolBox.cpp.
void ToolBox::setItemIcon | ( | int | index, | |
const QIcon & | iconSet | |||
) |
Sets the icon of the item at position index to iconSet.
Definition at line 137 of file ToolBox.cpp.
void ToolBox::setItemText | ( | int | index, | |
const QString & | label | |||
) |
Sets the label of the item at position index to label.
Definition at line 121 of file ToolBox.cpp.
Referenced by changeEvent(), and Gui::ToolBoxManager::retranslate().
void ToolBox::setItemToolTip | ( | int | index, | |
const QString & | toolTip | |||
) |
Sets the tooltip of the item at position index to toolTip.
Definition at line 153 of file ToolBox.cpp.
QWidget * ToolBox::widget | ( | int | index | ) | const |
Returns the item at position index, or 0 if there is no such item.
Definition at line 193 of file ToolBox.cpp.
Referenced by changeEvent(), Gui::ToolBoxManager::retranslate(), and Gui::ToolBoxManager::setup().