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


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

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


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

示例1: Point

QList<Point> ChartLine::getPoints()
{
    if (numberOfPoints == 0)
        return QList<Point>();

    QList<Point> points;
    //points.reserve(numberOfPoints);

    if (fabs(angle) < EPS_ZERO)
    {
        double dx = (end.x - start.x) / (numberOfPoints - 1);
        double dy = (end.y - start.y) / (numberOfPoints - 1);

        for (int i = 0; i < numberOfPoints; i++)
            if (reverse)
                points.insert(0, Point(start.x + i*dx, start.y + i*dy));
            else
                points.append(Point(start.x + i*dx, start.y + i*dy));
    }
    else
    {
        Point center = centerPoint(start, end, angle);
        double radius = (start - center).magnitude();
        double startAngle = atan2(center.y - start.y, center.x - start.x) / M_PI*180 - 180;
        double theta = angle / double(numberOfPoints - 1);

        for (int i = 0; i < numberOfPoints; i++)
        {
            double arc = (startAngle + i*theta)/180.0*M_PI;

            double x = radius * cos(arc);
            double y = radius * sin(arc);

            if (reverse)
                points.insert(0, Point(center.x + x, center.y + y));
            else
                points.append(Point(center.x + x, center.y + y));
        }
    }

    return points;
}
开发者ID:honzakac,项目名称:agros2d,代码行数:42,代码来源:chartdialog.cpp

示例2: set_func_list

/**
 * @brief Draw the function list and decide whether to load the default selection configuration or not.
 * @param new_  A flag indicating whether to load the default selection configuration or not. Default value is `0`.
 * 0    Use user config.
 * 1    Use default config.
 */
void QDialogUI::set_func_list(int new_)
{
    ui->Functionlist->clear();
    ui->FunctionsBox->setTitle(QApplication::translate("Util", "Functions"));

    //if new,the data will be load from database,or we just use data from class member
    if(new_){
        for(int ip=0; ip<2; ip++){
            QList<QList<QVariant> > choice;
            std::map<int, QList<int> > defaults;
            QList<int> slices;
            redata_->get_choice(ip?true:false, choice, defaults, slices);
            if(QFile::exists(custom_)){
                QList<QVariant> a;
                a.append(4);
                a.append(1);
                a.append(0);
                a.append("customize");
                choice.insert(0, a);
                QList<int> b;
                b.push_back(1);
                defaults[0x04] = b;
                for(int i=0; i<slices.size(); i++){
                    slices[i] += 1;
                }
                slices.insert(0, 0);
            }
            this->choice_[ip] = choice;
            this->slices_[ip] = slices;
            QList<int> funcs;
            for(int i=0; i<choice.size(); i++){
                int id = (choice[i][0].toInt());
                if(defaults[id].indexOf(choice[i][1].toInt()) >= 0){
                    funcs.append(1);
                }else{
                    funcs.append(0);
                }
            }
            funcs_[ip] = funcs;
        }
    }
}
开发者ID:AllenWeb,项目名称:hoststool-cpp,代码行数:48,代码来源:qdialogui.cpp

示例3: while

QTreeWidgetItem* ProgressTree2::findItem(Job* job, bool create)
{
    QList<Job*> path;
    Job* v = job;
    while (v) {
        path.insert(0, v);
        v = v->parentJob;
    }

    QTreeWidgetItem* c = 0;
    for (int i = 0; i < path.count(); i++) {
        Job* toFind = path.at(i);
        QTreeWidgetItem* found = 0;
        if (i == 0) {
            for (int j = 0; j < this->topLevelItemCount(); j++) {
                QTreeWidgetItem* item = this->topLevelItem(j);
                Job* v = getJob(*item);
                if (v == toFind) {
                    found = item;
                    break;
                }
            }
        } else {
            for (int j = 0; j < c->childCount(); j++) {
                QTreeWidgetItem* item = c->child(j);
                Job* v = getJob(*item);
                if (v == toFind) {
                    found = item;
                    break;
                }
            }
        }
        if (found)
            c = found;
        else {
            if (create) {
                if (!toFind->parentJob)
                    c = addJob(toFind);
                else {
                    QTreeWidgetItem* subItem = new QTreeWidgetItem(c);
                    fillItem(subItem, toFind);
                    if (autoExpandNodes)
                        c->setExpanded(true);
                    c = subItem;
                }
            } else {
                c = 0;
                break;
            }
        }
    }

    return c;
}
开发者ID:mariusvam,项目名称:windows-package-manager.npackd-cpp,代码行数:54,代码来源:progresstree2.cpp

示例4: insertHandle

