当前位置: 首页>>代码示例>>C++>>正文


C++ QMap::insert方法代码示例

本文整理汇总了C++中QMap::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::insert方法的具体用法?C++ QMap::insert怎么用?C++ QMap::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMap的用法示例。


在下文中一共展示了QMap::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
    KAboutData aboutData("previewer", 0, ki18n("Plasma-Studio Previewer"),
                         "1.0", ki18n(description), KAboutData::License_BSD,
                         ki18n("XXXX"));
    aboutData.setProgramIconName("plasma");
    aboutData.addAuthor(ki18n("XXX"),
                         ki18n("Original author"),
                        "[email protected]");

    KCmdLineArgs::init(argc, argv, &aboutData);

    KCmdLineOptions options;
    options.add("list", ki18n("Displays a list of known applets"));
    options.add("f");
    options.add("formfactor <name>", ki18nc("Do not translate horizontal, vertical, mediacenter nor planar", "The formfactor to use (horizontal, vertical, mediacenter or planar)"), "planar");
    options.add("l");
    options.add("location <name>", ki18nc("Do not translate floating, desktop, fullscreen, top, bottom, left nor right", "The location constraint to start the Containment with (floating, desktop, fullscreen, top, bottom, left, right)"), "floating");
    options.add("c");
    options.add("containment <name>", ki18n("Name of the containment plugin"), "null");
    options.add("w");
    options.add("wallpaper <name>", ki18n("Name of the wallpaper plugin"), QByteArray());
    options.add("p");
    options.add("pixmapcache <size>", ki18n("The size in KB to set the pixmap cache to"));
    options.add("+applet", ki18n("Name of applet to add (required)"));
    options.add("+[args]", ki18n("Optional arguments of the applet to add"));
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs() ;

    if (args->isSet("list")) {
        int maxLen = 0;
        QMap<QString, QString> applets;
        foreach (const KPluginInfo &info, Plasma::Applet::listAppletInfo()) {
            if (info.property("NoDisplay").toBool())
                continue;

            int len = info.pluginName().length();
            if (len > maxLen)
                maxLen = len;

            QString name = info.pluginName();
            QString comment = info.comment();

            if(comment.isEmpty())
                comment = i18n("No description available");

            applets.insert(name, comment);
        }

        QMap<QString, QString>::const_iterator it;
        for(it = applets.constBegin(); it != applets.constEnd(); it++) {
            QString applet("%1 - %2");

            applet = applet.arg(it.key().leftJustified(maxLen, ' ')).arg(it.value());
            std::cout << applet.toLocal8Bit().data() << std::endl;
        }

        return 0;
    }
开发者ID:ruphy,项目名称:plasma-studio,代码行数:62,代码来源:main.cpp

示例2: featureTypeList

