本文整理汇总了C++中qstringlist::const_iterator::size方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::size方法的具体用法?C++ const_iterator::size怎么用?C++ const_iterator::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstringlist::const_iterator
的用法示例。
在下文中一共展示了const_iterator::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseQualities
Qualities Visualizer::parseQualities(QString raw_qualities)
{
Qualities ret;
QStringList qualities = raw_qualities.split('&');
for(QStringList::const_iterator cqi = qualities.constBegin()
, cqiend = qualities.constEnd(); cqi != cqiend; ++cqi)
if(cqi->size())
{
QStringList key_and_value = cqi->split("=");
QString key = key_and_value.takeFirst();
filter_model_.checkKey(key);
QVariant &value = ret[key];
QString str = key_and_value.join("=");
bool is_double = false;
double d = str.toDouble(&is_double);
value = is_double ? QVariant(d) : QVariant(str);
}
return ret;
}
示例2: parseArguments
CodaClientApplication::ParseArgsResult CodaClientApplication::parseArguments(QString *errorMessage)
{
int argNumber = 1;
const QStringList args = QCoreApplication::arguments();
const QStringList::const_iterator cend = args.constEnd();
QStringList::const_iterator it = args.constBegin();
bool optionsEnd = false;
for (++it; it != cend; ++it) {
if (!optionsEnd && *it == QLatin1String("--")) {
optionsEnd = true;
continue;
}
if (!optionsEnd && it->startsWith(QLatin1Char('-')) && it->size() == 2) {
switch (it->at(1).toAscii()) {
case 'v':
m_verbose++;
break;
case 'd':
m_launchDebug = true;
break;
case 's':
m_installSilently = true;
break;
case 'c':
if (++it == cend) {
*errorMessage = QString::fromLatin1("Parameter missing for -c");
return ParseArgsError;
}
m_putChunkSize = it->toULongLong() * 1024;
if (!m_putChunkSize) {
*errorMessage = QString::fromLatin1("Invalid chunk size.");
return ParseArgsError;
}
break;
default:
*errorMessage = QString::fromLatin1("Invalid option %1").arg(*it);
return ParseArgsError;
}
} else {
if (!parseArgument(*it, argNumber++, errorMessage))
return ParseArgsError;
}
} //for loop
// Basic Check & init
switch (m_mode) {
case Invalid:
return ParseArgsError;
case Launch:
if (m_address.isEmpty() || !m_launchUID || m_launchBinary.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for launch.");
return ParseInitError;
}
break;
case Ping:
if (m_address.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for ping.");
return ParseInitError;
}
if (!isSerialPort(m_address)) {
*errorMessage = QString::fromLatin1("'ping' not supported for TCP/IP.");
return ParseInitError;
}
break;
case Install:
if (m_address.isEmpty() || m_installSisFile.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for install.");
return ParseInitError;
}
break;
case Uninstall:
if (!m_uninstallPackage) {
*errorMessage = QString::fromLatin1("Not enough parameters for uninstall.");
return ParseInitError;
}
break;
case Put: {
if (m_address.isEmpty() || m_putLocalFile.isEmpty() || m_putRemoteFile.isEmpty()) {
*errorMessage = QString::fromLatin1("Not enough parameters for put.");
return ParseInitError;
}
const QFileInfo fi(m_putLocalFile);
if (!fi.isFile() || !fi.isReadable()) {
*errorMessage = QString::fromLatin1("Local file '%1' not readable.").arg(m_putLocalFile);
return ParseInitError;
}
}
break;
default:
break;
}
return ParseArgsOk;
}
示例3: prepareImages
void LocalImageLoaderPrivate::prepareImages() {
QString file, filename, mime, stickerMime = qsl("image/webp");
int32 filesize = 0;
QImage img;
QByteArray data;
PeerId peer;
uint64 id, thumbId = 0;
int32 duration = 0;
QString thumbExt = "jpg";
ToPrepareMediaType type;
bool animated = false;
bool ctrlShiftEnter = false;
MsgId replyTo = 0;
{
QMutexLocker lock(loader->toPrepareMutex());
ToPrepareMedias &list(loader->toPrepareMedias());
if (list.isEmpty()) return;
file = list.front().file;
img = list.front().img;
data = list.front().data;
peer = list.front().peer;
id = list.front().id;
type = list.front().type;
duration = list.front().duration;
ctrlShiftEnter = list.front().ctrlShiftEnter;
replyTo = list.front().replyTo;
}
if (img.isNull()) {
if (!file.isEmpty()) {
QFileInfo info(file);
if (type == ToPrepareAuto) {
QString lower(file.toLower());
const QStringList &photoExtensions(cPhotoExtensions());
for (QStringList::const_iterator i = photoExtensions.cbegin(), e = photoExtensions.cend(); i != e; ++i) {
if (lower.lastIndexOf(*i) == lower.size() - i->size()) {
if (info.size() < MaxUploadPhotoSize) {
type = ToPreparePhoto;
break;
}
}
}
if (type == ToPrepareAuto && info.size() < MaxUploadDocumentSize) {
type = ToPrepareDocument;
}
}
if (type == ToPrepareDocument) {
mime = mimeTypeForFile(info).name();
}
if (type != ToPrepareAuto && info.size() < MaxUploadPhotoSize) {
bool opaque = (mime != stickerMime);
img = App::readImage(file, 0, opaque, &animated);
}
filename = info.fileName();
filesize = info.size();
} else if (!data.isEmpty()) {
if (type != ToPrepareAudio) {
img = App::readImage(data, 0, true, &animated);
if (type == ToPrepareAuto) {
if (!img.isNull() && data.size() < MaxUploadPhotoSize) {
type = ToPreparePhoto;
} else if (data.size() < MaxUploadDocumentSize) {
type = ToPrepareDocument;
} else {
img = QImage();
}
}
}
MimeType mimeType = mimeTypeForData(data);
if (type == ToPrepareDocument || type == ToPrepareAudio) {
mime = mimeType.name();
}
if (mime == "image/jpeg") {
filename = filedialogDefaultName(qsl("image"), qsl(".jpg"), QString(), true);
} else if (type == ToPrepareAudio) {
filename = filedialogDefaultName(qsl("audio"), qsl(".ogg"), QString(), true);
mime = "audio/ogg";
} else {
QString ext;
QStringList patterns = mimeType.globPatterns();
if (!patterns.isEmpty()) {
ext = patterns.front().replace('*', QString());
}
filename = filedialogDefaultName((type == ToPrepareAudio) ? qsl("audio") : qsl("doc"), ext, QString(), true);
}
filesize = data.size();
}
} else {
if (type == ToPrepareDocument) {
filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
mime = mimeTypeForName("image/png").name();
data = QByteArray();
{
QBuffer b(&data);
img.save(&b, "PNG");
}
filesize = data.size();
} else {
if (img.hasAlphaChannel()) {
//.........这里部分代码省略.........
示例4: prepareImages
void LocalImageLoaderPrivate::prepareImages() {
QString file, filename, mime;
int32 filesize = 0;
QImage img;
QByteArray data;
PeerId peer;
uint64 id, jpeg_id = 0;
ToPrepareMediaType type;
{
QMutexLocker lock(loader->toPrepareMutex());
ToPrepareMedias &list(loader->toPrepareMedias());
if (list.isEmpty()) return;
file = list.front().file;
img = list.front().img;
data = list.front().data;
peer = list.front().peer;
id = list.front().id;
type = list.front().type;
}
if (img.isNull()) {
if (!file.isEmpty()) {
QFileInfo info(file);
if (type == ToPrepareAuto) {
QString lower(file.toLower());
const QStringList &photoExtensions(cPhotoExtensions());
for (QStringList::const_iterator i = photoExtensions.cbegin(), e = photoExtensions.cend(); i != e; ++i) {
if (lower.lastIndexOf(*i) == lower.size() - i->size()) {
if (info.size() < MaxUploadPhotoSize) {
type = ToPreparePhoto;
break;
}
}
}
if (type == ToPrepareAuto && info.size() < MaxUploadDocumentSize) {
type = ToPrepareDocument;
}
}
if (type != ToPrepareAuto && info.size() < MaxUploadPhotoSize) {
img = App::readImage(file);
}
if (type == ToPrepareDocument) {
mime = QMimeDatabase().mimeTypeForFile(info).name();
}
filename = info.fileName();
filesize = info.size();
} else if (!data.isEmpty()) {
img = App::readImage(data);
if (type == ToPrepareAuto) {
if (!img.isNull() && data.size() < MaxUploadPhotoSize) {
type = ToPreparePhoto;
} else if (data.size() < MaxUploadDocumentSize) {
type = ToPrepareDocument;
} else {
img = QImage();
}
}
QMimeType mimeType = QMimeDatabase().mimeTypeForData(data);
if (type == ToPrepareDocument) {
mime = mimeType.name();
}
filename = qsl("Document");
QStringList patterns = mimeType.globPatterns();
if (!patterns.isEmpty()) {
filename = patterns.front().replace('*', filename);
}
filesize = data.size();
}
} else {
if (type == ToPrepareDocument) {
filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
QMimeType mimeType = QMimeDatabase().mimeTypeForName("image/png");
data = QByteArray();
{
QBuffer b(&data);
img.save(&b, "PNG");
}
filesize = data.size();
} else {
type = ToPreparePhoto; // only photo from QImage
filename = qsl("Untitled.jpg");
filesize = 0;
}
}
if ((img.isNull() && (type != ToPrepareDocument || !filesize)) || type == ToPrepareAuto || (img.isNull() && file.isEmpty() && data.isEmpty())) { // if could not decide what type
{
QMutexLocker lock(loader->toPrepareMutex());
ToPrepareMedias &list(loader->toPrepareMedias());
list.pop_front();
}
QTimer::singleShot(1, this, SLOT(prepareImages()));
emit imageFailed(id);
} else {
PreparedPhotoThumbs photoThumbs;
QVector<MTPPhotoSize> photoSizes;
//.........这里部分代码省略.........
示例5: parse
bool MatchParser::parse()
{
QStringList::const_iterator it;
for (it = m_args.constBegin(); it != m_args.constEnd(); ++it)
{
if (!m_validOptions.contains(*it))
{
qWarning("Unknown option: \"%s\"", qPrintable(*it));
return false;
}
QString name = *it;
PrivateOption& option = m_validOptions[name];
QStringList list;
while (++it != m_args.constEnd())
{
if (it->size() > 1 && it->startsWith('-'))
{
bool ok = false;
it->toDouble(&ok);
if (!ok)
break;
}
list << *it;
}
--it;
if (!option.duplicates && contains(name))
{
qWarning("Multiple instances of option \"%s\"",
qPrintable(name));
return false;
}
if (list.size() < option.minArgs)
{
if (option.maxArgs == option.minArgs)
qWarning("Option \"%s\" needs %d argument(s)",
qPrintable(name), option.minArgs);
else
qWarning("Option \"%s\" needs at least %d argument(s)",
qPrintable(name), option.minArgs);
return false;
}
if (option.maxArgs != -1 && list.size() > option.maxArgs)
{
qWarning("Too many arguments for option \"%s\"",
qPrintable(name));
return false;
}
// Boolean option
if (list.isEmpty())
{
Option tmp = { name, QVariant(true) };
m_options.insert(option.priority, tmp);
continue;
}
QVariant value;
if (option.type == QVariant::StringList)
value.setValue(list);
else
value.setValue(list.join(" "));
if (!value.convert(option.type))
{
qWarning("Invalid value for option \"%s\": \"%s\"",
qPrintable(name),
qPrintable(list.join(" ")));
return false;
}
Option tmp = { name, value };
m_options.insert(option.priority, tmp);
}
return true;
}