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


C++ QVariantList::replace方法代码示例

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


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

示例1: changePOTCAR

  void TabEdit::changePOTCAR(QListWidgetItem *item)
  {
    QSettings settings; // Already set up in avogadro/src/main.cpp

    // Get symbol and filename
    QStringList strl = item->text().split(":");
    QString symbol   = strl.at(0).trimmed();
    QString filename = strl.at(1).trimmed();

    QStringList files;
    QString path = settings.value("xtalopt/templates/potcarPath", "").toString();
    QFileDialog dialog (NULL, QString("Select pot file for atom %1").arg(symbol), path);
    dialog.selectFile(filename);
    dialog.setFileMode(QFileDialog::ExistingFile);
    if (dialog.exec()) {
      files = dialog.selectedFiles();
      if (files.size() != 1) { return;} // Only one file per element
      filename = files.first();
      settings.setValue("xtalopt/templates/potcarPath", dialog.directory().absolutePath());
    }
    else { return;} // User cancel file selection.
    // "POTCAR info" is of type
    // QList<QHash<QString, QString> >
    // e.g. a list of hashes containing
    // [atomic symbol : pseudopotential file] pairs
    QVariantList potcarInfo = m_opt->optimizer()->getData("POTCAR info").toList();
    QVariantHash hash = potcarInfo.at(ui_list_optStep->currentRow()).toHash();
    hash.insert(symbol,QVariant(filename));
    potcarInfo.replace(ui_list_optStep->currentRow(), hash);
    m_opt->optimizer()->setData("POTCAR info", potcarInfo);
    qobject_cast<VASPOptimizer*>(m_opt->optimizer())->buildPOTCARs();
    updateEditWidget();
  }
开发者ID:ajshamp,项目名称:XtalOpt-ajs,代码行数:33,代码来源:tab_edit.cpp

示例2: deleteRecord

void QuotesApp::deleteRecord()
{
    QVariantList indexPath = mListView->selected();

    if (!indexPath.isEmpty()) {
        QVariantMap map = mDataModel->data(indexPath).toMap();

        // Delete the item from the database based on unique ID. If successful, remove it
        // from the data model (which will remove the data from the list).
        if (mQuotesDbHelper->deleteById(map["id"])) {

            // Delete is the only operation where the logics for updating which item
            // is selected is handled in code.
            // Before the item is removed, we store how many items there are in the
            // category that the item is removed from, we need this to select a new item.
            QVariantList categoryIndexPath;
            categoryIndexPath.append(indexPath.first());
            int childrenInCategory = mDataModel->childCount(categoryIndexPath);

            mDataModel->remove(map);

            // After removing the selected item, we want another quote to be shown.
            // So we select the next quote relative to the removed one in the list.
            if (childrenInCategory > 1) {
                // If the Category still has items, select within the category.
                int itemInCategory = indexPath.last().toInt();

                if (itemInCategory < childrenInCategory - 1) {
                    mListView->select(indexPath);
                } else {
                    // The last item in the category was removed, select the previous item relative to the removed item.
                    indexPath.replace(1, QVariant(itemInCategory - 1));
                    mListView->select(indexPath);
                }
            } else {
                // If no items left in the category, move to the next category. 
                // If there are no more categories below(next), select the previous category.
                // If no items left at all, navigate to the list.
                QVariantList lastIndexPath = mDataModel->last();

                if (!lastIndexPath.isEmpty()) {
                    if (indexPath.first().toInt() <= lastIndexPath.first().toInt()) {
                        mListView->select(indexPath);
                    } else {
                        mListView->select(mDataModel->last());
                    }
                }
            } // else statment
        } //if statement
    } // top if statement
} // deleteRecord()
开发者ID:ProLove365,项目名称:Cascades-Samples,代码行数:51,代码来源:quotesapp.cpp

示例3: initPickerValues

void CustomItemProvider::initPickerValues(DataModel* pickerModel)
{
    QVariantList indexPath;
    indexPath << 0;

    // Get the number of columns by checking the child count of the models root element.
    mColumnCount = pickerModel->childCount(QVariantList());

    // The column range correspond to the child count of the models column data elements,
    // this information is reported back in the range function above.
    for (int i = 0; i < mColumnCount; i++) {
        indexPath.replace(0, i);
        mUpperRanges.insert(i, pickerModel->childCount(indexPath) - 1);
    }
}
开发者ID:13natty,项目名称:Cascades-Samples,代码行数:15,代码来源:customitemprovider.cpp

示例4: fieldData


//.........这里部分代码省略.........
            }
            case FieldTextValue:
            {
                QStringList list;

                for (int i = 0; i < data.sources_size(); i++)
                    list.append(QHostAddress(data.sources(i).v4()).toString());
                return list.join(", ");
            }
            default:
                break;
            }
            break;
        }
        case kGroupRecords:
        {
            switch(attrib)
            {
            case FieldValue:
            {
                QVariantList grpRecords = GmpProtocol::fieldData(
                        index, attrib, streamIndex).toList();

                for (int i = 0; i < data.group_records_size(); i++)
                {
                    QVariantMap grpRec = grpRecords.at(i).toMap();
                    OstProto::Gmp::GroupRecord rec = data.group_records(i);

                    grpRec["groupRecordAddress"] = QHostAddress(
                                rec.group_address().v4()).toString();

                    QStringList sl;
                    for (int j = 0; j < rec.sources_size(); j++)
                        sl.append(QHostAddress(rec.sources(j).v4()).toString());
                    grpRec["groupRecordSourceList"] = sl;

                    grpRecords.replace(i, grpRec);
                }
                return grpRecords;
            }
            case FieldFrameValue:
            {
                QVariantList list = GmpProtocol::fieldData(
                        index, attrib, streamIndex).toList();
                QByteArray fv;

                for (int i = 0; i < data.group_records_size(); i++)
                {
                    OstProto::Gmp::GroupRecord rec = data.group_records(i);
                    QByteArray rv = list.at(i).toByteArray();

                    rv.insert(4, QByteArray(4+4*rec.sources_size(), char(0)));
                    qToBigEndian(rec.group_address().v4(), 
                            (uchar*)(rv.data()+4));
                    for (int j = 0; j < rec.sources_size(); j++)
                    {
                        qToBigEndian(rec.sources(j).v4(),
                                (uchar*)(rv.data()+8+4*j));
                    }

                    fv.append(rv);
                }
                return fv;
            }
            case FieldTextValue:
            {
                QStringList list = GmpProtocol::fieldData(
                        index, attrib, streamIndex).toStringList();

                for (int i = 0; i < data.group_records_size(); i++)
                {
                    OstProto::Gmp::GroupRecord rec = data.group_records(i);
                    QString recStr = list.at(i);
                    QString str;

                    str.append(QString("Group: %1").arg(
                        QHostAddress(rec.group_address().v4()).toString()));

                    str.append("; Sources: ");
                    QStringList sl;
                    for (int j = 0; j < rec.sources_size(); j++)
                        sl.append(QHostAddress(rec.sources(j).v4()).toString());
                    str.append(sl.join(", "));

                    recStr.replace("XXX", str);
                    list.replace(i, recStr);
                }
                return list.join("\n").insert(0, "\n");
            }
            default:
                break;
            }
            break;
        }
        default:
            break;
    }

    return GmpProtocol::fieldData(index, attrib, streamIndex);
}
开发者ID:Raman325,项目名称:ostinato,代码行数:101,代码来源:igmp.cpp


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