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


C++ QList类代码示例

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


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

示例1: tag

void TagModificationHelper::slotTagDelete(TAlbum* t)
{
    if (!t || t->isRoot())
    {
        return;
    }

    AlbumPointer<TAlbum> tag(t);

    // find number of subtags
    int children = 0;
    AlbumIterator iter(tag);

    while (iter.current())
    {
        ++children;
        ++iter;
    }

    // ask for deletion of children
    if (children)
    {
        int result = KMessageBox::warningContinueCancel(d->dialogParent,
                                                        i18np("Tag '%2' has one subtag. "
                                                              "Deleting this will also delete "
                                                              "the subtag. "
                                                              "Do you want to continue?",
                                                              "Tag '%2' has %1 subtags. "
                                                              "Deleting this will also delete "
                                                              "the subtags. "
                                                              "Do you want to continue?",
                                                              children,
                                                              tag->title()));

        if (result != KMessageBox::Continue || !tag)
        {
            return;
        }
    }

    QString message;
    QList<qlonglong> assignedItems = DatabaseAccess().db()->getItemIDsInTag(tag->id());

    if (!assignedItems.isEmpty())
    {
        message = i18np("Tag '%2' is assigned to one item. "
                        "Do you want to continue?",
                        "Tag '%2' is assigned to %1 items. "
                        "Do you want to continue?",
                        assignedItems.count(), tag->title());
    }
    else
    {
        message = i18n("Delete '%1' tag?", tag->title());
    }

    int result = KMessageBox::warningContinueCancel(0, message,
                                                    i18n("Delete Tag"),
                                                    KGuiItem(i18n("Delete"),
                                                             "edit-delete"));

    if (result == KMessageBox::Continue && tag)
    {
        emit aboutToDeleteTag(tag);
        QString errMsg;

        if (!AlbumManager::instance()->deleteTAlbum(tag, errMsg))
        {
            KMessageBox::error(0, errMsg);
        }
    }
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:72,代码来源:tagmodificationhelper.cpp

示例2: if

void QXmppDataForm::parse(const QDomElement &element)
{
    if (element.isNull())
        return;

    /* form type */
    const QString typeStr = element.attribute("type");
    if (typeStr == "form")
        m_type = QXmppDataForm::Form;
    else if (typeStr == "submit")
        m_type = QXmppDataForm::Submit;
    else if (typeStr == "cancel")
        m_type = QXmppDataForm::Cancel;
    else if (typeStr == "result")
        m_type = QXmppDataForm::Result;
    else
    {
        qWarning() << "Unknown form type" << typeStr;
        return;
    }

    /* form properties */
    m_title = element.firstChildElement("title").text();
    m_instructions = element.firstChildElement("instructions").text();

    QDomElement fieldElement = element.firstChildElement("field");
    while (!fieldElement.isNull())
    {
        QXmppDataForm::Field field;

        /* field type */
        QXmppDataForm::Field::Type type = static_cast<QXmppDataForm::Field::Type>(-1);
        const QString typeStr = fieldElement.attribute("type");
        struct field_type *ptr;
        for (ptr = field_types; ptr->str; ptr++)
        {
            if (typeStr == ptr->str)
            {
                type = ptr->type;
                break;
            }
        }
        if (type < 0)
            qWarning() << "Unknown field type" << typeStr;
        field.setType(type);

        /* field attributes */
        field.setLabel(fieldElement.attribute("label"));
        field.setKey(fieldElement.attribute("var"));

        /* field value(s) */
        if (type == QXmppDataForm::Field::BooleanField)
        {
            const QString valueStr = fieldElement.firstChildElement("value").text();
            field.setValue(valueStr == "1" || valueStr == "true");
        }
        else if (type == QXmppDataForm::Field::ListMultiField ||
            type == QXmppDataForm::Field::JidMultiField || 
            type == QXmppDataForm::Field::TextMultiField) 
        {
            QStringList values;
            QDomElement valueElement = fieldElement.firstChildElement("value");
            while (!valueElement.isNull())
            {
                values.append(valueElement.text());
                valueElement = valueElement.nextSiblingElement("value");
            }
            field.setValue(values);
        }
        else
        {
            field.setValue(fieldElement.firstChildElement("value").text());
        }

        /* field options */
        if (type == QXmppDataForm::Field::ListMultiField ||
            type == QXmppDataForm::Field::ListSingleField)
        { 
            QList<QPair<QString, QString> > options;
            QDomElement optionElement = fieldElement.firstChildElement("option");
            while (!optionElement.isNull())
            {
                options.append(QPair<QString, QString>(optionElement.attribute("label"),
                    optionElement.firstChildElement("value").text()));
                optionElement = optionElement.nextSiblingElement("option"); 
            }
            field.setOptions(options);
        }

        /* other properties */
        field.setDescription(fieldElement.firstChildElement("description").text());
        field.setRequired(!fieldElement.firstChildElement("required").isNull());

        m_fields.append(field);

        fieldElement = fieldElement.nextSiblingElement("field");
    }
}
开发者ID:chloerei,项目名称:qxmpp,代码行数:98,代码来源:QXmppDataForm.cpp

示例3: QDialog

RenderOptionsDialog::RenderOptionsDialog()
    : QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
{
    setWindowOpacity(0.75);
    setWindowTitle(tr("Options (double click to flip)"));
    QGridLayout *layout = new QGridLayout;
    setLayout(layout);
    layout->setColumnStretch(1, 1);

    int row = 0;

    QCheckBox *check = new QCheckBox(tr("Dynamic cube map"));
    check->setCheckState(Qt::Unchecked);
    // Dynamic cube maps are only enabled when multi-texturing and render to texture are available.
    check->setEnabled(glActiveTexture && glGenFramebuffersEXT);
    connect(check, SIGNAL(stateChanged(int)), this, SIGNAL(dynamicCubemapToggled(int)));
    layout->addWidget(check, 0, 0, 1, 2);
    ++row;

    QPalette palette;

    // Load all .par files
    // .par files have a simple syntax for specifying user adjustable uniform variables.
    QSet<QByteArray> uniforms;
    QList<QString> filter = QStringList("*.par");
    QList<QFileInfo> files = QDir(":/res/boxes/").entryInfoList(filter, QDir::Files | QDir::Readable);

    foreach (QFileInfo fileInfo, files) {
        QFile file(fileInfo.absoluteFilePath());
        if (file.open(QIODevice::ReadOnly)) {
            while (!file.atEnd()) {
                QList<QByteArray> tokens = file.readLine().simplified().split(' ');
                QList<QByteArray>::const_iterator it = tokens.begin();
                if (it == tokens.end())
                    continue;
                QByteArray type = *it;
                if (++it == tokens.end())
                    continue;
                QByteArray name = *it;
                bool singleElement = (tokens.size() == 3); // type, name and one value
                char counter[10] = "000000000";
                int counterPos = 8; // position of last digit
                while (++it != tokens.end()) {
                    m_parameterNames << name;
                    if (!singleElement) {
                        m_parameterNames.back() += "[";
                        m_parameterNames.back() += counter + counterPos;
                        m_parameterNames.back() += "]";
                        int j = 8; // position of last digit
                        ++counter[j];
                        while (j > 0 && counter[j] > '9') {
                            counter[j] = '0';
                            ++counter[--j];
                        }
                        if (j < counterPos)
                            counterPos = j;
                    }

                    if (type == "color") {
                        layout->addWidget(new QLabel(m_parameterNames.back()));
                        bool ok;
                        ColorEdit *colorEdit = new ColorEdit(it->toUInt(&ok, 16), m_parameterNames.size() - 1);
                        m_parameterEdits << colorEdit;
                        layout->addWidget(colorEdit);
                        connect(colorEdit, SIGNAL(colorChanged(QRgb,int)), this, SLOT(setColorParameter(QRgb,int)));
                        ++row;
                    } else if (type == "float") {
                        layout->addWidget(new QLabel(m_parameterNames.back()));
                        bool ok;
                        FloatEdit *floatEdit = new FloatEdit(it->toFloat(&ok), m_parameterNames.size() - 1);
                        m_parameterEdits << floatEdit;
                        layout->addWidget(floatEdit);
                        connect(floatEdit, SIGNAL(valueChanged(float,int)), this, SLOT(setFloatParameter(float,int)));
                        ++row;
                    }
                }
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:76,代码来源:scene.cpp

示例4: dropEvent

void CanvasObject::dropEvent(QDropEvent *event) {
  if(event->mimeData()->hasUrls()) {
    QList<QUrl> list = event->mimeData()->urls();
    if(list.count() == 1) cartridge.loadNormal(list.at(0).toLocalFile().toUtf8().constData());
  }
}
开发者ID:CatalystG,项目名称:mednafen-libretro,代码行数:6,代码来源:main.cpp

示例5: ProcesoSubScene

QList <Proceso *> ListaProcesos::getListaProcesosOrto(DataZoneProject *dataZoPro)
{
    QList <Proceso *> listaProcesos;
    if(dataZoPro->getCoordinateSystem()==DataZoneProject::Ed50)
    {
        if(dataZoPro->getFootPrintMask()==false && dataZoPro->getCutDtm()==false)
        {
                listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
        }
        if(dataZoPro->getFootPrintMask() && dataZoPro->getCutDtm())
        {
            listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
            listaProcesos.append(new ProcesoFootPrintMask(this,_qMapEjecutables.value("exeFootPrintMask")));
            listaProcesos.append(new ProcesoGeoTrans(this,_qMapEjecutables.value("exeGeoTransform")));
            listaProcesos.append(new ProcesoResize(this,_qMapEjecutables.value("exeResize")));
            listaProcesos.append(new ProcesoCutFiles(this,_qMapEjecutables.value("exeSubScene")));
        }
        if(dataZoPro->getFootPrintMask()==false && dataZoPro->getCutDtm())
        {
            listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
            listaProcesos.append(new ProcesoGeoTrans(this,_qMapEjecutables.value("exeGeoTransform")));
            listaProcesos.append(new ProcesoResize(this,_qMapEjecutables.value("exeResize")));
            listaProcesos.append(new ProcesoCutFiles(this,_qMapEjecutables.value("exeSubScene")));
        }
        if(dataZoPro->getFootPrintMask() && dataZoPro->getCutDtm()==false)
        {
            listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
            listaProcesos.append(new ProcesoFootPrintMask(this,_qMapEjecutables.value("exeFootPrintMask")));
            listaProcesos.append(new ProcesoGeoTrans(this,_qMapEjecutables.value("exeGeoTransform")));
            listaProcesos.append(new ProcesoResize(this,_qMapEjecutables.value("exeResize")));
        }
    }

    else //si el sistema de coordenadas es Etrs89 y Ntf
    {
        if(dataZoPro->getFootPrintMask()==false && dataZoPro->getCutDtm()==false)
        {
                listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
        }
        if(dataZoPro->getFootPrintMask() && dataZoPro->getCutDtm())
        {
            listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
            listaProcesos.append(new ProcesoResize(this,_qMapEjecutables.value("exeResize")));
            listaProcesos.append(new ProcesoFootPrintMask(this,_qMapEjecutables.value("exeFootPrintMask")));
            listaProcesos.append(new ProcesoCutFiles(this,_qMapEjecutables.value("exeSubScene")));
        }
        if(dataZoPro->getFootPrintMask()==false && dataZoPro->getCutDtm())
        {
            listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
            listaProcesos.append(new ProcesoResize(this,_qMapEjecutables.value("exeResize")));
            listaProcesos.append(new ProcesoCutFiles(this,_qMapEjecutables.value("exeSubScene")));
        }
        if(dataZoPro->getFootPrintMask() && dataZoPro->getCutDtm()==false)
        {
            listaProcesos.append(new ProcesoSubScene(this,_qMapEjecutables.value("exeSubScene")));
            listaProcesos.append(new ProcesoFootPrintMask(this,_qMapEjecutables.value("exeFootPrintMask")));
        }
    }
    return listaProcesos;
}
开发者ID:tonilogar,项目名称:OpePcot,代码行数:60,代码来源:listaprocesos.cpp

示例6: Q_D

//-----------------------------------------------------------------------------
void ctkTransferFunctionRepresentation::computeCurve()
{
  Q_D(ctkTransferFunctionRepresentation);

  int count = d->TransferFunction ? d->TransferFunction->count() : 0;
  if (count <= 0)
    {
    return;
    }

  d->TransferFunction->range(d->WorldRangeX[0], d->WorldRangeX[1]);
  d->WorldRangeY[0] = this->posY(d->TransferFunction->minValue());
  d->WorldRangeY[1] = this->posY(d->TransferFunction->maxValue());

  d->RangeXDiff   = this->computeRangeXDiff(d->rect(), d->WorldRangeX);
  d->RangeXOffSet = this->computeRangeXOffset(d->WorldRangeX);

  d->RangeYDiff   = this->computeRangeYDiff(d->rect(), d->WorldRangeY);
  d->RangeYOffSet = this->computeRangeYOffset(d->WorldRangeY);

  ctkControlPoint* startCP = d->TransferFunction->controlPoint(0);
  ctkControlPoint* nextCP = 0;

  QPointF startPos = this->mapPointToScene(startCP);

  d->Points.clear();
  d->Points << startPos;

  d->Path = QPainterPath();
  d->Path.moveTo(startPos);
  for(int i = 1; i < count; ++i)
    {
    nextCP = d->TransferFunction->controlPoint(i);
    if (this->transferFunction()->isDiscrete())
      {
      QPointF nextPos = this->mapPointToScene(nextCP);
      qreal midPosX = (startPos.x() + nextPos.x()) / 2.;

      d->Path.lineTo(QPointF(midPosX, startPos.y()));
      d->Path.lineTo(QPointF(midPosX, nextPos.y()));

      d->Points << nextPos;
      startPos = nextPos;
      if (i == count -1)
        {
        d->Path.lineTo(nextPos);
        }
      }
    else if (dynamic_cast<ctkNonLinearControlPoint*>(startCP))
      {
      QList<ctkPoint> points = this->nonLinearPoints(startCP, nextCP);
      int j;
      for (j = 1; j < points.count(); ++j)
        {
        d->Path.lineTo(this->mapPointToScene(points[j]));
        }
      j = points.count() - 1;
      d->Points << this->mapPointToScene(points[j]);
      }
    else //dynamic_cast<ctkBezierControlPoint*>(startCP))
      {
      QList<ctkPoint> points = this->bezierParams(startCP, nextCP);
      QList<ctkPoint>::iterator it = points.begin();
      QList<QPointF> bezierPoints;
      foreach(const ctkPoint& p, points)
        {
        bezierPoints << this->mapPointToScene(p);
        }
      d->Path.cubicTo(bezierPoints[1], bezierPoints[2], bezierPoints[3]);
      d->Points << bezierPoints[3];
      }
    //qDebug() << i << points[0] << points[1] << points[2] << points[3];
    delete startCP;
    startCP = nextCP;
    }
开发者ID:benoitbleuze,项目名称:CTK,代码行数:76,代码来源:ctkTransferFunctionRepresentation.cpp

示例7: AddWarningsOfNewFile

void LDFEditor::AddWarningsOfNewFile(double dVers)
{
    QList<QVariant> ouRow;
    int nRow = 0;
    m_pWarningTable->setRowCount(3);


    ouRow.push_back("Warning");
    ouRow.push_back("Valid LDF File should Contain Atleast one signal");
    ouRow.push_back("");
    m_pWarningTable->InsertRow(nRow, ouRow);
    nRow++;

    ouRow.clear();
    ouRow.push_back("Warning");
    ouRow.push_back("Valid LDF File should Contain Atleast one Unconditional Frame");
    ouRow.push_back("");
    m_pWarningTable->InsertRow(nRow, ouRow);
    nRow++;

    ouRow.clear();
    ouRow.push_back("Warning");
    ouRow.push_back("Valid LDF File should Contain Atleast one Schedule Table");
    ouRow.push_back("");
    m_pWarningTable->InsertRow(nRow, ouRow);

    ui.dockPaneWarning->show();
    nRow++;
}
开发者ID:ETAS-Nithin,项目名称:busmaster,代码行数:29,代码来源:ldfeditor.cpp

示例8: sortByFrequencyCustom

void ViewTableListWidget::sortByFrequencyCustom(bool ascend)
{
    QList<SortItem> list;
    for(int i = 0; i < rowCount(); i++)
    {
        SortItem newitem;
        newitem.row = i;
        newitem.frequecy = item(i,2)->text().toInt();
        int j = 0;
        if(ascend)
            for(j = list.count() - 1; j >=0 ; j--)
            {
                if(newitem.frequecy >= list.at(j).frequecy) break;
            }
        else
            for(j = list.count() - 1; j >=0 ; j--)
            {
                if(newitem.frequecy <= list.at(j).frequecy) break;
            }
        list.insert(j + 1,newitem);
    }
    QTableWidgetItem * tempitem;
    int temprowcount = rowCount();
    for(int i = 0; i < temprowcount; i++)
    {
        this->insertRow(temprowcount + i);
        tempitem = new QTableWidgetItem(item(list.at(i).row,0)->text());
        tempitem->setIcon(item(list.at(i).row,0)->icon());
        tempitem->setToolTip(item(list.at(i).row,0)->toolTip());
        setItem(temprowcount + i,0,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,1)->text());
        setItem(temprowcount + i,1,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,2)->text());
        tempitem->setTextAlignment(Qt::AlignCenter);
        setItem(temprowcount + i,2,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,3)->text());
        tempitem->setTextAlignment(Qt::AlignCenter);
        setItem(temprowcount + i,3,tempitem);
    }
    for(int i = 0; i < temprowcount; i++)
        removeRow(0);
    list.clear();
}
开发者ID:nhosproject,项目名称:OSProject,代码行数:43,代码来源:viewtablelistwidget.cpp

示例9: parseMeshes

void AssimpLoader::parseMeshes(aiMesh **meshes,
    const unsigned int numMeshes, QList<PolygonalDrawable *> &drawables) const
{
    for (unsigned int i = 0; i < numMeshes; i++)
        drawables.insert(i, parseMesh(*meshes[i]));
}
开发者ID:hpicgs,项目名称:cgsee,代码行数:6,代码来源:assimploader.cpp

示例10: boundMultipleTags

void TagModificationHelper::slotMultipleTagDel()
{
    QList<TAlbum*> lst = boundMultipleTags(sender());
    kDebug() << lst.size();
    slotMultipleTagDel(lst);
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:6,代码来源:tagmodificationhelper.cpp

示例11: foreach

void TagModificationHelper::slotMultipleTagDel(QList<TAlbum* >& tags)
{
    QString tagWithChildrens;
    QString tagWithImages;
    QMultiMap<int, TAlbum*> sortedTags;

    foreach(TAlbum* const t, tags)
    {

        if (!t || t->isRoot())
        {
            continue;
        }

        AlbumPointer<TAlbum> tag(t);

        // find number of subtags
        int children = 0;
        AlbumIterator iter(tag);

        while (iter.current())
        {
            ++children;
            ++iter;
        }

        if(children)
            tagWithChildrens.append(tag->title() + QString(" "));

        QList<qlonglong> assignedItems = DatabaseAccess().db()->getItemIDsInTag(tag->id());

        if(!assignedItems.isEmpty())
            tagWithImages.append(tag->title() + QString(" "));

        /**
         * Tags must be deleted from children to parents, if we don't want
         * to step on invalid index. Use QMultiMap to order them by distance
         * to root tag
         */

        Album* parent = t;
        int depth = 0;

        while(!parent->isRoot())
        {
            parent = parent->parent();
            depth++;
        }

        sortedTags.insert(depth,tag);

    }

    // ask for deletion of children

    if (!tagWithChildrens.isEmpty())
    {
        int result = KMessageBox::warningContinueCancel(0,
                                                        i18n("Tags '%1' have one or more subtags. "
                                                             "Deleting them will also delete "
                                                             "the subtags. "
                                                             "Do you want to continue?",
                                                             tagWithChildrens));

        if (result != KMessageBox::Continue)
        {
            return;
        }
    }

    QString message;

    if (!tagWithImages.isEmpty())
    {
        message = i18n("Tags '%1' are assigned to one or more items. "
                        "Do you want to continue?",
                        tagWithImages);
    }
    else
    {
        message = i18n("Delete '%1' tag(s)?", tagWithImages);
    }

    int result = KMessageBox::warningContinueCancel(0, message,
                                                    i18n("Delete Tag"),
                                                    KGuiItem(i18n("Delete"),
                                                            "edit-delete"));

    if (result == KMessageBox::Continue)
    {
        QMultiMap<int, TAlbum*>::iterator it;
        /**
         * QMultimap doesn't provide reverse iterator, -1 is required
         * because end() points after the last element
         */
        for(it = sortedTags.end()-1; it != sortedTags.begin()-1; --it)
        {
            emit aboutToDeleteTag(it.value());
            QString errMsg;

//.........这里部分代码省略.........
开发者ID:rickysarraf,项目名称:digikam,代码行数:101,代码来源:tagmodificationhelper.cpp

示例12: switch

void GameRule::onPhaseChange(ServerPlayer *player) const {
    Room *room = player->getRoom();
    switch(player->getPhase()) {
    case Player::Start: {
        player->setMark("SlashCount", 0);
        break;
    }
    case Player::Judge: {
        QList<const DelayedTrick *> tricks = player->delayedTricks();
        while(!tricks.isEmpty() && player->isAlive()) {
            const DelayedTrick *trick = tricks.takeLast();
            bool on_effect = room->cardEffect(trick, NULL, player);
            if(!on_effect)
                trick->onNullified(player);
        }

        break;
    }
    case Player::Draw: {
        QVariant num = 2;
        if(room->getTag("FirstRound").toBool() && room->getMode() == "02_1v1") {
            room->setTag("FirstRound", false);
            num = 1;
        }

        room->getThread()->trigger(DrawNCards, player, num);
        int n = num.toInt();
        if(n > 0)
            player->drawCards(n, false);
        break;
    }

    case Player::Play: {
        player->clearHistory();

        while(player->isAlive()) {
            CardUseStruct card_use;
            room->activate(player, card_use);
            if(card_use.isValid()) {
                room->useCard(card_use);
            } else
                break;
        }
        break;
    }

    case Player::Discard: {
        int discard_num = player->getHandcardNum() - player->getMaxCards();
        if(player->hasFlag("jilei")) {
            QSet<const Card *> jilei_cards;
            QList<const Card *> handcards = player->getHandcards();
            foreach(const Card *card, handcards) {
                if(player->isJilei(card))
                    jilei_cards << card;
            }

            if(jilei_cards.size() > player->getMaxCards()) {
                // show all his cards
                room->showAllCards(player);

                foreach(const Card *card, handcards.toSet() - jilei_cards) {
                    room->throwCard(card);
                }

                return;
            }
        }

        if(discard_num > 0)
            room->askForDiscard(player, "gamerule", discard_num);
        break;
    }
开发者ID:wenq1217,项目名称:msgs,代码行数:72,代码来源:gamerule.cpp

示例13: viewFilter

bool OneCardViewAsSkill::viewFilter(const QList<CardItem *> &selected, const CardItem *to_select) const{
    return selected.isEmpty() && viewFilter(to_select);
}
开发者ID:JasonWX,项目名称:QSanguosha,代码行数:3,代码来源:skill.cpp

示例14: ComplexValue

Value* ComplexValue::operation(Value& v, Expression::Operator_e op)
{
	auto* c=dynamic_cast<ComplexValue*>(&v);
	if(c) {
		if(imaginary.size()>2&&c->imaginary.size()>2) {
			Value* w1=real;
			Value* w2=c->real;

			Value* x1=imaginary.at(0);
			Value* x2=c->imaginary.at(0);

			Value* y1=imaginary.at(1);
			Value* y2=c->imaginary.at(1);

			Value* z1=imaginary.at(2);
			Value* z2=c->imaginary.at(2);

			if(op==Expression::Multiply) {
				//(Q1 * Q2).w = (w1w2 - x1x2 - y1y2 - z1z2)
				//(Q1 * Q2).x = (w1x2 + x1w2 + y1z2 - z1y2)
				//(Q1 * Q2).y = (w1y2 - x1z2 + y1w2 + z1x2)
				//(Q1 * Q2).z = (w1z2 + x1y2 - y1x2 + z1w2)
				Value *w,*x,*y,*z;
				Value* w1w2 = Value::operation(w1,op,w2);
				Value* x1x2 = Value::operation(x1,op,x2);
				Value* y1y2 = Value::operation(y1,op,y2);
				Value* z1z2 = Value::operation(z1,op,z2);
				w = Value::operation(w1w2,Expression::Subtract,x1x2);
				w = Value::operation(w,Expression::Subtract,y1y2);
				w = Value::operation(w,Expression::Subtract,z1z2);

				Value* w1x2 = Value::operation(w1,op,x2);
				Value* x1w2 = Value::operation(x1,op,w2);
				Value* y1z2 = Value::operation(y1,op,z2);
				Value* z1y2 = Value::operation(z1,op,y2);
				x = Value::operation(w1x2,Expression::Add,x1w2);
				x = Value::operation(x,Expression::Add,y1z2);
				x = Value::operation(x,Expression::Subtract,z1y2);

				Value* w1y2 = Value::operation(w1,op,y2);
				Value* x1z2 = Value::operation(x1,op,z2);
				Value* y1w2 = Value::operation(y1,op,w2);
				Value* z1x2 = Value::operation(z1,op,x2);
				y = Value::operation(w1y2,Expression::Subtract,x1z2);
				y = Value::operation(y,Expression::Add,y1w2);
				y = Value::operation(y,Expression::Add,z1x2);

				Value* w1z2 = Value::operation(w1,op,z2);
				Value* x1y2 = Value::operation(x1,op,y2);
				Value* y1x2 = Value::operation(y1,op,x2);
				Value* z1w2 = Value::operation(z1,op,w2);
				z = Value::operation(w1z2,Expression::Subtract,x1y2);
				z = Value::operation(z,Expression::Add,y1x2);
				z = Value::operation(z,Expression::Add,z1w2);

				QList<Value*> i;
				i.append(x);
				i.append(y);
				i.append(z);

				return new ComplexValue(w,i);
			} else if(op==Expression::Equal||op==Expression::NotEqual) {
				Value* eqRe=Value::operation(real,op,c->real);
				bool eq=eqRe->isTrue();
				if(op==Expression::NotEqual && !eq)
					return new BooleanValue(true);
				if(eq)
					for(auto i=0; i<3; ++i) {
						Value* eqIm=Value::operation(imaginary.at(i),op,c->imaginary.at(i));
						if(op==Expression::NotEqual && eqIm->isTrue())
							return new BooleanValue(true);
						if(eqIm->isFalse())
							eq=false;
					}
				return new BooleanValue(eq);
			}
		}
	}

	auto* n=dynamic_cast<NumberValue*>(&v);
	if(n) {
		if(op==Expression::Divide) {
			Value* w=Value::operation(real,Expression::Divide,n);
			QList<Value*> result;
			for(Value* i: imaginary) {
				Value* a=Value::operation(i,Expression::Divide,n);
				result.append(a);
			}
			return new ComplexValue(w,result);
		}
	}

	return Value::undefined();
}
开发者ID:GilesBathgate,项目名称:RapCAD,代码行数:94,代码来源:complexvalue.cpp

示例15: while

void MesytecMadc32UI::applySettings()
{
    applyingSettings = true;

    QList<QGroupBox*> gbs = findChildren<QGroupBox*>();
    if(!gbs.empty())
    {
        QList<QGroupBox*>::const_iterator it = gbs.begin();
        while(it != gbs.end())
        {
            QGroupBox* w = (*it);
            for(int ch=0; ch < MADC32V2_NUM_CHANNELS; ch++) {
                if(w->objectName() == tr("enable_channel%1").arg(ch)) w->setChecked(module->conf_.enable_channel[ch]);
            }
            it++;
        }
    }
    QList<QCheckBox*> cbs = findChildren<QCheckBox*>();
    if(!cbs.empty())
    {
        QList<QCheckBox*>::const_iterator it = cbs.begin();
        while(it != cbs.end())
        {
            QCheckBox* w = (*it);

            if(w->objectName() == "enable_multi_event_send_different_eob_marker") w->setChecked(module->conf_.enable_multi_event_send_different_eob_marker);
            if(w->objectName() == "enable_multi_event_compare_with_max_transfer_data") w->setChecked(module->conf_.enable_multi_event_compare_with_max_transfer_data);
            if(w->objectName() == "enable_adc_override") w->setChecked(module->conf_.enable_adc_override);
            if(w->objectName() == "enable_switch_off_sliding_scale") w->setChecked(module->conf_.enable_switch_off_sliding_scale);
            if(w->objectName() == "enable_skip_out_of_range") w->setChecked(module->conf_.enable_skip_out_of_range);
            if(w->objectName() == "enable_ignore_thresholds") w->setChecked(module->conf_.enable_ignore_thresholds);
            if(w->objectName() == "enable_termination_input_gate0") w->setChecked(module->conf_.enable_termination_input_gate0);
            if(w->objectName() == "enable_termination_input_fast_clear") w->setChecked(module->conf_.enable_termination_input_fast_clear);
            if(w->objectName() == "enable_external_time_stamp_reset") w->setChecked(module->conf_.enable_external_time_stamp_reset);

            it++;
        }
    }
    QList<QComboBox*> cbbs = findChildren<QComboBox*>();
    if(!cbbs.empty())
    {
        QList<QComboBox*>::const_iterator it = cbbs.begin();
        while(it != cbbs.end())
        {
            QComboBox* w = (*it);
            //printf("Found combobox with the name %s\n",w->objectName().toStdString().c_str());
            if(w->objectName() == "addr_source") w->setCurrentIndex(module->conf_.addr_source);
            if(w->objectName() == "multi_event_mode") w->setCurrentIndex(module->conf_.multi_event_mode);
            if(w->objectName() == "vme_mode") w->setCurrentIndex(module->conf_.vme_mode);
            if(w->objectName() == "data_length_format") w->setCurrentIndex(module->conf_.data_length_format);
            if(w->objectName() == "time_stamp_source") w->setCurrentIndex(module->conf_.time_stamp_source);
            if(w->objectName() == "adc_resolution") w->setCurrentIndex(module->conf_.adc_resolution);
            if(w->objectName() == "output_format") w->setCurrentIndex(module->conf_.output_format);
            if(w->objectName() == "gate_generator_mode") w->setCurrentIndex(module->conf_.gate_generator_mode);
            if(w->objectName() == "ecl_gate1_mode") w->setCurrentIndex(module->conf_.ecl_gate1_mode);
            if(w->objectName() == "ecl_fclear_mode") w->setCurrentIndex(module->conf_.ecl_fclear_mode);
            if(w->objectName() == "ecl_busy_mode") w->setCurrentIndex(module->conf_.ecl_busy_mode);
            if(w->objectName() == "nim_gate1_mode") w->setCurrentIndex(module->conf_.nim_gate1_mode);
            if(w->objectName() == "nim_fclear_mode") w->setCurrentIndex(module->conf_.nim_fclear_mode);
            if(w->objectName() == "input_range") {
                switch (module->conf_.input_range){
                case MesytecMadc32ModuleConfig::ir4V: w->setCurrentIndex(0); break;
                case MesytecMadc32ModuleConfig::ir8V: w->setCurrentIndex(1); break;
                case MesytecMadc32ModuleConfig::ir10V: w->setCurrentIndex(2); break;
                default: w->setCurrentIndex(2); break;
                }
            }
            if(w->objectName() == "marking_type") w->setCurrentIndex(module->conf_.marking_type);
            if(w->objectName() == "bank_operation") w->setCurrentIndex(module->conf_.bank_operation);
            if(w->objectName() == "test_pulser_mode") w->setCurrentIndex(module->conf_.test_pulser_mode);
            it++;
        }
    }
    QList<QSpinBox*> csb = findChildren<QSpinBox*>();
    if(!csb.empty())
    {
        QList<QSpinBox*>::const_iterator it = csb.begin();
        while(it != csb.end())
        {
            QSpinBox* w = (*it);
            //printf("Found spinbox with the name %s\n",w->objectName().toStdString().c_str());
            if(w->objectName() == "irq_level") w->setValue(module->conf_.irq_level);
            if(w->objectName() == "irq_vector") w->setValue(module->conf_.irq_vector);
            if(w->objectName() == "irq_threshold") w->setValue(module->conf_.irq_threshold);
            if(w->objectName() == "base_addr_register") w->setValue(module->conf_.base_addr_register);
            if(w->objectName() == "time_stamp_divisor") w->setValue(module->conf_.time_stamp_divisor);
            if(w->objectName() == "max_transfer_data") w->setValue(module->conf_.max_transfer_data);
            if(w->objectName() == "rc_module_id_read") w->setValue(module->conf_.rc_module_id_read);
            if(w->objectName() == "rc_module_id_write") w->setValue(module->conf_.rc_module_id_write);

            for(int ch=0; ch<2; ch++)
            {
                if(w->objectName() == tr("hold_delay_%1").arg(ch)) w->setValue(module->conf_.hold_delay[ch]);
                if(w->objectName() == tr("hold_width_%1").arg(ch)) w->setValue(module->conf_.hold_width[ch]);
            }
            for(int ch=0; ch<MADC32V2_NUM_CHANNELS; ch++)
            {
                if(w->objectName() == tr("thresholds%1").arg(ch)) w->setValue(module->conf_.thresholds[ch]);
            }
            it++;
//.........这里部分代码省略.........
开发者ID:mojca,项目名称:gecko,代码行数:101,代码来源:mesytecMadc32ui.cpp


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