Пример #1
0
void SubmitFieldWidget::createField(const QString &f)
{
    FieldEntry fe;
    fe.createGui(d->removeFieldIcon);
    fe.combo->addItems(d->fields);
    if (!f.isEmpty()) {
        const int index = fe.combo->findText(f);
        if (index != -1) {
            setComboBlocked(fe.combo, index);
            fe.comboIndex = index;
        }
    }

    connect(fe.browseButton, &QAbstractButton::clicked, this, &SubmitFieldWidget::slotBrowseButtonClicked);
    if (!d->hasBrowseButton)
        fe.browseButton->setVisible(false);

    if (d->completer)
        fe.lineEdit->setCompleter(d->completer);

    connect(fe.combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
            this, &SubmitFieldWidget::slotComboIndexChanged);
    connect(fe.clearButton, &QAbstractButton::clicked,
            this, &SubmitFieldWidget::slotRemove);
    d->layout->addLayout(fe.layout);
    d->fieldEntries.push_back(fe);
}
Пример #2
0
void SubmitFieldWidget::createField(const QString &f)
{
    FieldEntry fe;
    fe.createGui(m_d->removeFieldIcon);
    fe.combo->addItems(m_d->fields);
    if (!f.isEmpty()) {
        const int index = fe.combo->findText(f);
        if (index != -1) {
            setComboBlocked(fe.combo, index);
            fe.comboIndex = index;
        }
    }

    connect(fe.browseButton, SIGNAL(clicked()), this, SLOT(slotBrowseButtonClicked()));
    if (!m_d->hasBrowseButton)
        fe.browseButton->setVisible(false);

    if (m_d->completer)
        fe.lineEdit->setCompleter(m_d->completer);

    connect(fe.combo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(slotComboIndexChanged(int)));
    connect(fe.clearButton, SIGNAL(clicked()),
            this, SLOT(slotRemove()));
    m_d->layout->addLayout(fe.layout);
    m_d->fieldEntries.push_back(fe);
}
Пример #3
0
void SubmitFieldWidget::slotComboIndexChanged(int comboIndex)
{
    const int pos = d->findSender(sender());
    if (debug)
        qDebug() << '>' << Q_FUNC_INFO << pos;
    if (pos == -1)
        return;
    // Accept new index or reset combo to previous value?
    int &previousIndex = d->fieldEntries[pos].comboIndex;
    if (comboIndexChange(pos, comboIndex))
        previousIndex = comboIndex;
    else
        setComboBlocked(d->fieldEntries.at(pos).combo, previousIndex);
    if (debug)
        qDebug() << '<' << Q_FUNC_INFO << pos;
}