1 #include "XGUI_MenuGroupPanel.h"
2 #include "XGUI_Command.h"
7 #include <QResizeEvent>
12 XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent)
13 : QWidget(parent), myNewRow(0), myNewCol(0), myMaxRow(1)
15 myLayout = new QGridLayout(this);
16 myLayout->setSpacing(0);
17 myLayout->setMargin(0);
18 myLayout->setContentsMargins(0, 0, 0, 0);
21 void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
23 myActions.append(theAction);
24 QWidget* aWdg = theAction->requestWidget(this);
25 myActionWidget.append(aWdg);
29 void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
31 if (myMaxRow == myNewRow) {
35 myLayout->addWidget(theWgt, myNewRow, myNewCol, Qt::AlignLeft);
39 void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt)
44 void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
46 QWidget::resizeEvent(theEvent);
47 if (myActions.size() == 0)
50 int aH = theEvent->size().height();
51 int aMaxRow = (int) floor(double(aH / MIN_BUTTON_HEIGHT));
52 if (aMaxRow == myMaxRow)
58 foreach(QWidget* eachWidget, myActionWidget) {
59 placeWidget(eachWidget);
63 XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle,
64 const QString& theTip, const QIcon& theIcon,
65 const QKeySequence& theKeys, bool isCheckable)
67 XGUI_Command* aCommand = new XGUI_Command(theId, theIcon, theTitle, this, isCheckable);
68 aCommand->setToolTip(theTip);
69 if (!theKeys.isEmpty())
70 aCommand->setShortcut(theKeys);
77 XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const
79 QList<XGUI_Command*>::const_iterator aIt;
80 for (aIt = myActions.constBegin(); aIt != myActions.constEnd(); ++aIt)
81 if ((*aIt)->id() == theId)