void QgsWfsProjectParser::featureTypeList( QDomElement& parentElement, QDomDocument& doc ) const
{
    const QList<QDomElement>& projectLayerElements = mProjectParser->projectLayerElements();
    if ( projectLayerElements.size() < 1 )
    {
        return;
    }

    QStringList wfsLayersId = mProjectParser->wfsLayers();
    QSet<QString> wfstUpdateLayersId = wfstUpdateLayers();
    QSet<QString> wfstInsertLayersId = wfstInsertLayers();
    QSet<QString> wfstDeleteLayersId = wfstDeleteLayers();

    QMap<QString, QgsMapLayer *> layerMap;

    Q_FOREACH ( const QDomElement &elem, projectLayerElements )
    {
        QString type = elem.attribute( QStringLiteral( "type" ) );
        if ( type == QLatin1String( "vector" ) )
        {
            QString layerId = mProjectParser->layerId( elem );
            if ( !wfsLayersId.contains( layerId ) )
            {
                continue;
            }
            QgsMapLayer *layer = mProjectParser->createLayerFromElement( elem );
            if ( !layer )
            {
                continue;
            }
#ifdef HAVE_SERVER_PYTHON_PLUGINS
            if ( !mAccessControl->layerReadPermission( layer ) )
            {
                continue;
            }
#endif
            QgsDebugMsg( QString( "add layer %1 to map" ).arg( layer->id() ) );
            layerMap.insert( layer->id(), layer );

            QDomElement layerElem = doc.createElement( QStringLiteral( "FeatureType" ) );
            QDomElement nameElem = doc.createElement( QStringLiteral( "Name" ) );
            //We use the layer name even though it might not be unique.
            //Because the id sometimes contains user/pw information and the name is more descriptive
            QString typeName = layer->name();
            if ( !layer->shortName().isEmpty() )
                typeName = layer->shortName();
            typeName = typeName.replace( QLatin1String( " " ), QLatin1String( "_" ) );
            QDomText nameText = doc.createTextNode( typeName );
            nameElem.appendChild( nameText );
            layerElem.appendChild( nameElem );

            QDomElement titleElem = doc.createElement( QStringLiteral( "Title" ) );
            QString titleName = layer->title();
            if ( titleName.isEmpty() )
            {
                titleName = layer->name();
            }
            QDomText titleText = doc.createTextNode( titleName );
            titleElem.appendChild( titleText );
            layerElem.appendChild( titleElem );

            QDomElement abstractElem = doc.createElement( QStringLiteral( "Abstract" ) );
            QString abstractName = layer->abstract();
            if ( abstractName.isEmpty() )
            {
                abstractName = QLatin1String( "" );
            }
            QDomText abstractText = doc.createTextNode( abstractName );
            abstractElem.appendChild( abstractText );
            layerElem.appendChild( abstractElem );

            //keyword list
            if ( !layer->keywordList().isEmpty() )
            {
                QDomElement keywordsElem = doc.createElement( QStringLiteral( "Keywords" ) );
                QDomText keywordsText = doc.createTextNode( layer->keywordList() );
                keywordsElem.appendChild( keywordsText );
                layerElem.appendChild( keywordsElem );
            }

            //appendExGeographicBoundingBox( layerElem, doc, layer->extent(), layer->crs() );

            QDomElement srsElem = doc.createElement( QStringLiteral( "SRS" ) );
            QDomText srsText = doc.createTextNode( layer->crs().authid() );
            srsElem.appendChild( srsText );
            layerElem.appendChild( srsElem );

            //wfs:Operations element
            QDomElement operationsElement = doc.createElement( QStringLiteral( "Operations" )/*wfs:Operations*/ );
            //wfs:Query element
            QDomElement queryElement = doc.createElement( QStringLiteral( "Query" )/*wfs:Query*/ );
            operationsElement.appendChild( queryElement );

            QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( layer );
            QgsVectorDataProvider* provider = vlayer->dataProvider();
            if (( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) && wfstInsertLayersId.contains( layer->id() ) )
            {
                //wfs:Insert element
                QDomElement insertElement = doc.createElement( QStringLiteral( "Insert" )/*wfs:Insert*/ );
                operationsElement.appendChild( insertElement );
//.........这里部分代码省略.........
开发者ID:spono,项目名称:QGIS,代码行数:101,代码来源:qgswfsprojectparser.cpp

示例3: start

void Spider::start(){

    XpathUtil *util = new XpathUtil(page);
    int count = 0;
    global::unVisitedUrl->pop();
    global::unVisitedUrl->pop();
    while (!global::unVisitedUrl->empty())
    {
        Node node = global::unVisitedUrl->top();
        this->node = node;
        //判断url是否本地采集过
        if(global::bf->contains(node.url.toStdString())){
            qDebug()<< node.url<<" already crawled before !";
            global::unVisitedUrl->pop();
            continue;
        }
        count++;
        qDebug()<<count;
        //判断数据采集节点是否服务器已经采集过
        if(node.depth == global::maxDepth){
            instance->flag = false;
            instance->getService = true;
            if(this->get(instance,node.url)){
                qDebug()<<"elasticesearch indexed :" +node.url;
                logInfo(QString::number(count)+" elasticesearch indexed :"+node.url);
                global::bf->insert(node.url.toStdString());
                global::unVisitedUrl->pop();
                continue;
            }
        }
        logInfo(QString::number(count)+" load url :"+node.url);
        qDebug()<<"load url :"+node.url;
        page->flag = true;
        page->mainFrame()->load(QUrl(node.url));
        QEventLoop eventLoop;
        QObject::connect(page, SIGNAL(loadFinished(bool)), &eventLoop, SLOT(quit()));
        QTimer timer;
        timer.setSingleShot(true);
        QObject::connect(&timer,SIGNAL(timeout()),&eventLoop,SLOT(quit()));
        //5s
        timer.start(5000);
        eventLoop.exec();       //block until finish
        if(timer.isActive()){
            timer.stop();
        }
        //采集数据节点
        int emptyCount = 0;
        if(node.depth == global::maxDepth){

            page->flag = true;
            QMap<int,QStringList> result;
            QMap<QString, QVariant> map;
            emptyCount=0;
            for(int j=0;j<node.collectData.size()-3;j++){
                QStringList tmpResult;
                QString nameFiled = node.collectData.at(j)["name"];
                QString resultFiled = util->parserXpath(page,node.collectData.at(j)["xpath"],node.collectData.at(j)["type"].toInt());
                //logInfo("[collect data ] nameFiled : "+nameFiled +" resultFiled :"+resultFiled);
                //logInfo("debug : "+node.collectData.at(j)["xpath"]+ " debug :"+node.collectData.at(j)["type"]);
                tmpResult.append(nameFiled);
                tmpResult.append(resultFiled);
                result.insert(j+1,tmpResult);
                map.insert(nameFiled,resultFiled);
                if(resultFiled.trimmed()==""){
                    emptyCount++;
                }
            }
            QStringList tmpResult;
            tmpResult.append("url");
            tmpResult.append(node.url);
            result.insert(node.collectData.size()-2,tmpResult);
            map.insert("url",node.url);
            QStringList tmpResult2;
            tmpResult2.append("来源");
            tmpResult2.append(global::taskID);
            result.insert(node.collectData.size()-1,tmpResult2);
            map.insert("来源",global::taskID);
            QDateTime current_date_time = QDateTime::currentDateTime();
            QString current_date = current_date_time.toString("yyyy-MM-dd hh:mm:ss");
            QStringList tmpResult3;
            tmpResult3.append("采集时间");
            tmpResult3.append(current_date);
            map.insert("采集时间",current_date);
            result.insert(node.collectData.size(),tmpResult3);
            if(emptyCount<7){
                global::sqlite->insertXpathResult(global::taskID,result);
                this->post(map,instance);

            }

        }else{
            //非采集节点
            page->flag = false;

            //qDebug()<<page->mainFrame()->toHtml();

            for(int j=0;j<node.regionXpath.size();j++){
                qDebug()<<"region xpath";
                this->node = (*(global::nodeMap))[node.depth];
                this->isRegionNode = true;
//.........这里部分代码省略.........
开发者ID:huyangenruc,项目名称:bccspider,代码行数:101,代码来源:spider_service.cpp

示例4: QDialog

GroupchatTopicDlg::GroupchatTopicDlg(GCMainDlg *parent) :
    QDialog(parent),
    m_ui(new Ui::GroupchatTopicDlg),
    m_addLangUi(new Ui::GroupChatTopicAddLangDlg)
{
    m_ui->setupUi(this);
    QKeySequence sendKey = ShortcutManager::instance()->shortcut("chat.send");
    if (sendKey == QKeySequence(Qt::Key_Enter) || sendKey == QKeySequence(Qt::Key_Return)) {
        sendKey = QKeySequence(Qt::CTRL + Qt::Key_Return);
    }
    m_ui->buttonBox->button(QDialogButtonBox::Ok)->setShortcut(sendKey);

    auto cw = new QToolButton();
    cw->setIcon(IconsetFactory::icon("psi/add").icon());
    m_ui->twLang->setCornerWidget(cw);
    QObject::connect(m_ui->twLang, &QTabWidget::tabCloseRequested, this, [=](int index) {
        m_ui->twLang->widget(index)->deleteLater();
        m_ui->twLang->removeTab(index);
    });
    QObject::connect(cw, &QToolButton::clicked, this, [=](bool checked) {
        Q_UNUSED(checked);
        if (!addLangDlg) {
            addLangDlg = new QDialog(this);
            m_addLangUi->setupUi(addLangDlg);
            addLangDlg->setWindowIcon(QIcon(IconsetFactory::iconPixmap("psi/logo_128")));
            addLangDlg->setAttribute(Qt::WA_DeleteOnClose);

            m_addLangUi->cmbLang->addItem(tr("Any Language"), 0);
            QMap<QString,QLocale::Language> langs;
            for (auto const &loc : QLocale::matchingLocales(
                     QLocale::AnyLanguage,
                     QLocale::AnyScript,
                     QLocale::AnyCountry))
            {
                if (loc != QLocale::c()) {
                    langs.insert(QLocale::languageToString(loc.language()), loc.language());
                }
            }
            for (auto lang: langs) {
                LanguageManager::LangId id;
                id.language = lang;
                m_addLangUi->cmbLang->addItem(LanguageManager::languageName(id), lang);
            }

            populateCountryAndScript();

            addLangDlg->adjustSize();
            addLangDlg->move(cw->mapToGlobal(QPoint(cw->width() - addLangDlg->width(), cw->height())));
            addLangDlg->show();
            QObject::connect(addLangDlg,  &QDialog::accepted, this, [=]() {
                LanguageManager::LangId id;
                id.language = m_addLangUi->cmbLang->currentData().toInt();
                id.script = m_addLangUi->cmbScript->currentData().toInt();
                id.country = m_addLangUi->cmbCountry->currentData().toInt();
                bool found = false;
                for (int i = 0; i < m_ui->twLang->count(); i++) {
                    QPlainTextEdit *edit = static_cast<QPlainTextEdit *>(m_ui->twLang->widget(i));
                    LanguageManager::LangId tabId = edit->property("langId").value<LanguageManager::LangId>();
                    if (id == tabId) {
                        m_ui->twLang->setCurrentIndex(i);
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    addLanguage(id);
                }
            });

            QObject::connect(m_addLangUi->cmbLang, static_cast<void(QComboBox::*)(int index)>(&QComboBox::currentIndexChanged), this, [=](int index) {
                Q_UNUSED(index)
                populateCountryAndScript();
            });
        } else {
            addLangDlg->setFocus();
        }
    });
}
开发者ID:psi-im,项目名称:psi,代码行数:78,代码来源:groupchattopicdlg.cpp

示例5: identityRegisterTwice

void TimeoutsTest::identityRegisterTwice()
{
    QEventLoop loop;
    QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
    QObject::connect(this, SIGNAL(finished()), &loop, SLOT(quit()));

    QMap<MethodName,MechanismsList> methods;
    methods.insert("dummy", QStringList() << "mech1" << "mech2");
    IdentityInfo info = IdentityInfo(QLatin1String("timeout test"),
                                     QLatin1String("[email protected]"),
                                     methods);
    info.setAccessControlList(QStringList() << "*");
    Identity *identity = Identity::newIdentity(info);
    QVERIFY(identity != NULL);

    QObject::connect(identity,
                     SIGNAL(credentialsStored(const quint32)),
                     this,
                     SLOT(credentialsStored(const quint32)));
    QObject::connect(identity,
                     SIGNAL(error(const SignOn::Error &)),
                     this,
                     SLOT(identityError(const SignOn::Error &)));

    identity->storeCredentials();

    loop.exec();
    QVERIFY(identity->id() != SSO_NEW_IDENTITY);

    QDBusConnection conn = SIGNOND_BUS;

    QDBusMessage msg = QDBusMessage::createMethodCall(SIGNOND_SERVICE,
                                                      SIGNOND_DAEMON_OBJECTPATH,
                                                      SIGNOND_DAEMON_INTERFACE,
                                                      "getIdentity");
    QList<QVariant> args;
    args << identity->id();
    msg.setArguments(args);

    QDBusMessage reply = conn.call(msg);
    QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);

    QDBusObjectPath objectPath = reply.arguments()[0].value<QDBusObjectPath>();
    QString path = objectPath.path();
    qDebug() << "Got path" << path;
    QVERIFY(!path.isEmpty());

    bool success;

    QTest::qSleep(100);
    success = triggerDisposableCleanup();
    QVERIFY(success);

    /* The identity object must exist now */
    QVERIFY(identityAlive(path));

    QTest::qSleep(6 * 1000);
    /* now we register the same identity again. The expected behavior is that
     * the registration succeeds, possibly returning the same object path as
     * before.
     * This is to test a regression (NB#182914) which was happening because
     * signond was deleting the expired Identity immediately after returning
     * its object path to the client.
     */
    reply = conn.call(msg);
    QVERIFY(reply.type() == QDBusMessage::ReplyMessage);

    objectPath = reply.arguments()[0].value<QDBusObjectPath>();
    path = objectPath.path();
    qDebug() << "Got path" << path;
    QVERIFY(!path.isEmpty());

    QVERIFY(identityAlive(path));
}
开发者ID:Distrotech,项目名称:signon,代码行数:74,代码来源:timeouts.cpp

示例6: initializePage

void MTPageNym_AltLocation::initializePage() //virtual
{
    if (!bInitialized)
    {
        bInitialized=true;

    WizardEditProfile * pWizard = dynamic_cast<WizardEditProfile *>(wizard());
    const bool bEditingExistingProfile = (nullptr != pWizard);

    listContactDataTuples copy_of_list;
    if (bEditingExistingProfile) copy_of_list = pWizard->listContactDataTuples_;
    // ------------------------------
    //QList<QWidget *>  listTabs_;
    int nCurrentTab = 0;

    std::set<uint32_t> sections = opentxs::OTAPI_Wrap::OTAPI()->GetContactSections();

    for (auto & indexSection: sections)  //Names (for example)
    {
        nCurrentTab++;
        bool bAddedInitialItem = false;

        QMap<uint32_t, QString> mapTypeNames;
        // ----------------------------------------
        // Create a new (tab page) Widget.
        QWidget * pTab = new QWidget(this);
        std::string sectionName = opentxs::OTAPI_Wrap::OTAPI()->GetContactSectionName (indexSection);

        if (opentxs::proto::CONTACTSECTION_RELATIONSHIPS == indexSection)
        {
            pTab->setEnabled(false);
            pTab->setVisible(false);
        }
        // ----------------------------------------

//      pTab->setWindowTitle(QString::fromStdString(sectionName));
        // ----------------------------
        // Setup the widget

        //QMap<int, QList<GroupBoxContactItems *> * > mapGroupBoxLists_;

        QList<GroupBoxContactItems *> * pListGroupBoxes = new QList<GroupBoxContactItems *>;

        std::set<uint32_t> sectionTypes = opentxs::OTAPI_Wrap::OTAPI()->GetContactSectionTypes(indexSection);

        for (auto & indexSectionType: sectionTypes)
        {
            std::string typeName = opentxs::OTAPI_Wrap::OTAPI()->GetContactTypeName(indexSectionType);
            mapTypeNames.insert(indexSectionType, QString::fromStdString(typeName));
        }
        // -------------------------------
        QVBoxLayout * pvBox = new QVBoxLayout(pTab);
        pvBox->setAlignment(Qt::AlignTop);
        pvBox->setMargin(0);
        pTab->setContentsMargins(0,0,0,0);
        // -------------------------------
        int nContactItemsAdded = 0;

        for (auto & indexSectionType: sectionTypes) // BUSINESS Name (for example)
        {
            GroupBoxContactItems   * pGroupBox = new GroupBoxContactItems(pTab);
            QVBoxLayout            * layout    = new QVBoxLayout(pGroupBox);
            // -------------------------------
            pGroupBox->setFlat(true);
            pGroupBox->setContentsMargins(0,0,0,0);

            layout->setMargin(0);

            pGroupBox->indexSection_ = indexSection;
            pGroupBox->indexSectionType_ = indexSectionType;
            pGroupBox->mapTypeNames_ = mapTypeNames;

            if (bEditingExistingProfile) // We're editing pre-existing claims, so need to add them to the UI.
            {
        //      typedef std::tuple<uint32_t, uint32_t, std::string, bool> tupleContactDataItem;
        //      typedef std::list<tupleContactDataItem> listContactDataTuples;

//                qDebug() << "===> copy_of_list.size(): " << copy_of_list.size();

                int nCounter=0;
                for (auto & data_item: copy_of_list)
                {
//                    qDebug() << "Loop through copy_of_list nCounter: " << nCounter++;
//                    qDebug() << "std::get<0>(data_item): " << std::get<0>(data_item);
//                    qDebug() << "std::get<1>(data_item): " << std::get<1>(data_item);
//                    qDebug() << "std::get<2>(data_item): " << QString::fromStdString(std::get<2>(data_item));
//                    qDebug() << "std::get<3>(data_item): " << std::get<3>(data_item);

                    const uint32_t    item_section = std::get<0>(data_item);
                    const uint32_t    item_type    = std::get<1>(data_item);
                    const std::string item_value   = std::get<2>(data_item);
                    const bool        item_primary = std::get<3>(data_item);

                    if ( (item_section == indexSection) &&
                         (item_type    == indexSectionType) )
                    {
                        // Crash isolated to the below line of code:
                        //qDebug() << "Crash isolated to below line of code: indexSectionType: " << indexSectionType;

                        OT_ASSERT(indexSectionType >= 1);
//.........这里部分代码省略.........
开发者ID:bitcredit-currency,项目名称:Moneychanger,代码行数:101,代码来源:pagenym_altlocation.cpp

示例7: itemProcessed

QMap<ItemId, CommitResult> StorageHandler::commitAddedItems( StoragePlugin& aPlugin, 
		                               ConflictResolver* aConflictResolver )
{
    FUNCTION_CALL_TRACE;

    QMap<ItemId, CommitResult> results = resolveConflicts (aConflictResolver, iAddList, COMMIT_INIT_ADD);    
    QList<ItemId> addIds = iAddList.keys();
    QList<SyncItem*> addItems = iAddList.values();

    LOG_DEBUG( "Committing" << addItems.count() << "added items" );

    QList<StoragePlugin::StoragePluginStatus> addStatus = aPlugin.addItems( addItems );

    for( int i = 0; i < addStatus.count(); ++i ) {

        CommitResult& result = results[addIds[i]];
        result.iItemKey = *addItems[i]->getKey();
        
        LOG_DEBUG( "Item" << addIds[i].iCmdId << "/" << addIds[i].iItemIndex << "committed" );

        switch( addStatus[i] )
        {

            case StoragePlugin::STATUS_OK:
            {
                LOG_DEBUG( "Commit result: COMMIT_ADDED" );
                result.iStatus = COMMIT_ADDED;
                
		emit itemProcessed( MOD_ITEM_ADDED, MOD_LOCAL_DATABASE,
                                    aPlugin.getSourceURI() , addItems[i]->getType(), addItems.count() );

                break;
            }
            case StoragePlugin::STATUS_DUPLICATE:
            {
                LOG_DEBUG( "Commit result: COMMIT_DUPLICATE" );
                result.iStatus = COMMIT_DUPLICATE;

                emit itemProcessed( MOD_ITEM_ADDED, MOD_LOCAL_DATABASE,
                                    aPlugin.getSourceURI() , addItems[i]->getType(), addItems.count() );

                break;
            }
            default:
            {
                result.iStatus = generalStatus( addStatus[i] );

                emit itemProcessed( MOD_ITEM_ERROR, MOD_LOCAL_DATABASE,
                                    aPlugin.getSourceURI() , addItems[i]->getType(), addItems.count() );

                break;
            }

        }

        results.insert( addIds[i], result );

    }

    qDeleteAll( addItems );
    iAddList.clear();

    return results;
}
开发者ID:kavuri,项目名称:buteo-syncml,代码行数:64,代码来源:StorageHandler.cpp

示例8: initWithString

bool CCImage::initWithString(
        const char * pText,
        int nWidth/* = 0*/,
        int nHeight/* = 0*/,
        ETextAlign eAlignMask/* = kAlignCenter*/,
        const char * pFontName/* = nil*/,
        int nSize/* = 0*/)
{
    if (!pText)
    {
        return false;
    }

    QString fontPath(CCFileUtils::fullPathFromRelativePath(pFontName));

    QString fontFamily = pFontName;
    QString fontStyle = "Normal";

    // font already loaded?
    QMap<QString, QString>::iterator fontIter = loadedFontMap.find(fontPath);
    if(fontIter == loadedFontMap.end())
    {
        int fontID = QFontDatabase::addApplicationFont(fontPath);
        if(fontID != -1)
        {
            QStringList familyList = QFontDatabase::applicationFontFamilies(fontID);

            if(familyList.size() > 0)
                fontFamily = familyList.at(0);
        }

        loadedFontMap.insert(fontPath, fontFamily);
    }
    else
    {
        fontFamily = fontIter.value();
    }

    QFontDatabase fd;
    QFont f = fd.font(fontFamily, fontStyle, nSize);
    f.setPixelSize(nSize);

    QFontMetrics fm(f);

    if (nWidth)
    {
        m_nWidth = (short)nWidth;
    }
    else
    {
        m_nWidth = fm.width(QString(pText));
    }

    if (nHeight)
    {
        m_nHeight = (short)nHeight;
    }
    else
    {
        m_nHeight = fm.height();
    }

    m_bHasAlpha = true;
    m_bPreMulti = false;
    m_pData = new unsigned char[m_nWidth * m_nHeight * 4];
    memset(m_pData, 0, m_nWidth * m_nHeight * 4);
    m_nBitsPerComponent = 8;

    QImage image(m_pData, m_nWidth, m_nHeight, QImage::Format_ARGB32_Premultiplied);
    QPainter painter(&image);
    painter.setFont(f);
    painter.setPen(Qt::white);

    int flags = 0;
    switch (eAlignMask)
    {
    case kAlignCenter: // Horizontal center and vertical center.
        flags |= Qt::AlignHCenter;
        flags |= Qt::AlignVCenter;
        break;
    case kAlignTop: // Horizontal center and vertical top.
        flags |= Qt::AlignHCenter;
        flags |= Qt::AlignTop;
        break;
    case kAlignTopRight: // Horizontal right and vertical top.
        flags |= Qt::AlignRight;
        flags |= Qt::AlignTop;
        break;
    case kAlignRight: // Horizontal right and vertical center.
        flags |= Qt::AlignRight;
        flags |= Qt::AlignVCenter;
        break;
    case kAlignBottomRight: // Horizontal right and vertical bottom.
        flags |= Qt::AlignRight;
        flags |= Qt::AlignBottom;
        break;
    case kAlignBottom: // Horizontal center and vertical bottom.
        flags |= Qt::AlignHCenter;
        flags |= Qt::AlignBottom;
        break;
//.........这里部分代码省略.........
开发者ID:JorgeGalingP,项目名称:cocos2d-x-qt,代码行数:101,代码来源:CCImage_qt.cpp

示例9: copyTo

bool KArchiveDirectory::copyTo(const QString &dest, bool recursiveCopy) const
{
    QDir root;

    QList<const KArchiveFile *> fileList;
    QMap<qint64, QString> fileToDir;

    // placeholders for iterated items
    QStack<const KArchiveDirectory *> dirStack;
    QStack<QString> dirNameStack;

    dirStack.push(this);       // init stack at current directory
    dirNameStack.push(dest);   // ... with given path
    do {
        const KArchiveDirectory *curDir = dirStack.pop();
        const QString curDirName = dirNameStack.pop();
        if (!root.mkpath(curDirName)) {
            return false;
        }

        const QStringList dirEntries = curDir->entries();
        for (QStringList::const_iterator it = dirEntries.begin(); it != dirEntries.end(); ++it) {
            const KArchiveEntry *curEntry = curDir->entry(*it);
            if (!curEntry->symLinkTarget().isEmpty()) {
                QString linkName = curDirName + QLatin1Char('/') + curEntry->name();
                // To create a valid link on Windows, linkName must have a .lnk file extension.
#ifdef Q_OS_WIN
                if (!linkName.endsWith(QStringLiteral(".lnk"))) {
                    linkName += QStringLiteral(".lnk");
                }
#endif
                QFile symLinkTarget(curEntry->symLinkTarget());
                if (!symLinkTarget.link(linkName)) {
                    //qDebug() << "symlink(" << curEntry->symLinkTarget() << ',' << linkName << ") failed:" << strerror(errno);
                }
            } else {
                if (curEntry->isFile()) {
                    const KArchiveFile *curFile = dynamic_cast<const KArchiveFile *>(curEntry);
                    if (curFile) {
                        fileList.append(curFile);
                        fileToDir.insert(curFile->position(), curDirName);
                    }
                }

                if (curEntry->isDirectory() && recursiveCopy) {
                    const KArchiveDirectory *ad = dynamic_cast<const KArchiveDirectory *>(curEntry);
                    if (ad) {
                        dirStack.push(ad);
                        dirNameStack.push(curDirName + QLatin1Char('/') + curEntry->name());
                    }
                }
            }
        }
    } while (!dirStack.isEmpty());

    qSort(fileList.begin(), fileList.end(), sortByPosition);    // sort on d->pos, so we have a linear access

    for (QList<const KArchiveFile *>::const_iterator it = fileList.constBegin(), end = fileList.constEnd();
            it != end; ++it) {
        const KArchiveFile *f = *it;
        qint64 pos = f->position();
        if (!f->copyTo(fileToDir[pos])) {
            return false;
        }
    }
    return true;
}
开发者ID:parulina,项目名称:parupaint,代码行数:67,代码来源:karchive.cpp

示例10: runChecks


//.........这里部分代码省略.........
    if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Check Geometries" ), tr( "The following output layers are in a format that does not support editing features:\n%1\n\nThe geometry check can be performed, but it will not be possible to fix any errors. Do you want to continue?" ).arg( nonEditableLayerNames.join( "\n" ) ), QMessageBox::Yes, QMessageBox::No ) )
    {
      if ( ui.radioButtonOutputNew->isChecked() )
      {
        for ( QgsVectorLayer *layer : qgis::as_const( processLayers ) )
        {
          QString layerPath = layer->dataProvider()->dataSourceUri();
          delete layer;
          if ( ui.comboBoxOutputFormat->currentText() == QLatin1String( "ESRI Shapefile" ) )
          {
            QgsVectorFileWriter::deleteShapeFile( layerPath );
          }
          else
          {
            QFile( layerPath ).remove();
          }
        }
        mRunButton->setEnabled( true );
        ui.labelStatus->hide();
        unsetCursor();
      }
      return;
    }
  }

  // Setup checker
  ui.labelStatus->setText( tr( "<b>Building spatial index...</b>" ) );
  QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
  QMap<QString, QgsFeaturePool *> featurePools;
  for ( QgsVectorLayer *layer : qgis::as_const( processLayers ) )
  {
    double layerToMapUntis = mIface->mapCanvas()->mapSettings().layerToMapUnits( layer );
    QgsCoordinateTransform layerToMapTransform( layer->crs(), QgsProject::instance()->crs(), QgsProject::instance() );
    featurePools.insert( layer->id(), new QgsFeaturePool( layer, layerToMapUntis, layerToMapTransform, selectedOnly ) );
  }
  // LineLayerIntersection check is enabled, make sure there is also a feature pool for that layer
  if ( ui.checkLineLayerIntersection->isChecked() && !featurePools.keys().contains( ui.comboLineLayerIntersection->currentData().toString() ) )
  {
    QgsVectorLayer *layer = dynamic_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( ui.comboLineLayerIntersection->currentData().toString() ) );
    Q_ASSERT( layer );
    double layerToMapUntis = mIface->mapCanvas()->mapSettings().layerToMapUnits( layer );
    QgsCoordinateTransform layerToMapTransform( layer->crs(), QgsProject::instance()->crs(), QgsProject::instance() );
    featurePools.insert( layer->id(), new QgsFeaturePool( layer, layerToMapUntis, layerToMapTransform, selectedOnly ) );
  }

  QgsGeometryCheckerContext *context = new QgsGeometryCheckerContext( ui.spinBoxTolerance->value(), QgsProject::instance()->crs(), featurePools );

  QList<QgsGeometryCheck *> checks;
  for ( const QgsGeometryCheckFactory *factory : QgsGeometryCheckFactoryRegistry::getCheckFactories() )
  {
    QgsGeometryCheck *check = factory->createInstance( context, ui );
    if ( check )
    {
      checks.append( check );
    }
  }
  QgsGeometryChecker *checker = new QgsGeometryChecker( checks, context );

  emit checkerStarted( checker );

  if ( ui.radioButtonOutputNew->isChecked() )
  {
    QList<QgsMapLayer *> addLayers;
    for ( QgsVectorLayer *layer : qgis::as_const( processLayers ) )
    {
      addLayers.append( layer );
开发者ID:vmora,项目名称:QGIS,代码行数:67,代码来源:qgsgeometrycheckersetuptab.cpp

示例11:

QMap<QString, QSharedPointer<DeviceState> > MusicScene::getDeviceState()
{
    QMap<QString, QSharedPointer<DeviceState> > ret;
    ret.insert(player.getDeviceId(),player.createEmptyState());
    return ret;
}
开发者ID:midiPlayer,项目名称:midiPlayer,代码行数:6,代码来源:musicscene.cpp

示例12: px

QMap<QString, QString> CSSCustomDialog::cssDict()
{
    QMap<QString, QString> dict;

    // Fontsizes ------------------------------------------------------

    int bfs = basefontsize->currentText().toInt();
    dict.insert(QStringLiteral("fontsize-base"), px(bfs, 1.0));

    if (dontScale->isChecked()) {
        dict.insert(QStringLiteral("fontsize-small-1"), px(bfs, 1.0));
        dict.insert(QStringLiteral("fontsize-large-1"), px(bfs, 1.0));
        dict.insert(QStringLiteral("fontsize-large-2"), px(bfs, 1.0));
        dict.insert(QStringLiteral("fontsize-large-3"), px(bfs, 1.0));
        dict.insert(QStringLiteral("fontsize-large-4"), px(bfs, 1.0));
        dict.insert(QStringLiteral("fontsize-large-5"), px(bfs, 1.0));
    } else {
        // TODO: use something harmonic here
        dict.insert(QStringLiteral("fontsize-small-1"), px(bfs, 0.8));
        dict.insert(QStringLiteral("fontsize-large-1"), px(bfs, 1.2));
        dict.insert(QStringLiteral("fontsize-large-2"), px(bfs, 1.4));
        dict.insert(QStringLiteral("fontsize-large-3"), px(bfs, 1.5));
        dict.insert(QStringLiteral("fontsize-large-4"), px(bfs, 1.6));
        dict.insert(QStringLiteral("fontsize-large-5"), px(bfs, 1.8));
    }

    // Colors --------------------------------------------------------

    if (customColor->isChecked()) {
        dict.insert(QStringLiteral("background-color"), backgroundColorButton->color().name());
        dict.insert(QStringLiteral("foreground-color"), foregroundColorButton->color().name());
    } else {
        const char *blackOnWhiteFG[2] = {"White", "Black"};
        bool bw = blackOnWhite->isChecked();
        dict.insert(QStringLiteral("foreground-color"), QLatin1String(blackOnWhiteFG[bw]));
        dict.insert(QStringLiteral("background-color"), QLatin1String(blackOnWhiteFG[!bw]));
    }

    const char *notImportant[2] = {"", "! important"};
    dict.insert(QStringLiteral("force-color"), QLatin1String(notImportant[sameColor->isChecked()]));

    // Fonts -------------------------------------------------------------
    dict.insert(QStringLiteral("font-family"), fontFamily->currentText());
    dict.insert(QStringLiteral("force-font"), QLatin1String(notImportant[sameFamily->isChecked()]));

    // Images

    const char *bgNoneImportant[2] = {"", "background-image : none ! important"};
    dict.insert(QStringLiteral("display-images"), QLatin1String(bgNoneImportant[hideImages->isChecked()]));
    dict.insert(QStringLiteral("display-background"), QLatin1String(bgNoneImportant[hideBackground->isChecked()]));

    return dict;
}
开发者ID:KDE,项目名称:kde-baseapps,代码行数:53,代码来源:kcmcss.cpp

示例13: skipWhitespace

/*!
  Parses the MIME header \a header and returns the map of those headers.
  This function is for internal use only.
*/
QMap<QByteArray, QByteArray> TMimeHeader::parseHeaderParameter(const QByteArray &header)
{
    QMap<QByteArray, QByteArray> result;
    int pos = 0;

    for (;;) {
        pos = skipWhitespace(header, pos);
        if (pos >= header.length())
            return result;

        int semicol = header.indexOf(';', pos);
        if (semicol < 0)
            semicol = header.length();

        QByteArray key;
        int equal = header.indexOf('=', pos);
        if (equal < 0 || equal > semicol) {
            key = header.mid(pos, semicol - pos).trimmed();
            if (!key.isEmpty()) {
                result.insert(key, QByteArray());
            }
            pos = semicol + 1;
            continue;
        }

        key = header.mid(pos,  equal - pos).trimmed();
        pos = equal + 1;

        pos = skipWhitespace(header, pos);
        if (pos >= header.length())
            return result;

        QByteArray value;
        if (header[pos] == '"') {
            ++pos;
            while (pos < header.length()) {
                char c = header.at(pos);
                if (c == '"') {
                    // end of quoted text
                    break;
                } else if (c == '\\') {
                    ++pos;
                    if (pos >= header.length()) {
                        // broken header
                        return result;
                    }
                    c = header[pos];
                }

                value += c;
                ++pos;
            }
        } else {
            while (pos < header.length()) {
                char c = header.at(pos);
                if (c == ' ' || c == '\t' || c == '\r'
                    || c == '\n' || c == ';') {
                    break;
                }
                value += c;
                ++pos;
            }
        }

        result.insert(key, value);
    }
    return result;
}
开发者ID:AbhimanyuAryan,项目名称:treefrog-framework,代码行数:72,代码来源:tmultipartformdata.cpp

示例14: setInputVariablesXml

void OpenModelica::setInputVariablesXml(QDomDocument & doc, QString modelName, MOVector<Variable> *variables)
{
    QDomElement xfmi = doc.firstChildElement("fmiModelDescription");
    QDomElement oldxfmi = xfmi;

    QDomElement xModelVars = xfmi.firstChildElement("ModelVariables");
    QDomElement oldxModelVars = xModelVars;

    QDomNodeList listScalarVars = xModelVars.elementsByTagName("ScalarVariable");


    // filling map
    QMap<QString,int> mapScalarVars; //<name,index in listScalarVars>
    QMap<QDomElement,QDomElement> mapNewScalarVars; // <old node,new node>
    QDomElement curVar;
    QDomElement oldVar;
    QDomElement newVar;
    int index;
    QDomElement oldType;
    QDomElement newType;
    QString localVarName;

    // create map for index looking
    for(int i=0;i<listScalarVars.size();i++)
    {
        curVar = listScalarVars.at(i).toElement();
        mapScalarVars.insert(curVar.attribute("name"),i);
    }

    // change variables values
    for(int i=0;i<variables->size();i++)
    {
        // getting local var name (name in init file does not contain model name)
        localVarName = variables->at(i)->name(Variable::SHORT);
        //localVarName = localVarName.remove(modelName+".");

        index = mapScalarVars.value(localVarName,-1);
        if(index>-1)
        {
            oldVar = listScalarVars.at(index).toElement();
            newVar = oldVar;

            oldType = newVar.firstChildElement("Real");
            if(oldType.isNull())
                oldType = newVar.firstChildElement("Integer");
            if(oldType.isNull())
                oldType = newVar.firstChildElement("Boolean");

            if(!oldType.isNull())
            {
                newType = oldType;
                newType.setAttribute("start",variables->at(i)->value().toString());
                newVar.replaceChild(newType,oldType);
                xModelVars.replaceChild(newVar,oldVar);
            }
            xModelVars.replaceChild(newVar,oldVar);
        }
    }

    // update xfmi with new vars
    xfmi.replaceChild(xModelVars,oldxModelVars);
    doc.replaceChild(xfmi,oldxfmi);
}
开发者ID:cephdon,项目名称:OMOptim,代码行数:63,代码来源:OpenModelica.cpp

示例15: Tab

TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *_ownUser, const ServerInfo_Room &info)
    : Tab(_tabSupervisor), client(_client), roomId(info.room_id()), roomName(QString::fromStdString(info.name())), ownUser(_ownUser)
{
    const int gameTypeListSize = info.gametype_list_size();
    for (int i = 0; i < gameTypeListSize; ++i)
        gameTypes.insert(info.gametype_list(i).game_type_id(), QString::fromStdString(info.gametype_list(i).description()));

    QMap<int, GameTypeMap> tempMap;
    tempMap.insert(info.room_id(), gameTypes);
    gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), tempMap, true, true);
    userList = new UserList(tabSupervisor, client, UserList::RoomList);
    connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));

    chatView = new ChatView(tabSupervisor, 0, true);
    connect(chatView, SIGNAL(showMentionPopup(QString&)), this, SLOT(actShowMentionPopup(QString&)));
    connect(chatView, SIGNAL(messageClickedSignal()), this, SLOT(focusTab()));
    connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
    connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
    connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
    connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
    sayLabel = new QLabel;
    sayEdit = new QLineEdit;
    sayLabel->setBuddy(sayEdit);
    connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));

    QMenu *chatSettingsMenu = new QMenu(this);

    aClearChat = chatSettingsMenu->addAction(QString());
    aClearChat->setShortcut(QKeySequence("F12"));
    connect(aClearChat, SIGNAL(triggered()), this, SLOT(actClearChat()));

    chatSettingsMenu->addSeparator();

    aOpenChatSettings = chatSettingsMenu->addAction(QString());
    connect(aOpenChatSettings, SIGNAL(triggered()), this, SLOT(actOpenChatSettings()));

    QToolButton *chatSettingsButton = new QToolButton;
    chatSettingsButton->setIcon(QIcon(":/resources/icon_settings.svg"));
    chatSettingsButton->setMenu(chatSettingsMenu);
    chatSettingsButton->setPopupMode(QToolButton::InstantPopup);

    QHBoxLayout *sayHbox = new QHBoxLayout;
    sayHbox->addWidget(sayLabel);
    sayHbox->addWidget(sayEdit);
    sayHbox->addWidget(chatSettingsButton);

    QVBoxLayout *chatVbox = new QVBoxLayout;
    chatVbox->addWidget(chatView);
    chatVbox->addLayout(sayHbox);

    chatGroupBox = new QGroupBox;
    chatGroupBox->setLayout(chatVbox);

    QSplitter *splitter = new QSplitter(Qt::Vertical);
    splitter->addWidget(gameSelector);
    splitter->addWidget(chatGroupBox);

    QHBoxLayout *hbox = new QHBoxLayout;
    hbox->addWidget(splitter, 3);
    hbox->addWidget(userList, 1);

    aLeaveRoom = new QAction(this);
    connect(aLeaveRoom, SIGNAL(triggered()), this, SLOT(actLeaveRoom()));

    roomMenu = new QMenu(this);
    roomMenu->addAction(aLeaveRoom);
    addTabMenu(roomMenu);

    retranslateUi();
    setLayout(hbox);

    const int userListSize = info.user_list_size();
    for (int i = 0; i < userListSize; ++i)
        userList->processUserInfo(info.user_list(i), true);
    userList->sortItems();

    const int gameListSize = info.game_list_size();
    for (int i = 0; i < gameListSize; ++i)
        gameSelector->processGameInfo(info.game_list(i));
}
开发者ID:DeanWay,项目名称:Cockatrice,代码行数:80,代码来源:tab_room.cpp


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