• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ qMakePair函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中qMakePair函数的典型用法代码示例。如果您正苦于以下问题:C++ qMakePair函数的具体用法?C++ qMakePair怎么用?C++ qMakePair使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了qMakePair函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
	}
}
开发者ID:Glought,项目名称:MultiMC5,代码行数:61,代码来源:VersionBuilder.cpp


示例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);
}
开发者ID:Scarwolf,项目名称:Flucky-Downloader,代码行数:95,代码来源:bsclient.cpp


示例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;
//.........这里部分代码省略.........
开发者ID:gaoxiaojun,项目名称:treefrog-framework,代码行数:101,代码来源:twebsocketworker.cpp


示例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
//.........这里部分代码省略.........
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:101,代码来源:paymentechprocessor.cpp


示例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 {
开发者ID:matthewvogt,项目名称:libqtsparql,代码行数:85,代码来源:qsparqlquerymodel.cpp


示例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)));
}
开发者ID:KDE,项目名称:okteta,代码行数:6,代码来源:enumscriptclass.cpp


示例7: toolChain

KitInformation::ItemList ToolChainKitInformation::toUserOutput(Kit *k) const
{
    ToolChain *tc = toolChain(k);
    return ItemList() << qMakePair(tr("Compiler"), tc ? tc->displayName() : tr("None"));
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:5,代码来源:kitinformation.cpp


示例8: ItemList

KitInformation::ItemList SysRootKitInformation::toUserOutput(Kit *k) const
{
    return ItemList() << qMakePair(tr("Sys Root"), sysRoot(k).toUserOutput());
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:4,代码来源:kitinformation.cpp


示例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;
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:101,代码来源:qprintengine_pdf.cpp


示例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

//.........这里部分代码省略.........
开发者ID:dev-life,项目名称:gideros,代码行数:101,代码来源:mainwindow.cpp


示例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);
}
开发者ID:phen89,项目名称:rtqt,代码行数:66,代码来源:formbuilderextra.cpp


示例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();
}
开发者ID:GavrisAS,项目名称:QGIS,代码行数:92,代码来源:qgsatlascomposition.cpp


示例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);
 }
开发者ID:hkahn,项目名称:qt5-qttools-nacl,代码行数:5,代码来源:qdesigner_utils.cpp


示例14: addByteArray

void AbstractStructureParser::addByteArray(const QLatin1String &name, QByteArray *str)
{
	m_byteArrays.append(qMakePair(name, str));
}
开发者ID:NeutronStein,项目名称:jreen,代码行数:4,代码来源:vcardfactory.cpp


示例15: qMakePair