void RelationItem::insertHandle(int beforeIndex, const QPointF &pos)
{
    if (beforeIndex >= 1 && beforeIndex <= m_relation->intermediatePoints().size() + 1) {
        QList<DRelation::IntermediatePoint> intermediatePoints = m_relation->intermediatePoints();
        intermediatePoints.insert(beforeIndex - 1, DRelation::IntermediatePoint(pos));

        m_diagramSceneModel->diagramController()->startUpdateElement(m_relation, m_diagramSceneModel->diagram(), DiagramController::UpdateMajor);
        m_relation->setIntermediatePoints(intermediatePoints);
        m_diagramSceneModel->diagramController()->finishUpdateElement(m_relation, m_diagramSceneModel->diagram(), false);
    }
}
开发者ID:mbenelli,项目名称:qt-creator,代码行数:11,代码来源:relationitem.cpp

示例5: aggregationMenuAboutToShow

void Widget::aggregationMenuAboutToShow()
{
  KMenu * menu = dynamic_cast< KMenu * >( sender() );
  if ( !menu )
    return;

  menu->clear();

  menu->addTitle( i18n( "Aggregation" ) );

  QActionGroup * grp = new QActionGroup( menu );

  const QHash< QString, Aggregation * > & aggregations = Manager::instance()->aggregations();

  QAction * act;

  QList< const Aggregation * > sortedAggregations;

  for ( QHash< QString, Aggregation * >::ConstIterator ci = aggregations.constBegin(); ci != aggregations.constEnd(); ++ci )
  {
    int idx = 0;
    int cnt = sortedAggregations.count();
    while ( idx < cnt )
    {
      if ( sortedAggregations.at( idx )->name() > ( *ci )->name() )
      {
        sortedAggregations.insert( idx, *ci );
        break;
      }
      idx++;
    }

    if ( idx == cnt )
      sortedAggregations.append( *ci );
  }

  for ( QList< const Aggregation * >::ConstIterator it = sortedAggregations.constBegin(); it != sortedAggregations.constEnd(); ++it )
  {
    act = menu->addAction( ( *it )->name() );
    act->setCheckable( true );
    grp->addAction( act );
    act->setChecked( d->mLastAggregationId == ( *it )->id() );
    act->setData( QVariant( ( *it )->id() ) );
    connect( act, SIGNAL( triggered( bool ) ),
             SLOT( aggregationSelected( bool ) ) );
  }

  menu->addSeparator();

  act = menu->addAction( i18n( "Configure..." ) );
  act->setData( QVariant( QString() ) );
  connect( act, SIGNAL( triggered( bool ) ),
           SLOT( aggregationSelected( bool ) ) );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:54,代码来源:widgetbase.cpp

示例6: insert

    ZVariant insert(const QList<ZVariant> &args)
    {
        if (args.count() > 2) {
            QList<ZVariant> list = args.first().toList();

            list.insert(args.at(1).toInt(), args.at(2));
            args.first().depthCopyAssign(list);
        }

        return ZVariant();
    }
开发者ID:zccrs,项目名称:zScript,代码行数:11,代码来源:zbase.cpp

示例7: foreach

QList<QString> KoHistogramProducerFactoryRegistry::keysCompatibleWith(const KoColorSpace* colorSpace) const
{
    QList<QString> list;
    QList<float> preferredList;
    foreach(const QString &id, keys()) {
        KoHistogramProducerFactory *f = value(id);
        if (f->isCompatibleWith(colorSpace)) {
            float preferred = f->preferrednessLevelWith(colorSpace);
            QList<float>::iterator pit = preferredList.begin();
            QList<float>::iterator pend = preferredList.end();
            QList<QString>::iterator lit = list.begin();

            while (pit != pend && preferred <= *pit) {
                ++pit;
                ++lit;
            }

            list.insert(lit, id);
            preferredList.insert(pit, preferred);
        }
    }
开发者ID:KDE,项目名称:calligra-history,代码行数:21,代码来源:KoHistogramProducer.cpp

示例8: QListGuiErrorCheckfromScriptValue

void QListGuiErrorCheckfromScriptValue(const QScriptValue &obj, QList<GuiErrorCheck> &list)
{
  list = QList<GuiErrorCheck>();
  QScriptValueIterator it(obj);

  while (it.hasNext()) {
    it.next();
    if (it.flags() & QScriptValue::SkipInEnumeration)
      continue;
    GuiErrorCheck item = qscriptvalue_cast<GuiErrorCheck>(it.value());
    list.insert(it.name().toInt(), item);
  }
}
开发者ID:szuke,项目名称:qt-client,代码行数:13,代码来源:guiErrorCheck.cpp

示例9: updateEntry

    void updateEntry(const QString &address, const QString &label, bool isMine, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending;

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
                break;
            }
            {
                CBitcoinAddress addr(address.toStdString());
                AddressTableEntry::Category cate = IsMyShare(*wallet, addr.Get()) ? AddressTableEntry::MultiSig : AddressTableEntry::Normal;

                parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
                cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address, cate));
                parent->endInsertRows();
            }
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
开发者ID:60E,项目名称:naocanfen,代码行数:51,代码来源:addresstablemodel.cpp

