void JAccountRegistrationPage::onFieldsReceived(const RegistrationData &data)
{
	ui->stackedWidget->setCurrentWidget(ui->formPage);
	if (data.form()) {
		DataForm::Ptr form = data.form();
		if (m_jabberForm) {
			DataForm::Ptr oldForm = m_jabberForm->getDataForm();
			for (uint i = 0; i < sizeof(knownVars) / sizeof(knownVars[0]); ++i) {
				QLatin1String var(knownVars[i]);
				Jreen::DataFormField oldField = oldForm->field(var);
				Jreen::DataFormField field = form->field(var);
				if (field.type() != Jreen::DataFormField::Invalid
						&& oldField.type() != Jreen::DataFormField::Invalid) {
					field.setValues(oldField.values());
				}
			}
			delete m_jabberForm;
		}
		
		m_jabberForm = new JDataForm(data.form(), data.bitsOfBinaries(), ui->formPage);
		m_form = m_jabberForm->widget();
		setSubTitle(data.form()->instructions());
		ui->verticalLayout_3->addWidget(m_jabberForm);
		
	} else {
//		if (data.hasUrl()) {
//			// Notify user about url by which he can register
//			QUrl url = data.url();
//		}
		if (data.hasFields()) {
			DataItem oldRoot;
			if (m_form)
				oldRoot = m_form->item();
			delete m_form;
			DataItem root;
			for (int i = 0; i < Jreen::RegistrationData::LastFieldType; ++i) {
				Jreen::RegistrationData::FieldType type = static_cast<Jreen::RegistrationData::FieldType>(i);
				if (!data.hasField(type))
					continue;
				QString name = QString::number(i);
				DataItem oldItem = root.subitem(name);
				DataItem item(name, fieldText(type), oldItem.data().toString());
				if (type == Jreen::RegistrationData::PasswordField)
					item.setProperty("password", true);
				item.setProperty("mandatory", true);
				root << item;
			}
			m_form = AbstractDataForm::get(root);
			setSubTitle(data.instructions());
			ui->verticalLayout_3->addWidget(m_form);
		}
	} 
	if (m_form) {
		connect(m_form, SIGNAL(completeChanged(bool)), SIGNAL(completeChanged()));
		emit completeChanged();
	}
}
예제 #2
0
QVariant KisPaintOpListModel::data(const QModelIndex& idx, int role) const
{
    if (!idx.isValid()) return QVariant();

    DataItem *item = categoriesMapper()->itemFromRow(idx.row());
    Q_ASSERT(item);

    if(role == Qt::DecorationRole) {
        if (!item->isCategory()) {
            return item->data()->icon;
        }
    } else if (role == SortRole) {
        return item->isCategory() ? item->name() :
            QString("%1%2%3")
            .arg(item->parentCategory()->name())
            .arg(item->data()->priority, 4)
            .arg(item->name());
    }

    return BasePaintOpCategorizedListModel::data(idx, role);
}
void JAccountRegistrationPage::onSuccess()
{
	ui->errorLabel->setText(QString());
	m_registered = true;
	if (m_jabberForm) {
		DataForm::Ptr form = m_jabberForm->getDataForm();
		DataFormField jidField = form->field(QLatin1String("username"));
		QString server = field(QLatin1String("server")).toString();
		JID jid = jidField.value() + QLatin1Char('@') + server;
		setField(QLatin1String("jid"), jid.bare());
		setField(QLatin1String("password"), QString());
		setField(QLatin1String("savePassword"), false);
	} else {
		DataItem item = m_form->item();
		DataItem jidItem = item.subitem(QString::number(Jreen::RegistrationData::UsernameField));
		QString server = field(QLatin1String("server")).toString();
		JID jid = jidItem.data().toString() + QLatin1Char('@') + server;
		setField(QLatin1String("jid"), jid.bare());
		setField(QLatin1String("password"), QString());
		setField(QLatin1String("savePassword"), false);
	}
	emit completeChanged();
	wizard()->next();
}
예제 #4
0
bool QuickContactInfo::isItemEmpty(const DataItem &item)
{
	if (item.data().isNull() || item.property("notSet", false))
		return true;
	QVariant::Type type = item.data().type();
	if (type == QVariant::Icon)
		return item.data().value<QIcon>().isNull();
	else if (type == QVariant::Pixmap)
		return item.data().value<QPixmap>().isNull();
	else if (type == QVariant::Image)
		return item.data().value<QImage>().isNull();
	else if (type == QVariant::StringList)
		return item.data().value<QStringList>().isEmpty();
	else if (item.data().canConvert<LocalizedString>())
		return item.data().value<LocalizedString>().toString().isEmpty();
	else if (item.data().canConvert<LocalizedStringList>())
		return item.data().value<LocalizedStringList>().isEmpty();
	else
		return item.data().toString().isEmpty();
}