예제 #1
0
    XDataField_ListMulti(XData::Field f, QGridLayout *grid, int row, QWidget *parent)
        : XDataField(f)
    {
        QLabel *label = new QLabel(labelText(), parent);
        grid->addWidget(label, row, 0);

        list = new QListWidget(parent);
        grid->addWidget(list, row, 1);
        list->setSelectionMode(QAbstractItemView::MultiSelection);

        XData::Field::OptionList opts = f.options();
        XData::Field::OptionList::Iterator it = opts.begin();
        for ( ; it != opts.end(); ++it) {
            QString lbl = (*it).label;
            if ( lbl.isEmpty() )
                lbl = (*it).value;

            QListWidgetItem* item = new QListWidgetItem(lbl,list);

            QStringList val = f.value();
            QStringList::Iterator sit = val.begin();
            for ( ; sit != val.end(); ++sit)
                if ( (*it).label == *sit || (*it).value == *sit )
                    list->setItemSelected(item, true);
        }

        QLabel *req = new QLabel(reqText(), parent);
        grid->addWidget(req, row, 2);

        if ( !f.desc().isEmpty() ) {
            label->setToolTip(f.desc());
            list->setToolTip(f.desc());
            req->setToolTip(f.desc());
        }
    }
예제 #2
0
    XDataField_ListSingle(XData::Field f, QGridLayout *grid, int row, QWidget *parent)
        : XDataField(f)
    {
        QLabel *label = new QLabel(labelText(), parent);
        grid->addWidget(label, row, 0);

        combo = new QComboBox(parent);
        grid->addWidget(combo, row, 1);
        combo->setInsertionPolicy(QComboBox::NoInsertion);

        QString sel;
        if ( !f.value().isEmpty() )
            sel = f.value().first();

        XData::Field::OptionList opts = f.options();
        XData::Field::OptionList::Iterator it = opts.begin();
        for ( ; it != opts.end(); ++it) {
            QString lbl = (*it).label;
            if ( lbl.isEmpty() )
                lbl = (*it).value;

            combo->insertItem(lbl);
            if ( (*it).value == sel )
                combo->setCurrentText( lbl );
        }

        QLabel *req = new QLabel(reqText(), parent);
        grid->addWidget(req, row, 2);

        if ( !f.desc().isEmpty() ) {
            label->setToolTip(f.desc());
            combo->setToolTip(f.desc());
            req->setToolTip(f.desc());
        }
    }
예제 #3
0
    XData::Field field() const
    {
        QString lbl = combo->currentText();

        XData::Field f = XDataField::field();
        QStringList val;

        XData::Field::OptionList opts = f.options();
        XData::Field::OptionList::Iterator it = opts.begin();
        for ( ; it != opts.end(); ++it) {
            if ( (*it).label == lbl || (*it).value == lbl ) {
                val << (*it).value;
                break;
            }
        }

        f.setValue(val);
        return f;
    }
예제 #4
0
    XData::Field field() const
    {
        XData::Field f = XDataField::field();
        QStringList val;

        for (int i = 0; i < list->count(); i++) {
            QListWidgetItem* item = list->item(i);
            if ( list->isItemSelected(item) ) {
                QString lbl = item->text();
                XData::Field::OptionList opts = f.options();
                XData::Field::OptionList::Iterator it = opts.begin();
                for ( ; it != opts.end(); ++it) {
                    if ( (*it).label == lbl || (*it).value == lbl ) {
                        val << (*it).value;
                        break;
                    }
                }
            }
        }

        f.setValue(val);
        return f;
    }