예제 #1
0
void XDataWidget::setFields(const XData::FieldList &f)
{
    fields_.clear();

    // delete all child widgets
    QObjectList objlist = queryList();
    while (!objlist.isEmpty()) {
        delete objlist.takeFirst();
    }


    QVBoxLayout* vert = new QVBoxLayout(this);
    if (!instructions_.isEmpty()) {
        QLabel* l = new QLabel(instructions_, this);
        l->setWordWrap(true);
        l->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::LinksAccessibleByMouse);
        connect(l,SIGNAL(linkActivated(const QString&)),SLOT(linkActivated(const QString&)));
        vert->addWidget(l);
    }
    QWidget *fields = new QWidget(this);
    vert->addWidget(fields);
    if ( f.count() ) {
        QGridLayout *grid = new QGridLayout(fields, 3, f.count(), 0, 3);

        int row = 0;
        XData::FieldList::ConstIterator it = f.begin();
        for ( ; it != f.end(); ++it, ++row) {
            XDataField *f;
            switch ( (*it).type() ) {
            case XData::Field::Field_Boolean:
                f = new XDataField_Boolean(*it, grid, row, this);
                break;
            case XData::Field::Field_Fixed:
                f = new XDataField_Fixed(*it, grid, row, this);
                break;
            case XData::Field::Field_Hidden:
                f = new XDataField_Hidden(*it);
                break;
            case XData::Field::Field_JidSingle:
                f = new XDataField_JidSingle(*it, grid, row, this);
                break;
            case XData::Field::Field_ListMulti:
                f = new XDataField_ListMulti(*it, grid, row, this);
                break;
            case XData::Field::Field_ListSingle:
                f = new XDataField_ListSingle(*it, grid, row, this);
                break;
            case XData::Field::Field_TextMulti:
                f = new XDataField_TextMulti(*it, grid, row, this);
                break;
            case XData::Field::Field_JidMulti:
                f = new XDataField_JidMulti(*it, grid, row, this);
                break;
            case XData::Field::Field_TextPrivate:
                f = new XDataField_TextPrivate(*it, grid, row, this);
                break;

            default:
                f = new XDataField_TextSingle(*it, grid, row, this);
            }
            fields_.append(f);
        }
    }
}
예제 #2
0
파일: xdata_widget.cpp 프로젝트: Shura0/psi
void XDataWidget::setFields(const XData::FieldList &f)
{
	qDeleteAll(fields_);
	fields_.clear();

	QLayoutItem *child;
	while ((child = layout_->takeAt(0)) != 0) {
		delete child->widget();
		delete child;
	}

	if (!instructions_.isEmpty()) {
		QLabel* l = new QLabel(instructions_, this);
		l->setWordWrap(true);
		l->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::LinksAccessibleByMouse);
		connect(l,SIGNAL(linkActivated(const QString&)),SLOT(linkActivated(const QString&)));
		layout_->addWidget(l);
	}
	QWidget *fields = new QWidget(this);
	layout_->addWidget(fields);
	if ( f.count() ) {
		// FIXME
		QGridLayout *grid = new QGridLayout(fields);

		int row = 0;
		XData::FieldList::ConstIterator it = f.begin();
		for ( ; it != f.end(); ++it, ++row) {
			XDataField *f;
			switch ( (*it).type() ) {
				case XData::Field::Field_Boolean:
					f = new XDataField_Boolean(*it, grid, row, this);
					break;
				case XData::Field::Field_Fixed:
					f = new XDataField_Fixed(*it, grid, row, this);
					break;
				case XData::Field::Field_Hidden:
					f = new XDataField_Hidden(*it);
					break;
				case XData::Field::Field_JidSingle:
					f = new XDataField_JidSingle(*it, grid, row, this);
					break;
				case XData::Field::Field_ListMulti:
					f = new XDataField_ListMulti(*it, grid, row, this);
					break;
				case XData::Field::Field_ListSingle:
					f = new XDataField_ListSingle(*it, grid, row, this);
					break;
				case XData::Field::Field_TextMulti:
					f = new XDataField_TextMulti(*it, grid, row, this);
					break;
				case XData::Field::Field_JidMulti:
					f = new XDataField_JidMulti(*it, grid, row, this);
					break;
				case XData::Field::Field_TextPrivate:
					f = new XDataField_TextPrivate(*it, grid, row, this);
					break;

				default:
					f = new XDataField_TextSingle(*it, grid, row, this);
			}
			fields_.append(f);
		}
	}
}