void ConfigWidgetProxy::createProjectConfigPage( QString const & title, unsigned int pagenumber, QString const & icon )
{
	_projectTitleMap.insert( pagenumber, qMakePair( title, icon ) );
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:4,代码来源:configwidgetproxy.cpp


示例16: addString

void AbstractStructureParser::addString(const QLatin1String &name, QString *str)
{
	m_strings.append(qMakePair(name, str));
}
开发者ID:NeutronStein,项目名称:jreen,代码行数:4,代码来源:vcardfactory.cpp


示例17: htmlUnitsToMM

double QgsComposerHtml::findNearbyPageBreak( double yPos )
{
  if ( !mWebPage || !mRenderedPage || !mUseSmartBreaks )
  {
    return yPos;
  }

  //convert yPos to pixels
  int idealPos = yPos * htmlUnitsToMM();

  //if ideal break pos is past end of page, there's nothing we need to do
  if ( idealPos >= mRenderedPage->height() )
  {
    return yPos;
  }

  int maxSearchDistance = mMaxBreakDistance * htmlUnitsToMM();

  //loop through all lines just before ideal break location, up to max distance
  //of maxSearchDistance
  int changes = 0;
  QRgb currentColor;
  bool currentPixelTransparent = false;
  bool previousPixelTransparent = false;
  QRgb pixelColor;
  QList< QPair<int, int> > candidates;
  int minRow = qMax( idealPos - maxSearchDistance, 0 );
  for ( int candidateRow = idealPos; candidateRow >= minRow; --candidateRow )
  {
    changes = 0;
    currentColor = qRgba( 0, 0, 0, 0 );
    //check all pixels in this line
    for ( int col = 0; col < mRenderedPage->width(); ++col )
    {
      //count how many times the pixels change color in this row
      //eventually, we select a row to break at with the minimum number of color changes
      //since this is likely a line break, or gap between table cells, etc
      //but very unlikely to be midway through a text line or picture
      pixelColor = mRenderedPage->pixel( col, candidateRow );
      currentPixelTransparent = qAlpha( pixelColor ) == 0;
      if ( pixelColor != currentColor && !( currentPixelTransparent && previousPixelTransparent ) )
      {
        //color has changed
        currentColor = pixelColor;
        changes++;
      }
      previousPixelTransparent = currentPixelTransparent;
    }
    candidates.append( qMakePair( candidateRow, changes ) );
  }

  //sort candidate rows by number of changes ascending, row number descending
  qSort( candidates.begin(), candidates.end(), candidateSort );
  //first candidate is now the largest row with smallest number of changes

  //ok, now take the mid point of the best candidate position
  //we do this so that the spacing between text lines is likely to be split in half
  //otherwise the html will be broken immediately above a line of text, which
  //looks a little messy
  int maxCandidateRow = candidates[0].first;
  int minCandidateRow = maxCandidateRow + 1;
  int minCandidateChanges = candidates[0].second;

  QList< QPair<int, int> >::iterator it;
  for ( it = candidates.begin(); it != candidates.end(); ++it )
  {
    if (( *it ).second != minCandidateChanges || ( *it ).first != minCandidateRow - 1 )
    {
      //no longer in a consecutive block of rows of minimum pixel color changes
      //so return the row mid-way through the block
      //first converting back to mm
      return ( minCandidateRow + ( maxCandidateRow - minCandidateRow ) / 2 ) / htmlUnitsToMM();
    }
    minCandidateRow = ( *it ).first;
  }

  //above loop didn't work for some reason
  //return first candidate converted to mm
  return candidates[0].first / htmlUnitsToMM();
}
开发者ID:dakcarto,项目名称:QGIS,代码行数:80,代码来源:qgscomposerhtml.cpp


示例18: medianCut

  void medianCut( QVector<QRgb> &colorTable, int nColors, const QImage &inputImage )
  {
    QHash<QRgb, int> inputColors;
    imageColors( inputColors, inputImage );

    if ( inputColors.size() <= nColors ) //all the colors in the image can be mapped to one palette color
    {
      colorTable.resize( inputColors.size() );
      int index = 0;
      for ( auto inputColorIt = inputColors.constBegin(); inputColorIt != inputColors.constEnd(); ++inputColorIt )
      {
        colorTable[index] = inputColorIt.key();
        ++index;
      }
      return;
    }

    //create first box
    QgsColorBox firstBox; //QList< QPair<QRgb, int> >
    int firstBoxPixelSum = 0;
    for ( auto  inputColorIt = inputColors.constBegin(); inputColorIt != inputColors.constEnd(); ++inputColorIt )
    {
      firstBox.push_back( qMakePair( inputColorIt.key(), inputColorIt.value() ) );
      firstBoxPixelSum += inputColorIt.value();
    }

    QgsColorBoxMap colorBoxMap; //QMultiMap< int, ColorBox >
    colorBoxMap.insert( firstBoxPixelSum, firstBox );
    QMap<int, QgsColorBox>::iterator colorBoxMapIt = colorBoxMap.end();

    //split boxes until number of boxes == nColors or all the boxes have color count 1
    bool allColorsMapped = false;
    while ( colorBoxMap.size() < nColors )
    {
      //start at the end of colorBoxMap and pick the first entry with number of colors < 1
      colorBoxMapIt = colorBoxMap.end();
      while ( true )
      {
        --colorBoxMapIt;
        if ( colorBoxMapIt.value().size() > 1 )
        {
          splitColorBox( colorBoxMapIt.value(), colorBoxMap, colorBoxMapIt );
          break;
        }
        if ( colorBoxMapIt == colorBoxMap.begin() )
        {
          allColorsMapped = true;
          break;
        }
      }

      if ( allColorsMapped )
      {
        break;
      }
    }

    //get representative colors for the boxes
    int index = 0;
    colorTable.resize( colorBoxMap.size() );
    for ( auto colorBoxIt = colorBoxMap.constBegin(); colorBoxIt != colorBoxMap.constEnd(); ++colorBoxIt )
    {
      colorTable[index] = boxColor( colorBoxIt.value(), colorBoxIt.key() );
      ++index;
    }
  }
开发者ID:anitagraser,项目名称:QGIS,代码行数:66,代码来源:qgsmediancut.cpp


示例19: qMakePair

void TWebSocketWorker::setPayload(TWebSocketFrame::OpCode opCode, const QByteArray &payload)
{
    _payloads << qMakePair((int)opCode, payload);
}
开发者ID:gaoxiaojun,项目名称:treefrog-framework,代码行数:4,代码来源:twebsocketworker.cpp


示例20: qMakePair

#include "plansza.h"

//wersory kierunkowe
const QPair <int,int> DIR[8] = {
qMakePair(0, 1), //GORA
qMakePair(1, 0), //PRAWO
qMakePair(0, -1), //DOL
qMakePair(-1, 0), //LEWO
qMakePair(1, 1), //GORA-PRAWO SKOS
qMakePair(1, -1), //DOL-PRAWO SKOS
qMakePair(-1, -1), //DOL-LEWO SKOS
qMakePair(-1, 1), //GORA-LEWO SKOS
};


Plansza::Plansza()
{
	for ( int i = 0; i < rozmiarDruzyny; i++ )
	{
		dane[i] = i;
		dane[i + rozmiarDruzyny] = i + 42;
	}

	dane[ 14 ] = 3; 	//pilka 0 na pozycje 3
	dane[ 15 ] = 45;	//pilka 1 na pozycje 45

	dane[16] = 0; //zaczyna gracz 0
}


bool Plansza::czyPilka( int pionekId )
开发者ID:wosiu,项目名称:Diaballik,代码行数:31,代码来源:plansza.cpp



注:本文中的qMakePair函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qMove函数代码示例发布时间:2022-05-30
下一篇:
C++ qLowerBound函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap