本文整理汇总了C++中item::List::count方法的典型用法代码示例。如果您正苦于以下问题:C++ List::count方法的具体用法?C++ List::count怎么用?C++ List::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item::List
的用法示例。
在下文中一共展示了List::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qCDebug
void RetrieveItemsJob::Private::akonadiFetchResult(KJob *job)
{
if (job->error() != 0) {
return; // handled by base class
}
ItemFetchJob *itemFetch = qobject_cast<ItemFetchJob *>(job);
Q_ASSERT(itemFetch != 0);
Item::List items = itemFetch->items();
itemFetch->clearItems(); // save memory
qCDebug(MIXEDMAILDIR_LOG) << "Akonadi fetch got" << items.count() << "items";
mServerItemsByRemoteId.reserve(items.size());
for (int i = 0; i < items.count(); ++i) {
Item &item = items[i];
// items without remoteId have not been written to the resource yet
if (!item.remoteId().isEmpty()) {
// set the parent collection (with all ancestors) in every item
item.setParentCollection(mCollection);
mServerItemsByRemoteId.insert(item.remoteId(), item);
}
}
qCDebug(MIXEDMAILDIR_LOG) << "of which" << mServerItemsByRemoteId.count() << "have remoteId";
FileStore::ItemFetchJob *storeFetch = mStore->fetchItems(mCollection);
// just basic items, no data
connect(storeFetch, SIGNAL(result(KJob*)), q, SLOT(storeListResult(KJob*)));
}
示例2: onItemsFetched
void InfoCommand::onItemsFetched(KJob *job)
{
if (job->error() != 0) {
emit error(job->errorString());
emit finished(RuntimeError);
return;
}
ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob *>(job);
Q_ASSERT(fetchJob!=0);
Item::List items = fetchJob->items();
if (items.count()<1)
{
emit error(i18nc("@info:shell", "Cannot find '%1' as a collection or item", mEntityArg));
emit finished(RuntimeError);
return;
}
mInfoItem = new Item(items.first());
fetchParentPath(mInfoItem->parentCollection());
}
示例3: constantPropagate
Expression::Ptr Expression::constantPropagate(const StaticContext::Ptr &context) const
{
Q_ASSERT(context);
/* Optimization: We rewrite literals to literals here, which is pointless.
* Maybe we should have a property which says "doesn't disable elimination
* but don't eliminate me." */
if(staticType()->cardinality().allowsMany())
{
Item::Iterator::Ptr it(evaluateSequence(context->dynamicContext()));
Item::List result;
Item item(it->next());
while(item)
{
result.append(item);
item = it->next();
}
switch(result.count())
{
case 0:
return EmptySequence::create(this, context);
case 1:
return rewrite(Expression::Ptr(new Literal(result.first())), context);
default:
return rewrite(Expression::Ptr(new LiteralSequence(result)), context);
}
}
else
{
const Item item(evaluateSingleton(context->dynamicContext()));
if(item)
return rewrite(Expression::Ptr(new Literal(item)), context);
else
return EmptySequence::create(this, context);
}
}
示例4: updateState
void ActionStateManager::updateState(const Collection::List &collections, const Item::List &items)
{
const int collectionCount = collections.count();
const bool singleCollectionSelected = (collectionCount == 1);
const bool multipleCollectionsSelected = (collectionCount > 1);
const bool atLeastOneCollectionSelected = (singleCollectionSelected || multipleCollectionsSelected);
const int itemCount = items.count();
const bool singleItemSelected = (itemCount == 1);
const bool multipleItemsSelected = (itemCount > 1);
const bool atLeastOneItemSelected = (singleItemSelected || multipleItemsSelected);
const bool listOfCollectionNotEmpty = collections.isEmpty() ? false : true;
bool canDeleteCollections = listOfCollectionNotEmpty;
if (canDeleteCollections) {
foreach (const Collection &collection, collections) {
// do we have the necessary rights?
if (!(collection.rights() &Collection::CanDeleteCollection)) {
canDeleteCollections = false;
break;
}
if (isRootCollection(collection)) {
canDeleteCollections = false;
break;
}
if (isResourceCollection(collection)) {
canDeleteCollections = false;
break;
}
}
}
bool canCutCollections = canDeleteCollections; // we must be able to delete for cutting
foreach (const Collection &collection, collections) {
if (isSpecialCollection(collection)) {
canCutCollections = false;
break;
}
if (!isFolderCollection(collection)) {
canCutCollections = false;
break;
}
}
const bool canMoveCollections = canCutCollections; // we must be able to cut for moving
bool canCopyCollections = listOfCollectionNotEmpty;
if (canCopyCollections) {
foreach (const Collection &collection, collections) {
if (isRootCollection(collection)) {
canCopyCollections = false;
break;
}
if (!isFolderCollection(collection)) {
canCopyCollections = false;
break;
}
}
}
bool canAddToFavoriteCollections = listOfCollectionNotEmpty;
if (canAddToFavoriteCollections) {
foreach (const Collection &collection, collections) {
if (isRootCollection(collection)) {
canAddToFavoriteCollections = false;
break;
}
if (isFavoriteCollection(collection)) {
canAddToFavoriteCollections = false;
break;
}
if (!isFolderCollection(collection)) {
canAddToFavoriteCollections = false;
break;
}
if (!canContainItems(collection)) {
canAddToFavoriteCollections = false;
break;
}
}
}
bool canRemoveFromFavoriteCollections = listOfCollectionNotEmpty;
foreach (const Collection &collection, collections) {
if (!isFavoriteCollection(collection)) {
canRemoveFromFavoriteCollections = false;
break;
}
}
bool collectionsAreFolders = listOfCollectionNotEmpty;
foreach (const Collection &collection, collections) {
if (!isFolderCollection(collection)) {
collectionsAreFolders = false;
//.........这里部分代码省略.........
示例5: testDupes
void DupeTest::testDupes()
{
QFETCH(QString, message);
QFETCH(int, count);
QFETCH(int, delay);
// clean sink
ItemFetchJob *fjob = new ItemFetchJob(sink, this);
AKVERIFYEXEC(fjob);
if (fjob->items().count() > 0) {
// this test is needed because ItemDeleteJob gives error if no items are found
ItemDeleteJob *djob = new ItemDeleteJob(sink, this);
AKVERIFYEXEC(djob);
}
fjob = new ItemFetchJob(sink, this);
AKVERIFYEXEC(fjob);
QCOMPARE(fjob->items().count(), 0);
// queue messages
Q_ASSERT(monitor);
QSignalSpy *addSpy = new QSignalSpy(monitor, SIGNAL(itemAdded(Akonadi::Item,Akonadi::Collection)));
qDebug() << "Queuing" << count << "messages...";
for (int i = 0; i < count; i++) {
//qDebug() << "Queuing message" << i + 1 << "of" << count;
Message::Ptr msg = Message::Ptr(new Message);
msg->setContent(QStringLiteral("%1-msg%2\n").arg(message).arg(i + 1, 2, 10, QLatin1Char('0')).toLatin1());
MessageQueueJob *job = new MessageQueueJob(this);
job->setMessage(msg);
job->transportAttribute().setTransportId(TransportManager::self()->defaultTransportId());
// default dispatch mode
// default sent-mail collection
job->addressAttribute().setFrom(QStringLiteral("naiba"));
job->addressAttribute().setTo(QStringList() << QStringLiteral("dracu"));
//AKVERIFYEXEC( job );
job->start();
QTest::qWait(delay);
}
qDebug() << "Queued" << count << "messages.";
// wait for the MDA to send them
int seconds = 0;
while (true) {
seconds++;
QTest::qWait(1000);
qDebug() << seconds << "seconds elapsed." << addSpy->count() << "messages got to sink.";
if (addSpy->count() >= count) {
break;
}
#if 0
if (seconds >= TIMEOUT_SECONDS) {
qDebug() << "Timeout, gdb master!";
QTest::qWait(1000 * 1000);
}
#endif
QVERIFY2(seconds < TIMEOUT_SECONDS, "Timeout");
}
// TODO I should verify that the MDA has actually finished its work and has an empty queue
QTest::qWait(2000);
// verify what has been sent
fjob = new ItemFetchJob(sink, this);
fjob->fetchScope().fetchFullPayload();
AKVERIFYEXEC(fjob);
const Item::List items = fjob->items();
int found[ MAXCOUNT ];
for (int i = 0; i < count; i++) {
found[i] = 0;
}
for (int i = 0; i < items.count(); i++) {
QVERIFY(items[i].hasPayload<Message::Ptr>());
Message::Ptr msg = items[i].payload<Message::Ptr>();
const QByteArray content = msg->encodedContent();
//qDebug() << "i" << i << "content" << content;
int loc = content.indexOf("-msg");
QVERIFY(loc >= 0);
bool ok;
int who = content.mid(loc + 4, 2).toInt(&ok);
QVERIFY(ok);
//qDebug() << "identified msg" << who;
QVERIFY(who > 0 && who <= count);
found[ who - 1 ]++;
}
for (int i = 0; i < count; i++) {
if (found[i] > 1) {
qDebug() << "found duplicate message" << i + 1 << "(" << found[i] << "times )";
} else if (found[i] < 1) {
qDebug() << "didn't find message" << i + 1;
}
QCOMPARE(found[i], 1);
}
QCOMPARE(addSpy->count(), count);
QCOMPARE(items.count(), count);
}