本文整理汇总了C++中qMakePair函数的典型用法代码示例。如果您正苦于以下问题:C++ qMakePair函数的具体用法?C++ qMakePair怎么用?C++ qMakePair使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qMakePair函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readOverrideOrders
void VersionBuilder::readInstancePatches()
{
PatchOrder userOrder;
readOverrideOrders(m_instance, userOrder);
QDir patches(instance_root.absoluteFilePath("patches/"));
// first, load things by sort order.
for (auto id : userOrder)
{
// ignore builtins
if (id == "net.minecraft")
continue;
if (id == "org.lwjgl")
continue;
// parse the file
QString filename = patches.absoluteFilePath(id + ".json");
QFileInfo finfo(filename);
if(!finfo.exists())
{
QLOG_INFO() << "Patch file " << filename << " was deleted by external means...";
continue;
}
QLOG_INFO() << "Reading" << filename << "by user order";
auto file = parseJsonFile(finfo, false);
// sanity check. prevent tampering with files.
if (file->fileId != id)
{
throw VersionBuildError(
QObject::tr("load id %1 does not match internal id %2").arg(id, file->fileId));
}
m_version->VersionPatches.append(file);
}
// now load the rest by internal preference.
QMap<int, QPair<QString, VersionFilePtr>> files;
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
{
// parse the file
QLOG_INFO() << "Reading" << info.fileName();
auto file = parseJsonFile(info, true);
// ignore builtins
if (file->fileId == "net.minecraft")
continue;
if (file->fileId == "org.lwjgl")
continue;
// do not load what we already loaded in the first pass
if (userOrder.contains(file->fileId))
continue;
if (files.contains(file->order))
{
// FIXME: do not throw?
throw VersionBuildError(QObject::tr("%1 has the same order as %2")
.arg(file->fileId, files[file->order].second->fileId));
}
files.insert(file->order, qMakePair(info.fileName(), file));
}
for (auto order : files.keys())
{
auto &filePair = files[order];
m_version->VersionPatches.append(filePair.second);
}
}
示例2: qDebug
void BSClient::replySeriesGenresFinished()
{
qDebug() << "BSClient::replySeriesGenresFinished()";
QByteArray byteArray = m_reply->readAll();
if(isCaptcha(byteArray))
{
loadSeriesGenres();
return;
}
QJsonDocument document = QJsonDocument::fromJson(byteArray);
if(!document.isObject())
{
Q_EMIT error(tr("JSON-Parse-Fehler: 0x0007"));
return;
}
QHash<QString, QList<QPair<int, QString> > > seriesCategories;
QJsonObject object = document.object();
for(QJsonObject::const_iterator iter = object.constBegin();
iter != object.constEnd();
iter++)
{
if(!iter.value().isObject())
{
qDebug() << iter.value();
Q_EMIT error(tr("JSON-Parse-Fehler: 0x0008"));
return;
}
QJsonObject object_ = iter.value().toObject();
if(!object_.contains("series"))
{
Q_EMIT error(tr("JSON-Parse-Fehler: 0x0009"));
return;
}
QJsonValue value = object_.value("series");
if(!value.isArray())
{
Q_EMIT error(tr("JSON-Parse-Fehler: 0x000A"));
return;
}
QList<QPair<int, QString> > series;
QJsonArray array = iter.value().toArray();
Q_FOREACH(const QJsonValue &value_, value.toArray())
{
if(!value_.isObject())
{
Q_EMIT error(tr("JSON-Parse-Fehler: 0x000B"));
return;
}
QJsonObject object__ = value_.toObject();
if(!object__.contains("name"))
{
Q_EMIT error(tr("JSON-Parse-Fehler: 0x000C"));
return;
}
QJsonValue idValue = object__.value("id");
if(!idValue.isDouble())
{
Q_EMIT error(tr("JSON-Parse-Fehler: 0x000D"));
return;
}
QJsonValue nameValue = object__.value("name");
if(!nameValue.isString())
{
Q_EMIT error(tr("JSON-Parse-Fehler: 0x000E"));
return;
}
series << qMakePair(idValue.toInt(), nameValue.toString());
}
seriesCategories.insert(iter.key(), series);
}
Q_EMIT loadSeriesGenresFinished(seriesCategories);
}
示例3: dispatcher
void TWebSocketWorker::execute(int opcode, const QByteArray &payload)
{
bool sendTask = false;
QString es = TUrlRoute::splitPath(_requestPath).value(0).toLower() + "endpoint";
TDispatcher<TWebSocketEndpoint> dispatcher(es);
TWebSocketEndpoint *endpoint = dispatcher.object();
if (!endpoint) {
return;
}
try {
tSystemDebug("Found endpoint: %s", qPrintable(es));
tSystemDebug("TWebSocketWorker opcode: %d", opcode);
endpoint->sessionStore = _socket->session(); // Sets websocket session
endpoint->uuid = _socket->socketUuid();
// Database Transaction
setTransactionEnabled(endpoint->transactionEnabled());
switch (_mode) {
case Opening: {
bool res = endpoint->onOpen(_httpSession);
if (res) {
// For switch response
endpoint->taskList.prepend(qMakePair((int)TWebSocketEndpoint::OpenSuccess, QVariant()));
if (endpoint->keepAliveInterval() > 0) {
endpoint->startKeepAlive(endpoint->keepAliveInterval());
}
} else {
endpoint->taskList.prepend(qMakePair((int)TWebSocketEndpoint::OpenError, QVariant()));
}
break; }
case Closing:
if (!_socket->closing.exchange(true)) {
endpoint->onClose(Tf::GoingAway);
endpoint->unsubscribeFromAll();
}
break;
case Receiving: {
switch (opcode) {
case TWebSocketFrame::TextFrame:
endpoint->onTextReceived(QString::fromUtf8(payload));
break;
case TWebSocketFrame::BinaryFrame:
endpoint->onBinaryReceived(payload);
break;
case TWebSocketFrame::Close: {
quint16 closeCode = Tf::GoingAway;
if (payload.length() >= 2) {
QDataStream ds(payload);
ds.setByteOrder(QDataStream::BigEndian);
ds >> closeCode;
}
if (!_socket->closing.exchange(true)) {
endpoint->onClose(closeCode);
endpoint->unsubscribeFromAll();
}
endpoint->close(closeCode); // close response or disconnect
break; }
case TWebSocketFrame::Ping:
endpoint->onPing(payload);
break;
case TWebSocketFrame::Pong:
endpoint->onPong(payload);
break;
default:
tSystemWarn("Invalid opcode: 0x%x [%s:%d]", (int)opcode, __FILE__, __LINE__);
break;
}
break; }
default:
break;
}
// Sets session to the websocket
_socket->setSession(endpoint->session());
for (auto &p : endpoint->taskList) {
const QVariant &taskData = p.second;
switch (p.first) {
case TWebSocketEndpoint::OpenSuccess:
_socket->sendHandshakeResponse();
break;
case TWebSocketEndpoint::OpenError:
_socket->closing = true;
_socket->closeSent = true;
//.........这里部分代码省略.........
示例4: formatbytea
int PaymentechProcessor::buildCommon(QString & pordernum, const int pccardid, const int pcvv, const double pamount, const int /*pcurrid*/, QString &prequest, QString pordertype, const QString & pAuthcode, const QString & pRespdate)
{
XSqlQuery anq;
anq.prepare(
"SELECT ccard_active,"
" formatbytea(decrypt(setbytea(ccard_number), setbytea(:key),'bf')) AS ccard_number,"
" formatccnumber(decrypt(setbytea(ccard_number),setbytea(:key),'bf')) AS ccard_number_x,"
" formatbytea(decrypt(setbytea(ccard_name), setbytea(:key),'bf')) AS ccard_name,"
" formatbytea(decrypt(setbytea(ccard_address1), setbytea(:key),'bf')) AS ccard_address1,"
" formatbytea(decrypt(setbytea(ccard_address2), setbytea(:key),'bf')) AS ccard_address2,"
" formatbytea(decrypt(setbytea(ccard_city), setbytea(:key),'bf')) AS ccard_city,"
" formatbytea(decrypt(setbytea(ccard_state), setbytea(:key),'bf')) AS ccard_state,"
" formatbytea(decrypt(setbytea(ccard_zip), setbytea(:key),'bf')) AS ccard_zip,"
" formatbytea(decrypt(setbytea(ccard_country), setbytea(:key),'bf')) AS ccard_country,"
" formatbytea(decrypt(setbytea(ccard_month_expired),setbytea(:key),'bf')) AS ccard_month_expired,"
" formatbytea(decrypt(setbytea(ccard_year_expired),setbytea(:key), 'bf')) AS ccard_year_expired,"
" ccard_type,"
" custinfo.* "
" FROM ccard, custinfo "
"WHERE ((ccard_id=:ccardid)"
" AND (ccard_cust_id=cust_id));");
anq.bindValue(":ccardid", pccardid);
anq.bindValue(":key", omfgThis->_key);
anq.exec();
if (anq.first())
{
if (!anq.value("ccard_active").toBool())
{
_errorMsg = errorMsg(-10);
return -10;
}
}
else if (anq.lastError().type() != QSqlError::NoError)
{
_errorMsg = anq.lastError().databaseText();
return -1;
}
else
{
_errorMsg = errorMsg(-17).arg(pccardid);
return -17;
}
_extraHeaders.clear();
_extraHeaders.append(qMakePair(QString("Stateless-Transaction"), QString("true")));
_extraHeaders.append(qMakePair(QString("Auth-MID"), QString(_metricsenc->value("CCPTDivisionNumber").rightJustified(10, '0', true))));
_extraHeaders.append(qMakePair(QString("Auth-User"), QString(_metricsenc->value("CCLogin"))));
_extraHeaders.append(qMakePair(QString("Auth-Password"), QString(_metricsenc->value("CCPassword"))));
_extraHeaders.append(qMakePair(QString("Content-type"), QString("SALEM05210/SLM")));
prequest = "P74V";
prequest += pordernum.leftJustified(22, ' ', true);
QString ccardType = anq.value("ccard_type").toString();
if("V" == ccardType) // Visa
ccardType = "VI";
else if("M" == ccardType) // Master Card
ccardType = "MC";
else if("A" == ccardType) // American Express
ccardType = "AX";
else if("D" == ccardType) // Discover
ccardType = "DI";
else if("P" == ccardType) // PayPal
ccardType = "PY";
else
{
_errorMsg = errorMsg(-209);
return -209;
}
prequest += ccardType;
prequest += anq.value("ccard_number").toString().leftJustified(19, ' ', true);
QString work_month;
work_month.setNum(anq.value("ccard_month_expired").toDouble());
if (work_month.length() == 1)
work_month = "0" + work_month;
prequest += work_month + anq.value("ccard_year_expired").toString().right(2);
prequest += _metricsenc->value("CCPTDivisionNumber").rightJustified(10, '0', true);
double shiftedAmt = pamount * 100.0;
int amount = (int)shiftedAmt;
prequest += QString::number(amount).rightJustified(12, '0', true);
// TODO: this needs to be changed to support non-us
prequest += "840"; // CurrencyCode: U.S. Dollars
prequest += "7"; // TransactionType: 1 - single trans over mail/phone card holder not present, 7 - e-commerce
prequest += " "; // EncryptionFlag, PaymentIndicator: both optional not using
prequest += pordertype; // ActionCode 2 digit
prequest += " "; // Reserved
if(pordertype == "AU")
{
// Bill To Address Information
//.........这里部分代码省略.........
示例5: qMakePair
void QSparqlQueryModelPrivate::findRoleNames()
{
QString queryString = query.preparedQueryText().simplified();
roleNames.clear();
QList<QString> uniqueNames;
bool processLoop = true;
bool process = false;
int firstPosition = 0;
int deletePosition = 0;
QChar closeChar;
QChar openChar;
QList<QPair<QLatin1Char, QLatin1Char> > bracketMatch;
bracketMatch.append( qMakePair( QLatin1Char('('), QLatin1Char(')') ) );
bracketMatch.append( qMakePair( QLatin1Char('{'), QLatin1Char('}') ) );
bracketMatch.append( qMakePair( QLatin1Char('"'), QLatin1Char('"') ) );
bracketMatch.append( qMakePair( QLatin1Char('\''), QLatin1Char('\'') ) );
// check query is valid, will ensure we don't get stuck in the loop
if ( queryString.count(QLatin1Char('(')) == queryString.count(QLatin1Char(')'))
&& queryString.count(QLatin1Char('{')) == queryString.count(QLatin1Char('}'))
&& queryString.count(QLatin1Char('"')) % 2 == 0
&& queryString.count(QLatin1Char('\'')) % 2 == 0 )
{
// first remove any, potentially nested, brackets
while (processLoop) {
if (!process) {
for (int i = 0; i < bracketMatch.size(); ++i) {
firstPosition = queryString.indexOf( bracketMatch.at(i).first );
if (firstPosition != -1) {
openChar = bracketMatch.at(i).first;
closeChar = bracketMatch.at(i).second;
deletePosition = firstPosition;
break;
}
}
}
if (firstPosition != -1) {
process = true;
int openCount = 0;
int closeCount = 0;
// go to the first close, count how many opens, repeat until they match
// then delete!
do {
deletePosition = queryString.indexOf(closeChar, deletePosition+1);
openCount = queryString.left(deletePosition).count(openChar);
if(deletePosition != -1)
closeCount++;
} while (closeCount != openCount);
queryString.remove(firstPosition, (deletePosition-firstPosition)+1);
firstPosition = 0;
closeCount = 0;
process = false;
} else {
processLoop = false;
}
}
QStringList stringList = queryString.split(QLatin1Char(' '));
Q_FOREACH(QString word, stringList) {
if ((word.at(0) == QLatin1Char('?') || word.at(0) == QLatin1Char('$'))
&& (!word.contains(QLatin1Char(';')) && !word.contains(QLatin1Char(':')))) {
//remove the ? or $
word.remove(0,1);
// select ?u{?u a ... is valid, need to make sure
// this is dealt with
if (word.contains(QLatin1Char('{'))) {
word = word.split(QLatin1Char('{')).at(0);
}
QRegExp cleanUp(QLatin1String("[,]|[{]|[}]|[.]"));
word.replace(cleanUp,QLatin1String(""));
if (!uniqueNames.contains(word)) {
uniqueNames.append(word);
}
}
}
int roleCounter = Qt::UserRole + 1;
Q_FOREACH(QString word, uniqueNames) {
roleNames[roleCounter++] = word.toLatin1();
}
q->setRoleNames(roleNames);
} else {
示例6: PrimitiveScriptClass
EnumScriptClass::EnumScriptClass(QScriptEngine* engine, ScriptHandlerInfo* handlerInfo)
: PrimitiveScriptClass(engine, handlerInfo)
{
s_values = engine->toStringHandle(ParserStrings::PROPERTY_ENUM_VALUES);
mIterableProperties.append(qMakePair(s_values, QScriptValue::PropertyFlags(QScriptValue::Undeletable)));
}
示例7: toolChain
KitInformation::ItemList ToolChainKitInformation::toUserOutput(Kit *k) const
{
ToolChain *tc = toolChain(k);
return ItemList() << qMakePair(tr("Compiler"), tc ? tc->displayName() : tr("None"));
}
示例8: ItemList
KitInformation::ItemList SysRootKitInformation::toUserOutput(Kit *k) const
{
return ItemList() << qMakePair(tr("Sys Root"), sysRoot(k).toUserOutput());
}
示例9: Q_D
//.........这里部分代码省略.........
break;
// The following keys are properties and settings that are supported by the PDF PrintEngine
case PPK_CollateCopies:
ret = d->collate;
break;
case PPK_ColorMode:
ret = d->grayscale ? QPrinter::GrayScale : QPrinter::Color;
break;
case PPK_Creator:
ret = d->creator;
break;
case PPK_DocumentName:
ret = d->title;
break;
case PPK_FullPage:
ret = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
break;
case PPK_CopyCount:
ret = d->copies;
break;
case PPK_SupportsMultipleCopies:
ret = false;
break;
case PPK_NumberOfCopies:
ret = d->copies;
break;
case PPK_Orientation:
ret = d->m_pageLayout.orientation();
break;
case PPK_OutputFileName:
ret = d->outputFileName;
break;
case PPK_PageOrder:
ret = d->pageOrder;
break;
case PPK_PageSize:
ret = d->m_pageLayout.pageSize().id();
break;
case PPK_PaperName:
ret = d->m_pageLayout.pageSize().name();
break;
case PPK_WindowsPageSize:
ret = d->m_pageLayout.pageSize().windowsId();
break;
case PPK_PaperSource:
ret = d->paperSource;
break;
case PPK_PrinterName:
ret = d->printerName;
break;
case PPK_PrinterProgram:
ret = d->printProgram;
break;
case PPK_Resolution:
ret = d->resolution;
break;
case PPK_SupportedResolutions:
ret = QList<QVariant>() << 72;
break;
case PPK_PaperRect:
ret = d->m_pageLayout.fullRectPixels(d->resolution);
break;
case PPK_PageRect:
ret = d->m_pageLayout.paintRectPixels(d->resolution);
break;
case PPK_SelectionOption:
ret = d->selectionOption;
break;
case PPK_FontEmbedding:
ret = d->embedFonts;
break;
case PPK_Duplex:
ret = d->duplex;
break;
case PPK_CustomPaperSize:
ret = d->m_pageLayout.fullRectPoints().size();
break;
case PPK_PageMargins: {
QList<QVariant> list;
QMarginsF margins = d->m_pageLayout.margins(QPageLayout::Point);
list << margins.left() << margins.top() << margins.right() << margins.bottom();
ret = list;
break;
}
case PPK_QPageSize:
ret.setValue(d->m_pageLayout.pageSize());
break;
case PPK_QPageMargins: {
QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(d->m_pageLayout.margins(), d->m_pageLayout.units());
ret.setValue(pair);
break;
}
case PPK_QPageLayout:
ret.setValue(d->m_pageLayout);
break;
// No default so that compiler will complain if new keys added and not handled in this engine
}
return ret;
}
示例10: while
void MainWindow::openFile(const QString& fileName, int line)
{
bool isStarted = false;
for (int i = 0; i < fileAssociations_.size(); ++i)
{
QString extension = fileAssociations_[i][0];
QString application = fileAssociations_[i][1];
QString arguments = fileAssociations_[i][2];
if (extension.startsWith(".") == false)
extension = "." + extension;
if (fileName.endsWith(extension) == true)
{
// find [] pairs
QList<QPair<int, int> > optionals;
int from = 0;
while (true)
{
int open = arguments.indexOf('[', from);
if (open == -1)
break;
int close = arguments.indexOf(']', open + 1);
if (close == -1)
break;
optionals.push_back(qMakePair(open, close));
from = close + 1;
}
if (line != -1)
{
while (true)
{
int index = arguments.indexOf("<line>");
if (index == -1)
break;
// optional?
int open = arguments.lastIndexOf('[', index);
int close = arguments.indexOf(']', index);
if (open == -1 || close == -1)
{
// not optional
arguments.replace(index, 6, QString::number(line));
}
else
{
// optional
arguments.remove(close, 1);
arguments.replace(index, 6, QString::number(line));
arguments.remove(open, 1);
}
}
}
else
{
while (true)
{
int index = arguments.indexOf("<line>");
if (index == -1)
break;
// optional?
int open = arguments.lastIndexOf('[', index);
int close = arguments.indexOf(']', index);
if (open == -1 || close == -1)
{
// not optional
arguments.remove(index, 6);
}
else
{
// optional
arguments.remove(open, close - open + 1);
}
}
}
QString proc = "\"" + application + "\"" + " " + "\"" + fileName + "\"";
QString proc_arg = "\"" + application + "\"" + " " + "\"" + fileName + "\"" + " " + arguments;
#ifdef Q_OS_MAC
if (QFileInfo(application).suffix().toLower() == "app")
{
QProcess::startDetached("open -a " + proc);
}
else
{
QProcess::startDetached(proc_arg);
}
#else
QProcess::startDetached(proc_arg);
#endif
//.........这里部分代码省略.........
示例11: buddyProperty
QFormBuilderStrings::QFormBuilderStrings() :
buddyProperty(QLatin1String("buddy")),
cursorProperty(QLatin1String("cursor")),
objectNameProperty(QLatin1String("objectName")),
trueValue(QLatin1String("true")),
falseValue(QLatin1String("false")),
horizontalPostFix(QLatin1String("Horizontal")),
separator(QLatin1String("separator")),
defaultTitle(QLatin1String("Page")),
titleAttribute(QLatin1String("title")),
labelAttribute(QLatin1String("label")),
toolTipAttribute(QLatin1String("toolTip")),
whatsThisAttribute(QLatin1String("whatsThis")),
flagsAttribute(QLatin1String("flags")),
iconAttribute(QLatin1String("icon")),
pixmapAttribute(QLatin1String("pixmap")),
textAttribute(QLatin1String("text")),
currentIndexProperty(QLatin1String("currentIndex")),
toolBarAreaAttribute(QLatin1String("toolBarArea")),
toolBarBreakAttribute(QLatin1String("toolBarBreak")),
dockWidgetAreaAttribute(QLatin1String("dockWidgetArea")),
marginProperty(QLatin1String("margin")),
spacingProperty(QLatin1String("spacing")),
leftMarginProperty(QLatin1String("leftMargin")),
topMarginProperty(QLatin1String("topMargin")),
rightMarginProperty(QLatin1String("rightMargin")),
bottomMarginProperty(QLatin1String("bottomMargin")),
horizontalSpacingProperty(QLatin1String("horizontalSpacing")),
verticalSpacingProperty(QLatin1String("verticalSpacing")),
sizeHintProperty(QLatin1String("sizeHint")),
sizeTypeProperty(QLatin1String("sizeType")),
orientationProperty(QLatin1String("orientation")),
styleSheetProperty(QLatin1String("styleSheet")),
qtHorizontal(QLatin1String("Qt::Horizontal")),
qtVertical(QLatin1String("Qt::Vertical")),
currentRowProperty(QLatin1String("currentRow")),
tabSpacingProperty(QLatin1String("tabSpacing")),
qWidgetClass(QLatin1String("QWidget")),
lineClass(QLatin1String("Line")),
geometryProperty(QLatin1String("geometry")),
scriptWidgetVariable(QLatin1String("widget")),
scriptChildWidgetsVariable(QLatin1String("childWidgets"))
{
itemRoles.append(qMakePair(Qt::FontRole, QString::fromLatin1("font")));
itemRoles.append(qMakePair(Qt::TextAlignmentRole, QString::fromLatin1("textAlignment")));
itemRoles.append(qMakePair(Qt::BackgroundRole, QString::fromLatin1("background")));
itemRoles.append(qMakePair(Qt::ForegroundRole, QString::fromLatin1("foreground")));
itemRoles.append(qMakePair(Qt::CheckStateRole, QString::fromLatin1("checkState")));
foreach (const RoleNName &it, itemRoles)
treeItemRoleHash.insert(it.second, it.first);
itemTextRoles.append(qMakePair(qMakePair(Qt::EditRole, Qt::DisplayPropertyRole),
textAttribute)); // This must be first for the loop below
itemTextRoles.append(qMakePair(qMakePair(Qt::ToolTipRole, Qt::ToolTipPropertyRole),
toolTipAttribute));
itemTextRoles.append(qMakePair(qMakePair(Qt::StatusTipRole, Qt::StatusTipPropertyRole),
QString::fromLatin1("statusTip")));
itemTextRoles.append(qMakePair(qMakePair(Qt::WhatsThisRole, Qt::WhatsThisPropertyRole),
whatsThisAttribute));
// Note: this skips the first item!
QList<TextRoleNName>::const_iterator it = itemTextRoles.constBegin(), end = itemTextRoles.constEnd();
while (++it != end)
treeItemTextRoleHash.insert(it->second, it->first);
}
示例12: createExpressionContext
int QgsAtlasComposition::updateFeatures()
{
//needs to be called when layer, filter, sort changes
if ( !mCoverageLayer )
{
return 0;
}
QgsExpressionContext expressionContext = createExpressionContext();
updateFilenameExpression();
// select all features with all attributes
QgsFeatureRequest req;
QScopedPointer<QgsExpression> filterExpression;
if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
{
filterExpression.reset( new QgsExpression( mFeatureFilter ) );
if ( filterExpression->hasParserError() )
{
mFilterParserError = filterExpression->parserErrorString();
return 0;
}
//filter good to go
req.setFilterExpression( mFeatureFilter );
}
mFilterParserError = QString();
QgsFeatureIterator fit = mCoverageLayer->getFeatures( req );
QScopedPointer<QgsExpression> nameExpression;
if ( !mPageNameExpression.isEmpty() )
{
nameExpression.reset( new QgsExpression( mPageNameExpression ) );
if ( nameExpression->hasParserError() )
{
nameExpression.reset( nullptr );
}
nameExpression->prepare( &expressionContext );
}
// We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process
// We thus store the feature ids for future extraction
QgsFeature feat;
mFeatureIds.clear();
mFeatureKeys.clear();
int sortIdx = mCoverageLayer->fieldNameIndex( mSortKeyAttributeName );
while ( fit.nextFeature( feat ) )
{
expressionContext.setFeature( feat );
QString pageName;
if ( !nameExpression.isNull() )
{
QVariant result = nameExpression->evaluate( &expressionContext );
if ( nameExpression->hasEvalError() )
{
QgsMessageLog::logMessage( tr( "Atlas name eval error: %1" ).arg( nameExpression->evalErrorString() ), tr( "Composer" ) );
}
pageName = result.toString();
}
mFeatureIds.push_back( qMakePair( feat.id(), pageName ) );
if ( mSortFeatures && sortIdx != -1 )
{
mFeatureKeys.insert( feat.id(), feat.attributes().at( sortIdx ) );
}
}
// sort features, if asked for
if ( !mFeatureKeys.isEmpty() )
{
FieldSorter sorter( mFeatureKeys, mSortAscending );
qSort( mFeatureIds.begin(), mFeatureIds.end(), sorter );
}
emit numberFeaturesChanged( mFeatureIds.size() );
//jump to first feature if currently using an atlas preview
//need to do this in case filtering/layer change has altered matching features
if ( mComposition->atlasMode() == QgsComposition::PreviewAtlas )
{
firstFeature();
}
return mFeatureIds.size();
}
示例13: qMakePair
PropertySheetPixmapValue PropertySheetIconValue::pixmap(QIcon::Mode mode, QIcon::State state) const
{
const ModeStateKey pair = qMakePair(mode, state);
return m_data->m_paths.value(pair);
}
示例14: addByteArray
void AbstractStructureParser::addByteArray(const QLatin1String &name, QByteArray *str)
{
m_byteArrays.append(qMakePair(name, str));
}
示例15: qMakePair
void ConfigWidgetProxy::createProjectConfigPage( QString const & title, unsigned int pagenumber, QString const & icon )
{
_projectTitleMap.insert( pagenumber, qMakePair( title, icon ) );
}