X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_MenuGroupPanel.cpp;h=8d5d24b2146206e706922eff835521861c478797;hb=e6aea428c7da7751e753eac36b99e16b7e3166e4;hp=0753625d5c476f1615c896e5173f30f2fc389206;hpb=dcfbdb77dfd1e8f4f5a9f636ff5534d74af3592e;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_MenuGroupPanel.cpp b/src/XGUI/XGUI_MenuGroupPanel.cpp index 0753625d5..8d5d24b21 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.cpp +++ b/src/XGUI/XGUI_MenuGroupPanel.cpp @@ -7,69 +7,80 @@ #include #include +#include -XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent) : - QWidget(parent), myNewRow(0), myNewCol(0), myMaxRow(1) +XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent) + : QWidget(parent), myNewRow(0), myNewCol(0), myMaxRow(1) { - myLayout = new QGridLayout(this); - myLayout->setSpacing(0); - myLayout->setMargin(0); - myLayout->setContentsMargins(0,0,0,0); + myLayout = new QGridLayout(this); + myLayout->setSpacing(0); + myLayout->setMargin(0); + myLayout->setContentsMargins(0, 0, 0, 0); } - void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction) { - myActions[theAction] = theAction->requestWidget(this); - addWidget(myActions[theAction]); + myActions.append(theAction); + QWidget* aWdg = theAction->requestWidget(this); + myActionWidget.append(aWdg); + addWidget(aWdg); } void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt) { - if (myMaxRow == myNewRow) { - myNewRow = 0; - myNewCol++; - } - myLayout->addWidget(theWgt, myNewRow, myNewCol, Qt::AlignLeft); - myNewRow++; + if (myMaxRow == myNewRow) { + myNewRow = 0; + myNewCol++; + } + myLayout->addWidget(theWgt, myNewRow, myNewCol); + myLayout->setRowStretch(myNewRow, 0); + myNewRow++; } void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt) { - placeWidget(theWgt); + placeWidget(theWgt); } - void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent) { - QWidget::resizeEvent(theEvent); - if (myActions.size() == 0) - return; + QWidget::resizeEvent(theEvent); + if (myActions.size() == 0) + return; - int aH = theEvent->size().height(); - int aMaxRow = (int) floor(double(aH / MIN_BUTTON_HEIGHT)); - if (aMaxRow == myMaxRow) - return; + int aH = theEvent->size().height(); + int aMaxRow = (int) floor(double(aH / MIN_BUTTON_HEIGHT)); + if (aMaxRow == myMaxRow) + return; - myMaxRow = aMaxRow; - QListIterator aIt(myActions.values()); - myNewRow = 0; - myNewCol = 0; - while (aIt.hasNext()) { - placeWidget(aIt.next()); - } + myMaxRow = aMaxRow; + myNewRow = 0; + myNewCol = 0; + foreach(QWidget* eachWidget, myActionWidget) { + placeWidget(eachWidget); + } + myLayout->setRowStretch(myMaxRow + 1, 1); } -IFeatureMenu* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys) +XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle, + const QString& theTip, const QIcon& theIcon, + const QKeySequence& theKeys, bool isCheckable) { - XGUI_Command* aCommand = new XGUI_Command(theId, theIcon, theTitle, this); - aCommand->setToolTip(theTip); - if (!theKeys.isEmpty()) - aCommand->setShortcut(theKeys); + XGUI_Command* aCommand = new XGUI_Command(theId, theIcon, theTitle, this, isCheckable); + aCommand->setToolTip(theTip); + if (!theKeys.isEmpty()) + aCommand->setShortcut(theKeys); - addCommand(aCommand); - return aCommand; + addCommand(aCommand); + return aCommand; +} + + +XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const +{ + foreach (XGUI_Command* aCmd, myActions) { + if (aCmd->data().toString() == theId) + return aCmd; + } + return 0; }