本文整理汇总了C++中StringSet::add方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSet::add方法的具体用法?C++ StringSet::add怎么用?C++ StringSet::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
bool TellicoZipExporter::exec() {
m_cancelled = false;
Data::CollPtr coll = collection();
if(!coll) {
return false;
}
// TODO: maybe need label?
ProgressItem& item = ProgressManager::self()->newProgressItem(this, QString(), true);
item.setTotalSteps(100);
connect(&item, SIGNAL(signalCancelled(ProgressItem*)), SLOT(slotCancel()));
ProgressItem::Done done(this);
TellicoXMLExporter exp(coll);
exp.setEntries(entries());
exp.setFields(fields());
exp.setURL(url()); // needed in case of relative URL values
long opt = options();
opt |= Export::ExportUTF8; // always export to UTF-8
opt |= Export::ExportImages; // always list the images in the xml
opt &= ~Export::ExportProgress; // don't show progress for xml export
exp.setOptions(opt);
exp.setIncludeImages(false); // do not include the images themselves in XML
QByteArray xml = exp.exportXML().toByteArray(); // encoded in utf-8
ProgressManager::self()->setProgress(this, 5);
QByteArray data;
QBuffer buf(&data);
if(m_cancelled) {
return true; // intentionally cancelled
}
KZip zip(&buf);
zip.open(QIODevice::WriteOnly);
zip.writeFile(QLatin1String("tellico.xml"), QString(), QString(), xml, xml.size());
if(m_includeImages) {
ProgressManager::self()->setProgress(this, 10);
// gonna be lazy and just increment progress every 3 images
// it might be less, might be more
int j = 0;
const QString imagesDir = QLatin1String("images/");
StringSet imageSet;
Data::FieldList imageFields = coll->imageFields();
// take intersection with the fields to be exported
imageFields = QSet<Data::FieldPtr>::fromList(imageFields).intersect(fields().toSet()).toList();
// already took 10%, only 90% left
const int stepSize = qMax(1, (coll->entryCount() * imageFields.count()) / 90);
foreach(Data::EntryPtr entry, entries()) {
if(m_cancelled) {
break;
}
foreach(Data::FieldPtr imageField, imageFields) {
const QString id = entry->field(imageField);
if(id.isEmpty() || imageSet.has(id)) {
continue;
}
const Data::ImageInfo& info = ImageFactory::imageInfo(id);
if(info.linkOnly) {
myLog() << "not copying linked image: " << id;
continue;
}
const Data::Image& img = ImageFactory::imageById(id);
// if no image, continue
if(img.isNull()) {
myWarning() << "no image found for " << imageField->title() << " field";
myWarning() << "...for the entry titled " << entry->title();
continue;
}
QByteArray ba = img.byteArray();
// myDebug() << "adding image id = " << it->field(fIt);
zip.writeFile(imagesDir + id, QString(), QString(), ba, ba.size());
imageSet.add(id);
if(j%stepSize == 0) {
ProgressManager::self()->setProgress(this, qMin(10+j/stepSize, 99));
kapp->processEvents();
}
++j;
}
}
} else {