本文整理汇总了C++中QDjangoQuerySet::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QDjangoQuerySet::size方法的具体用法?C++ QDjangoQuerySet::size怎么用?C++ QDjangoQuerySet::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDjangoQuerySet
的用法示例。
在下文中一共展示了QDjangoQuerySet::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filterRelated
/** Perform filtering on foreign keys.
*/
void tst_QDjangoModel::filterRelated()
{
// load fixtures
{
Item *item1 = new Item;
item1->setName("first");
QCOMPARE(item1->save(), true);
Item *item2 = new Item;
item2->setName("second");
QCOMPARE(item2->save(), true);
Owner owner;
owner.setName("owner");
owner.setItem1(item1);
owner.setItem2(item2);
QCOMPARE(owner.save(), true);
}
// perform filtering
QDjangoQuerySet<Owner> owners;
QDjangoQuerySet<Owner> qs = owners.filter(
QDjangoWhere("item1__name", QDjangoWhere::Equals, "first"));
CHECKWHERE(qs.where(), QLatin1String("T0.\"name\" = ?"), QVariantList() << "first");
QCOMPARE(qs.count(), 1);
QCOMPARE(qs.size(), 1);
Owner *owner = qs.at(0);
QVERIFY(owner != 0);
QCOMPARE(owner->name(), QLatin1String("owner"));
delete owner;
}
示例2: saveMessage
static void saveMessage(const QXmppMessage &message, const QDateTime &now, bool received)
{
const QString localJid = QXmppUtils::jidToBareJid(received ? message.to() : message.from());
const QString remoteJid = QXmppUtils::jidToBareJid(received ? message.from() : message.to());
// get or create collection
int chatId;
QDjangoQuerySet<ArchiveMessage> qs;
qs = qs.filter(QDjangoWhere("chat__jid", QDjangoWhere::Equals, localJid));
qs = qs.filter(QDjangoWhere("chat__with", QDjangoWhere::Equals, remoteJid));
qs = qs.orderBy(QStringList() << "-date").limit(0, 1);
ArchiveMessage tmp;
if (qs.size() > 0 && qs.at(0, &tmp) && tmp.date().secsTo(now) < 3600) {
chatId = tmp.property("chat_id").toInt();
} else {
ArchiveChat chat;
chat.setJid(localJid);
chat.setWith(remoteJid);
chat.setStart(now);
chat.save();
chatId = chat.pk().toInt();
}
// save outgoing message
ArchiveMessage msg;
msg.setProperty("chat_id", chatId);
msg.setBody(message.body());
msg.setDate(now);
msg.setReceived(received);
msg.save();
}
示例3: renderData
void GroupsWidget::renderData() {
FUNCTION
QDjangoQuerySet<Group> gqs = QDjangoQuerySet<Group>().all();
ui->groupsTW->setRowCount(gqs.size());
for(qint32 i = 0; i < gqs.size(); ++i) {
Group* group = gqs.at(i);
_groups.append(group);
QTableWidgetItem* item0 = new QTableWidgetItem(group->name());
Normal* normal = QDjangoQuerySet<Normal>().get(QDjangoWhere("group_id", QDjangoWhere::Equals, group->pk()));
QTableWidgetItem* item1 = new QTableWidgetItem(QString::number(normal->speed()));
qint32 userCount = QDjangoQuerySet<User>().filter(QDjangoWhere("group_id", QDjangoWhere::Equals, group->pk())).size();
QTableWidgetItem* item2 = new QTableWidgetItem(QString::number(userCount));
ui->groupsTW->setItem(i, 0, item0);
ui->groupsTW->setItem(i, 1, item1);
ui->groupsTW->setItem(i, 2, item2);
}
}
示例4: getCurrentName
QString LoggerSettingsModel::getCurrentName()
{
QDjangoQuerySet<LoggerSettingsQDjangoModel> settings;
LoggerSettingsQDjangoModel setting;
for (int i = 0; i < settings.size(); ++i) {
if (settings.at(i, &setting)) {
return setting.currentLoggerName();
}
}
return QString("");
}
示例5: existe
bool NouveauxProduitsDialog::existe( QString code )
{
QDjangoQuerySet< Core::Produit > produits;
int l = produits.size();
for( int i = 0; i < l; ++i )
{
Core::Produit *p = produits.at( i );
if( p->getCode() == code )
return true;
}
return false;
}
示例6: setCurrentName
void LoggerSettingsModel::setCurrentName(const QString ¤tName)
{
QDjangoQuerySet<LoggerSettingsQDjangoModel> settings;
for (int i = 0; i < settings.size(); ++i) {
LoggerSettingsQDjangoModel setting;
if (settings.at(i, &setting)) {
setting.setCurrentLoggerName(currentName);
setting.save();
return;
}
}
LoggerSettingsQDjangoModel *setting = new LoggerSettingsQDjangoModel;
setting->setCurrentLoggerName(currentName);
setting->save();
}
示例7: on_btValider_clicked
void NouveauxProduitsDialog::on_btValider_clicked()
{
QDjangoQuerySet< Core::Temp > produits;
int l = produits.size();
for( int i = 0; i < l; ++i )
{
Core::Temp *t = produits.at( i );
Core::Produit *p = new Core::Produit();
p->setCode( t->getCode() );
p->setConstructeur( t->getConstructeur() );
p->setNom( t->getNom() );
p->setDescription( t->getDescription() );
p->setType( t->getType() );
p->setPrixUnitaire( t->getPrixUnitaire() );
p->save();
}
produits.remove();
}
示例8: rsmFilter
void rsmFilter(QDjangoQuerySet<T1> &qs, const QXmppResultSetQuery &rsmQuery, QList<T2> &results, QXmppResultSetReply &rsmReply)
{
// if count was requested, stop here
if (rsmQuery.max() == 0) {
rsmReply.setCount(qs.count());
return;
}
rsmReply.setCount(qs.size());
T1 result;
if (rsmQuery.before().isNull()) {
// page forwards
bool rsmAfterReached = rsmQuery.after().isEmpty();
for (int i = 0; i < qs.size(); ++i) {
if (rsmQuery.max() >= 0 && results.size() >= rsmQuery.max())
break;
// fetch from database
if (!qs.at(i, &result))
break;
const QString uid = result.pk().toString();
// if an "after" was specified, check it was reached
if (!rsmAfterReached) {
if (uid == rsmQuery.after())
rsmAfterReached = true;
continue;
}
if (results.isEmpty()) {
rsmReply.setFirst(uid);
rsmReply.setIndex(i);
}
rsmReply.setLast(uid);
results << result;
}
} else {
// page backwards
bool rsmBeforeReached = rsmQuery.before().isEmpty();
for (int i = qs.size() - 1; i >= 0; --i) {
if (rsmQuery.max() >= 0 && results.size() >= rsmQuery.max())
break;
// fetch from database
if (!qs.at(i, &result))
break;
const QString uid = result.pk().toString();
// if a "before" was specified, check it was reached
if (!rsmBeforeReached) {
if (uid == rsmQuery.before())
rsmBeforeReached = true;
continue;
}
if (results.isEmpty())
rsmReply.setLast(uid);
rsmReply.setFirst(uid);
rsmReply.setIndex(i);
results.prepend(result);
}
}
}