QStringList PromissionModel::selectAllPromission() { QStringList tmp; tmp.clear(); QDjango::setDatabase(*Core::Base::instance().sessionDatabase()); QDjango::registerModel<Promission>(); QDjango::createTables(); QDjangoQuerySet<Promission> proms; QList<QVariantMap> propertyMaps = proms.values(QStringList() << "name" << "signature" << "constant"); foreach (const QVariantMap &propertyMap, propertyMaps) { tmp.append(propertyMap["name"].toString()); }
void AddUserDialog::showEvent(QShowEvent *) { QDjango::setDatabase(*Core::Base::instance().sessionDatabase()); QDjango::registerModel<User>(); QDjango::createTables(); QRegExp rx("^(\\w+\\s+)$"); QValidator *validator = new QRegExpValidator(rx, this); ui->usernameEdit->setValidator(validator); ui->passwordEdit->setValidator(validator); QDjangoQuerySet<Group> groups; ui->groupBox->addItem(""); QList<QVariantMap> propertyMaps = groups.values(QStringList() << "name"); foreach (const QVariantMap &propertyMap, propertyMaps) { ui->groupBox->addItem(propertyMap["name"].toString()); }
/* * Чтение и подгрузка из БД требований. */ void BF_AnalizeForm::fillRequirements(const QString &type, QListWidget *lwgt) { lwgt->clear(); QDjango::setDatabase(*Core::Base::instance().sessionDatabase()); QDjangoQuerySet<RequirementElement> someRequirementElements; someRequirementElements = someRequirementElements.filter( QDjangoWhere("type", QDjangoWhere::Equals, type)); // retrieve usernames and passwords for matching users as maps QList<QVariantMap> propertyMaps = someRequirementElements.values( QStringList() << "id" << "type" << "name"); foreach (const QVariantMap &propertyList, propertyMaps) { QString tmp = QString("%1:%2%3-%4") .arg(propertyList["id"].toString()) .arg(propertyList["type"].toString()) .arg(propertyList["id"].toString()) .arg(propertyList["name"].toString()); lwgt->addItem(tmp); }