QAbstractButton*
FirstRunWizard::setButton( Button button, const QString& text )
{
    QAbstractButton* returnButton;

    switch ( button )
    {
    case CustomButton:
        returnButton = ui->custom;
        break;
    case BackButton:
        returnButton = ui->back;
        break;
    case SkipButton:
        returnButton = ui->skip;
        break;
    case NextButton:
        returnButton = ui->next;
        break;
    case FinishButton:
        returnButton = ui->finish;
        break;
    }

    returnButton->setText( text );
    returnButton->show();

    return returnButton;
}
示例#2
0
void TabBar::updatePinnedTabCloseButton(int index)
{
    if (!validIndex(index)) {
        return;
    }

    WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
    QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, closeButtonPosition()));

    bool pinned = webTab && webTab->isPinned();

    if (pinned) {
        if (button) {
            button->hide();
        }
    }
    else {
        if (button) {
            button->show();
        }
        else {
            showCloseButton(index);
        }
    }
}
示例#3
0
void PTabWidget::tabChanged(int index) {
    // Hide the close button on the old tab
    if (m_lastTabIndex >= 0) {
        QAbstractButton *tabButton = qobject_cast<QAbstractButton *>(tabBar()->tabButton(m_lastTabIndex, QTabBar::LeftSide));
        if (!tabButton) {
			tabButton = qobject_cast<QAbstractButton *>(tabBar()->tabButton(m_lastTabIndex, QTabBar::RightSide));
        }

        if (tabButton) {
            tabButton->hide();
        }
    }

    m_lastTabIndex = index;

    // Show the close button on the new tab
    if (m_lastTabIndex >= 0) {
        QAbstractButton *tabButton = qobject_cast<QAbstractButton *>(tabBar()->tabButton(m_lastTabIndex, QTabBar::LeftSide));
        if (!tabButton) {
            tabButton = qobject_cast<QAbstractButton *>(tabBar()->tabButton(m_lastTabIndex, QTabBar::RightSide));
        }
        if (tabButton) {
            tabButton->show();
        }
    }
}
示例#4
0
void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList,
                                                 bool reverse)
{
    int start = reverse ? buttonList.count() - 1 : 0;
    int end = reverse ? -1 : buttonList.count();
    int step = reverse ? -1 : 1;

    for (int i = start; i != end; i += step) {
        QAbstractButton *button = buttonList.at(i);
        buttonLayout->addWidget(button);
        button->show();
    }
}
示例#5
0
void TabBar::updateCloseButton(int index)
{
    QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, QTabBar::RightSide));
    if (!button) {
        return;
    }

    WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
    if (webTab && webTab->isPinned()) {
        button->hide();
    }
    else {
        button->show();
    }
}
示例#6
0
void QDialogButtonBoxPrivate::layoutButtons()
{
    Q_Q(QDialogButtonBox);
    const int MacGap = 24 - 8;	// 8 is the default gap between a widget and a spacer item

    for (int i = buttonLayout->count() - 1; i >= 0; --i) {
        QLayoutItem *item = buttonLayout->takeAt(i);
        if (QWidget *widget = item->widget())
            widget->hide();
        delete item;
    }

    int tmpPolicy = layoutPolicy;

    static const int M = 5;
    static int ModalRoles[M] = { AcceptRole, RejectRole, DestructiveRole, YesRole, NoRole };
    if (tmpPolicy == QDialogButtonBox::MacLayout) {
        bool hasModalButton = false;
        for (int i = 0; i < M; ++i) {
            if (!buttonLists[ModalRoles[i]].isEmpty()) {
                hasModalButton = true;
                break;
            }
        }
        if (!hasModalButton)
            tmpPolicy = 4;  // Mac modeless
    }

    const int *currentLayout = layouts[orientation == Qt::Vertical][tmpPolicy];

    if (center)
        buttonLayout->addStretch();

    QList<QAbstractButton *> acceptRoleList = buttonLists[AcceptRole];

    while (*currentLayout != EOL) {
        int role = (*currentLayout & ~Reverse);
        bool reverse = (*currentLayout & Reverse);

        switch (role) {
        case Stretch:
            if (!center)
                buttonLayout->addStretch();
            break;
        case AcceptRole: {
            if (acceptRoleList.isEmpty())
                break;
            // Only the first one
            QAbstractButton *button = acceptRoleList.first();
            buttonLayout->addWidget(button);
            button->show();
        }
            break;
        case AlternateRole:
            {
                if (acceptRoleList.size() < 2)
                    break;
                QList<QAbstractButton *> list = acceptRoleList;
                list.removeFirst();
                addButtonsToLayout(list, reverse);
            }
            break;
        case DestructiveRole:
            {
                const QList<QAbstractButton *> &list = buttonLists[role];

                /*
                    Mac: Insert a gap on the left of the destructive
                    buttons to ensure that they don't get too close to
                    the help and action buttons (but only if there are
                    some buttons to the left of the destructive buttons
                    (and the stretch, whence buttonLayout->count() > 1
                    and not 0)).
                */
                if (tmpPolicy == QDialogButtonBox::MacLayout
                        && !list.isEmpty() && buttonLayout->count() > 1)
                    buttonLayout->addSpacing(MacGap);

                addButtonsToLayout(list, reverse);

                /*
                    Insert a gap between the destructive buttons and the
                    accept and reject buttons.
                */
                if (tmpPolicy == QDialogButtonBox::MacLayout && !list.isEmpty())
                    buttonLayout->addSpacing(MacGap);
            }
            break;
        case RejectRole:
        case ActionRole:
        case HelpRole:
        case YesRole:
        case NoRole:
        case ApplyRole:
        case ResetRole:
            addButtonsToLayout(buttonLists[role], reverse);
        }
        ++currentLayout;
    }

    QWidget *lastWidget = 0;
    q->setFocusProxy(0);
    for (int i = 0; i < buttonLayout->count(); ++i) {
        QLayoutItem *item = buttonLayout->itemAt(i);
        if (QWidget *widget = item->widget()) {
            if (lastWidget)
                QWidget::setTabOrder(lastWidget, widget);
            else
                q->setFocusProxy(widget);
            lastWidget = widget;
        }
    }

    if (center)
        buttonLayout->addStretch();
}
void ClsQNeuronStateVariableDisplay::groupChanged(){
#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
    cout << "ClsQNeuronStateVariableDisplay::groupChanged()" << endl;
#endif
    if(qLabelMiniGroup!=NULL){
	QPixmap qpm;
	qpm = ClsQMiniGroup::getPixmap(clsFEGroup->getTopology(), strSelectedIndices, qgrpbxStateVariables->sizeHint().width() - 10, 100);
	qLabelMiniGroup->setPixmap(qpm);
    }

/* change label */
    string strInfo;
    strInfo = "Group ID:\t" + clsFEGroup->getGroupID();
    strInfo = strInfo + "\nGroup name:\t" + clsFEGroup->getGroupName();
    strInfo = strInfo + "\nNeuron type:\t" + clsFEGroup->getGroupNeuronType();
    strInfo = strInfo + "\nGroup width:\t" + iqrUtils::int2string(clsFEGroup->getNrCellsHorizontal());
    strInfo = strInfo + "\nGroup height:\t" + iqrUtils::int2string(clsFEGroup->getNrCellsVertical());
    
    lblCaption->setText( clsFEGroup->getGroupName().c_str());
    QToolTip::add( lblCaption, strInfo.c_str() );

    /* save selections */
    list<string> lstSelectedState = getSelectedStates();

/* remove all buttons from the QButtonGroup */
    QList<QAbstractButton *> lst = qbtngrpStateVariables->buttons ();
    QList<QAbstractButton*>::iterator it;


    for (it = lst.begin(); it != lst.end(); ++it) {
	QAbstractButton* bb = (*it);
	if(bb!=NULL){
	    qbtngrpStateVariables->remove(bb);
	    delete bb;
	}
    }


/* rebuild state list */
    int ii=0;

    StateVariableList lstNeuronStateVariables = clsFEGroup->getListNeuronStateVariables( );
    iqrcommon::StateVariableList::const_iterator itlstNeuronStateVariables;
    for (itlstNeuronStateVariables = lstNeuronStateVariables.begin();
	 itlstNeuronStateVariables != lstNeuronStateVariables.end(); ++itlstNeuronStateVariables){

	QAbstractButton *qrb;
	ClsStateVariable *pState = *itlstNeuronStateVariables;

	if(bExclusiveStates) {
	    qrb = new QRadioButton ( pState->getName().c_str());
	}
	else{
	    qrb = new QCheckBox ( pState->getName().c_str());
	}
	
 	qrb->show();
	qbtngrpStateVariables->addButton(qrb, ii );
	qlayoutStateVariables->addWidget(qrb);

	ii++;
    }

//    qgrpbxStateVariables->setFixedHeight(qgrpbxStateVariables->sizeHint().height());
    setSelectedStates(lstSelectedState);
}
ClsQNeuronStateVariableDisplay::ClsQNeuronStateVariableDisplay(ClsFEDataClient *_clsFEDataClient,
							       string _strID, QWidget *_parent,
							       ClsFEGroup* _clsFEGroup,
							       string _strSelectedIndices,
							       bool bCloseEnabled, bool bAverageEnabled,
							       bool _bExclusiveStates, bool _bAdditiveDisplay, bool bMiniGroupDisplay) :
    ClsQBaseStateVariableDisplay(_clsFEDataClient, _strID, _parent), clsFEGroup(_clsFEGroup),
    strSelectedIndices(_strSelectedIndices), bExclusiveStates(_bExclusiveStates), bAdditiveDisplay(_bAdditiveDisplay) {

    

#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
    cout << "ClsQNeuronStateVariableDisplay::ClsQNeuronStateVariableDisplay(...)" << endl;
#endif

    qLabelMiniGroup = NULL;
    iCurrentStateButton = -99;
    bAverage = false;

    setAcceptDrops(TRUE);
    QGridLayout *qgly = new QGridLayout ( this, 5, 1, 2, 0);

    string strInfo;
    strInfo = "Group ID:\t" + clsFEGroup->getGroupID();
    strInfo = strInfo + "\nGroup name:\t" + clsFEGroup->getGroupName();
    strInfo = strInfo + "\nNeuron type:\t" + clsFEGroup->getGroupNeuronType();
    strInfo = strInfo + "\nGroup width:\t" + iqrUtils::int2string(clsFEGroup->getNrCellsHorizontal());
    strInfo = strInfo + "\nGroup height:\t" + iqrUtils::int2string(clsFEGroup->getNrCellsVertical());


    if(bCloseEnabled){
	qpbtnClose = new QPushButton ( this);
	qpbtnClose->setPixmap( QPixmap(close_very_small ));
	qpbtnClose->setFlat(true);
	qgly->addWidget(qpbtnClose, 0, 0, Qt::AlignRight | Qt::AlignTop);
	connect(qpbtnClose, SIGNAL(clicked()), SLOT(slotClose()));
    }

    ClsQDragHandle* clsQDragHandle = new ClsQDragHandle(this);
    qgly->addWidget(clsQDragHandle, 0, 0, Qt::AlignLeft | Qt::AlignTop);
    connect(clsQDragHandle, SIGNAL(drag(bool)), this, SLOT(startDragging(bool)));


    lblCaption->setText( clsFEGroup->getGroupName().c_str());
    QToolTip::add( lblCaption, strInfo.c_str() );

    qgly->addWidget (lblCaption, 1, 0, Qt::AlignHCenter | Qt::AlignVCenter ) ;

//	  setTitle(_clsQlstItemGroup->getGroupID());


//-------------------------------
    qgrpbxStateVariables = new QGroupBox("states");

    qbtngrpStateVariables = new QButtonGroup();
    qlayoutStateVariables = new QVBoxLayout;
    qlayoutStateVariables->setSpacing ( 0 );
    qlayoutStateVariables->setContentsMargins ( 0,0,0, 0);
    qgrpbxStateVariables->setLayout(qlayoutStateVariables);


    int ii=0;

    StateVariableList lstNeuronStateVariables = clsFEGroup->getListNeuronStateVariables( );
    iqrcommon::StateVariableList::const_iterator itlstNeuronStateVariables;
    for (itlstNeuronStateVariables = lstNeuronStateVariables.begin();
	 itlstNeuronStateVariables != lstNeuronStateVariables.end(); ++itlstNeuronStateVariables){

	QAbstractButton *qrb;
	ClsStateVariable *pState = *itlstNeuronStateVariables;

	if(bExclusiveStates) {
	    qrb = new QRadioButton ( pState->getName().c_str());
	}
	else{
	    qrb = new QCheckBox ( pState->getName().c_str());
	}
 	qrb->show();
	qbtngrpStateVariables->addButton(qrb, ii );
	qlayoutStateVariables->addWidget(qrb);

	ii++;
    }



    connect(qbtngrpStateVariables, SIGNAL(buttonClicked(int)), SLOT(slotStateVariables(int)));
    qbtngrpStateVariables->setExclusive ( bExclusiveStates );

//--------------------------

    qgly->addWidget ( qgrpbxStateVariables, 2, 0, Qt::AlignHCenter) ;

    if(bMiniGroupDisplay){
	qLabelMiniGroup = new QLabel(this);

	QPixmap qpm;
	qpm = ClsQMiniGroup::getPixmap(clsFEGroup->getTopology(), strSelectedIndices, qgrpbxStateVariables->sizeHint().width() - 10, 100);
	qLabelMiniGroup->setPixmap(qpm);
	qgly->addWidget(qLabelMiniGroup, 3, 0, Qt::AlignCenter  );
	qgly->setRowStretch ( 3, 5 );
    } 

    if(bAverageEnabled){
	qchkbxAverage = new QCheckBox ( "average", this) ;
	qgly->addWidget ( qchkbxAverage, 4, 0, Qt::AlignLeft ) ;
	connect(qchkbxAverage, SIGNAL(toggled(bool)), SLOT(slotAverage(bool)));
    } else {
	qchkbxAverage = NULL;
    }

    qchkbxLiveData = new QCheckBox ( "live data", this) ;
    qgly->addWidget ( qchkbxLiveData, 5, 0, Qt::AlignLeft ) ;
    qchkbxLiveData->setChecked( true); /* should on initially.... */
    connect(qchkbxLiveData, SIGNAL(toggled(bool)), SLOT(slotLiveData(bool)));

    this->show();
};