示例10: pluginsDir

//---------------------------------------------------------------------
// PosSettingsPluginsLoader::loadPlugins
// 
//---------------------------------------------------------------------
QList<PosSettingsAdvInterface*> PosSettingsPluginsLoader::loadPlugins()
    {
    qDebug() << "+ PosSettingsPluginsLoader::loadPlugins()";
    // parse the default cen rep key value which is used to determine
    // the order of loading the default positioning settings plugins
    ParseCenRepKey();
    // List containing the plugins implementing the PositioningSettingsAdvancedInterface
    QList<PosSettingsAdvInterface*> pluginsList;
    // Check for the files under the positioningsettings directory
    QDir pluginsDir(PLUGIN_PATH + QDir::separator());
    QFileInfoList fileInfoList = pluginsDir.entryInfoList();
    // check each file in this directory,only if its a dll give it to the
    // plugin loader
    foreach ( const QFileInfo &fileInfo, fileInfoList )
            {
            QString fileName = fileInfo.absoluteFilePath();
						qDebug() << "Filename: " <<  fileName;
						
            if (!QLibrary::isLibrary(fileName))
                {
                continue;
                }
            // load the dlls using QPluginLoader
            QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
            qDebug() << "Plugin Filename: " <<  pluginsDir.absoluteFilePath(fileName);
            QObject *plugin = pluginLoader.instance();
            // Check if the plugin found is an implementation of the
            // PosSettingsAdvInterface,if yes add it to the plugins list

            if (plugin)
                {
                PosSettingsAdvInterface* advancedInterface = qobject_cast<
                        PosSettingsAdvInterface *> (plugin);

                if (advancedInterface)
                    {
                    
                    QString dllName = fileInfo.baseName();
                    // check the position into which the plugin needs to be
                    // inserted if it is one of the default plugins
                    for (int i = 0; i < mDllNameList.count(); i++)
                        {
                        if (dllName.compare(mDllNameList[i],Qt::CaseInsensitive) == KErrNone)
                            {
                            pluginsList.insert(i, advancedInterface);
                            break;
                            }
                        }
                    }
                }
            }
开发者ID:cdaffara,项目名称:symbiandump-mw2,代码行数:55,代码来源:possettingspluginsloader.cpp

示例11: testSTLIterators

void tst_QList::testSTLIterators() const
{
    QList<QString> list;

    // create a list
    list << "foo" << "bar" << "baz";
    QList<QString>::iterator it = list.begin();
    QCOMPARE(*it, QLatin1String("foo")); it++;
    QCOMPARE(*it, QLatin1String("bar")); it++;
    QCOMPARE(*it, QLatin1String("baz")); it++;
    QCOMPARE(it, list.end()); it--;

    // walk backwards
    QCOMPARE(*it, QLatin1String("baz")); it--;
    QCOMPARE(*it, QLatin1String("bar")); it--;
    QCOMPARE(*it, QLatin1String("foo"));

    // test erase
    it = list.erase(it);
    QVERIFY(list.size() == 2);
    QCOMPARE(*it, QLatin1String("bar"));

    // test multiple erase
    it = list.erase(it, it + 2);
    QVERIFY(list.size() == 0);
    QCOMPARE(it, list.end());

    // insert again
    it = list.insert(it, QLatin1String("foo"));
    QVERIFY(list.size() == 1);
    QCOMPARE(*it, QLatin1String("foo"));

    // insert again
    it = list.insert(it, QLatin1String("bar"));
    QVERIFY(list.size() == 2);
    QCOMPARE(*it++, QLatin1String("bar"));
    QCOMPARE(*it, QLatin1String("foo"));
}
开发者ID:KDE,项目名称:android-qt,代码行数:38,代码来源:tst_qlist.cpp

示例12: insertClientIntoChain

void FocusChain::insertClientIntoChain(Client *client, QList< Client * >& chain)
{
    if (chain.contains(client)) {
        return;
    }
    if (m_activeClient && m_activeClient != client &&
            !chain.empty() && chain.last() == m_activeClient) {
        // Add it after the active client
        chain.insert(chain.size() - 1, client);
    } else {
        // Otherwise add as the first one
        chain.append(client);
    }
}
开发者ID:fluxer,项目名称:kde-workspace,代码行数:14,代码来源:focuschain.cpp

示例13: setSelections

void SelectableTextEditorWidget::setSelections(const QMap<int, QList<DiffSelection> > &selections)
{
    m_diffSelections.clear();
    QMapIterator<int, QList<DiffSelection> > itBlock(selections);
    while (itBlock.hasNext()) {
        itBlock.next();

        const QList<DiffSelection> diffSelections = itBlock.value();
        QList<DiffSelection> workingList;
        for (int i = 0; i < diffSelections.count(); i++) {
            const DiffSelection &diffSelection = diffSelections.at(i);

            if (diffSelection.start == -1 && diffSelection.end == 0)
                continue;

            if (diffSelection.start == diffSelection.end && diffSelection.start >= 0)
                continue;

            int j = 0;
            while (j < workingList.count()) {
                const DiffSelection existingSelection = workingList.takeAt(j);
                const QList<DiffSelection> newSelection = subtractSelection(existingSelection, diffSelection);
                for (int k = 0; k < newSelection.count(); k++)
                    workingList.insert(j + k, newSelection.at(k));
                j += newSelection.count();
            }
            workingList.append(diffSelection);
        }
        const int blockNumber = itBlock.key();
        QVector<QTextLayout::FormatRange> selList;
        for (int i = 0; i < workingList.count(); i++) {
            const DiffSelection &diffSelection = workingList.at(i);
            if (diffSelection.format) {
                QTextLayout::FormatRange formatRange;
                formatRange.start = diffSelection.start;
                if (formatRange.start < 0)
                    formatRange.start = 0;
                formatRange.length = diffSelection.end < 0
                        ? INT_MAX
                        : diffSelection.end - diffSelection.start;
                formatRange.format = *diffSelection.format;
                if (diffSelection.end < 0)
                    formatRange.format.setProperty(QTextFormat::FullWidthSelection, true);
                selList.append(formatRange);
            }
        }
        m_diffSelections.insert(blockNumber, workingList);
    }
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:49,代码来源:selectabletexteditorwidget.cpp

示例14: setTwoColumns

    void setTwoColumns(const bool twoColumns)
    {
        if(twoColumns == m_twoColumns)
            return;

        Q_Q(SimpleListView);
        m_twoColumns = twoColumns;

#if (QT_VERSION >= 0x040600)
        bool cache = q->listItemCaching();
        q->setListItemCaching(false);
#endif
        QList<QGraphicsLayoutItem *> moveditems;
        if(twoColumns) {
            int half = m_layout->count()/2;
            for (int i = m_layout->count()-1; i>=half; --i) {
                QGraphicsLayoutItem *item = m_layout->itemAt(i);
                m_layout->removeAt(i);
                moveditems.append(item);
            }            
            for ( int i = 0; i < moveditems.count(); ++i)
                m_layout->addItem(moveditems.at(i), i, 1);

            m_layout->setColumnSpacing(0,0);
            m_layout->setColumnSpacing(1,0);
            m_layout->setRowSpacing(0,0);
            m_layout->setRowSpacing(1,0);
        }
        else {
            int count = m_layout->count()/2;
            for (int i = m_layout->count()-1;  i>=0; --i) {
                if (i >= count)
                    moveditems.append(m_layout->itemAt(i));
                else
                    moveditems.insert(moveditems.begin(), m_layout->itemAt(i));
                m_layout->removeAt(i);                
            }
            for (int i = 0; i<moveditems.count(); ++i) {
                m_layout->addItem(moveditems.at(i), m_layout->count(), 0);
            }
        }

        resizeContents(q->size());
        resizeScrollBars();

#if (QT_VERSION >= 0x040600)
        q->setListItemCaching(cache);
#endif
    }
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:49,代码来源:simplelistview.cpp

示例15: insert_crc

// inserts tid&crc value into an ordered list
// returns true if item is inserted
static bool insert_crc(QList<uint64_t> &seen_crc, const PSIPTable &psip)
{
    uint64_t key = (((uint64_t)psip.TableID()) << 32) | psip.CRC();

    QList<uint64_t>::iterator it =
        lower_bound(seen_crc.begin(), seen_crc.end(), key);

    if ((it == seen_crc.end()) || (*it != key))
    {
        seen_crc.insert(it, key);
        return true;
    }

    return false;
}
开发者ID:,项目名称:,代码行数:17,代码来源:


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