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


C++ const_iterator::row方法代码示例

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


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

示例1: removeRows

bool CQUnitDM::removeRows(QModelIndexList rows, const QModelIndex&)
{
  if (rows.isEmpty())
    return false;

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = &CCopasiRootContainer::getDatamodelList()->operator[](0);
  assert(pDataModel != NULL);
  CModel * pModel = pDataModel->getModel();

  if (pModel == NULL)
    return false;

  // Build the list of pointers to items to be deleted
  // before actually deleting any item.

  QList <CUnitDefinition *> pUnitDefQList;
  QModelIndexList::const_iterator i;
  CUnitDefinition * pUnitDef;

  for (i = rows.begin(); i != rows.end(); ++i)
    {
      if (!isDefaultRow(*i) &&
          (pUnitDef = &CCopasiRootContainer::getUnitList()->operator[](i->row())) != NULL &&
          pModel->getUnitSymbolUsage(pUnitDef->getSymbol()).empty() &&
          !pUnitDef->isReadOnly())//Don't delete built-ins or used units
        pUnitDefQList.append(&CCopasiRootContainer::getUnitList()->operator[](i->row()));
    }

  for (QList <CUnitDefinition *>::const_iterator j = pUnitDefQList.begin(); j != pUnitDefQList.end(); ++j)
    {
      size_t delRow =
        CCopasiRootContainer::getUnitList()->CCopasiVector< CUnitDefinition >::getIndex(*j);

      if (delRow != C_INVALID_INDEX)
        {
          CCopasiObject::DataObjectSet DeletedObjects;
          DeletedObjects.insert(*j);

          QMessageBox::StandardButton choice =
            CQMessageBox::confirmDelete(NULL, "unit",
                                        FROM_UTF8((*j)->getObjectName()),
                                        DeletedObjects);

          if (choice == QMessageBox::Ok)
            removeRow((int) delRow);
        }
    }

  return true;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:51,代码来源:CQUnitDM.cpp

示例2: removeRows

bool CQReportDM::removeRows(QModelIndexList rows, const QModelIndex&)
{
    if (rows.isEmpty())
        return false;

    assert(mpDataModel != NULL);

    CCopasiVector< CReportDefinition > * pReportList = mpDataModel->getReportDefinitionList();

    if (pReportList == NULL)
        return false;

    QList< CReportDefinition * > Reports;

    QModelIndexList::const_iterator i;

    for (i = rows.begin(); i != rows.end(); ++i)
    {
        if (!isDefaultRow(*i) && &pReportList->operator[](i->row()))
            Reports.append(&pReportList->operator[](i->row()));
    }

    QList< CReportDefinition * >::const_iterator j;

    for (j = Reports.begin(); j != Reports.end(); ++j)
    {
        CReportDefinition * pReport = *j;

        size_t delRow = pReportList->getIndex(pReport);

        if (delRow != C_INVALID_INDEX)
        {
            std::set< const CCopasiObject * > DeletedObjects;
            DeletedObjects.insert(pReport);

            QMessageBox::StandardButton choice =
                CQMessageBox::confirmDelete(NULL, "report",
                                            FROM_UTF8(pReport->getObjectName()),
                                            DeletedObjects);

            if (choice == QMessageBox::Ok)
            {
                removeRow((int) delRow);
            }
        }
    }

    return true;
}
开发者ID:copasi,项目名称:COPASI,代码行数:49,代码来源:CQReportDM.cpp

示例3: removeRows

bool CQFunctionDM::removeRows(QModelIndexList rows, const QModelIndex&)
{
  if (rows.isEmpty())
    return false;

  assert(mpDataModel != NULL);
  CModel * pModel = mpDataModel->getModel();

  if (pModel == NULL)
    return false;

//Build the list of pointers to items to be deleted
//before actually deleting any item.
  QList <CEvaluationTree *> pFunctions;
  CFunction * pFunction;
  QModelIndexList::const_iterator i;

  for (i = rows.begin(); i != rows.end(); ++i)
    {
      if (!isDefaultRow(*i) &&
          (pFunction = &CRootContainer::getFunctionList()->loadedFunctions()[i->row()]) != NULL &&
          !pFunction->isReadOnly())
        pFunctions.append(&CRootContainer::getFunctionList()->loadedFunctions()[i->row()]);
    }

  QList <CEvaluationTree *>::const_iterator j;

  for (j = pFunctions.begin(); j != pFunctions.end(); ++j)
    {
      CEvaluationTree * pFunction = *j;

      size_t delRow =
        CRootContainer::getFunctionList()->loadedFunctions().CDataVector< CFunction >::getIndex(pFunction);

      if (delRow != C_INVALID_INDEX)
        {
          QMessageBox::StandardButton choice =
            CQMessageBox::confirmDelete(NULL, "function",
                                        FROM_UTF8(pFunction->getObjectName()),
                                        pFunction);

          if (choice == QMessageBox::Ok)
            removeRow((int) delRow);
        }
    }

  return true;
}
开发者ID:copasi,项目名称:COPASI,代码行数:48,代码来源:CQFunctionDM.cpp

示例4: selectedIndexes

QList<int>* listview_t::get_selectedIndexes()
{//descending
    QList<int>* result = new QList<int>;
    QVector<int> temp;
    QModelIndexList list = selectedIndexes();
    QModelIndexList::const_iterator it;
    for (it = list.constBegin(); it != list.constEnd(); it++)
        temp.push_back(it->row());

    if (!temp.empty())
    {
        for (int j = 0; j < temp.size() - 1; j++)
        {
            for (int i = 0; i < temp.size() - j - 1; i++)
                if (temp[i] > temp[i+1])
                {
                    int tmp = temp[i];
                    temp[i] = temp[i+1];
                    temp[i+1] = tmp;
                }
            result->push_back(temp[temp.size() - j - 1]);
        }
        result->push_back(temp[0]);
    }
    return result;
}
开发者ID:lisitsynSA,项目名称:Dance,代码行数:26,代码来源:listview_t.cpp

示例5: selectionModel

std::vector<std::string> CSVWorld::Table::listRevertableSelectedIds() const
{
    /// \todo Do not use hardcoded column numbers
    std::vector<std::string> revertableIds;

    if (mProxyModel->columnCount()>0)
    {
        QModelIndexList selectedRows = selectionModel()->selectedRows();

        for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
             ++iter)
        {
            QModelIndex index = mProxyModel->mapToSource (mProxyModel->index (iter->row(), 0));

            CSMWorld::RecordBase::State state =
                static_cast<CSMWorld::RecordBase::State> (
                mModel->data (mModel->index (index.row(), 1)).toInt());

            if (state!=CSMWorld::RecordBase::State_BaseOnly)
            {
                std::string id = mModel->data (mModel->index (index.row(), 0)).
                    toString().toUtf8().constData();

                revertableIds.push_back (id);
            }
        }
    }

    return revertableIds;
}
开发者ID:IanPAOConnor,项目名称:openmw,代码行数:30,代码来源:table.cpp

示例6: selectionModel

std::vector<std::string> CSVWorld::Table::listDeletableSelectedIds() const
{
    std::vector<std::string> deletableIds;

    if (mProxyModel->columnCount()>0)
    {
        QModelIndexList selectedRows = selectionModel()->selectedRows();

        for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
            ++iter)
        {
            QModelIndex index = mProxyModel->mapToSource (mProxyModel->index (iter->row(), 0));

            CSMWorld::RecordBase::State state =
                static_cast<CSMWorld::RecordBase::State> (
                mModel->data (mModel->index (index.row(), 1)).toInt());

            if (state!=CSMWorld::RecordBase::State_Deleted)
            {
                int columnIndex = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Id);

                std::string id = mModel->data (mModel->index (index.row(), columnIndex)).
                    toString().toUtf8().constData();

                deletableIds.push_back (id);
            }
        }
    }

    return deletableIds;
}
开发者ID:Riverwolf,项目名称:openmw,代码行数:31,代码来源:table.cpp

示例7: getSelectedIds

template<class T> std::vector<T> getSelectedIds(
  const QTableView* view,
  const QSqlQueryModel* model,
  const QString& colName)
{
  QModelIndexList selected = view->selectionModel()->selectedIndexes();
  std::vector<T> selectedIds;
  std::set<int> rows;
  for(
    QModelIndexList::const_iterator it = selected.begin();
    it != selected.end();
    ++it
  )
  {
    rows.insert(it->row()); 
  }
  for(
    std::set<int>::const_iterator it = rows.begin();
    it != rows.end();
    ++it
  )
  {
    QSqlRecord selectedRecord = model->record(*it);
    selectedIds.push_back(
      selectedRecord.value(colName).value<library_song_id_t>());
  }
  return selectedIds;
}
开发者ID:houdekk,项目名称:UDJ,代码行数:28,代码来源:Utils.hpp

示例8: removeSpecieRows

bool CQSpecieDM::removeSpecieRows(QModelIndexList rows, const QModelIndex&)
{
  if (rows.isEmpty())
    return false;

  GET_MODEL_OR(pModel, return false);

  switchToWidget(CCopasiUndoCommand::SPECIES);

  //Build the list of pointers to items to be deleted
  //before actually deleting any item.
  QList <CMetab *> pSpecies;
  QModelIndexList::const_iterator i;

  for (i = rows.begin(); i != rows.end(); ++i)
    {
      if (!isDefaultRow(*i) && &pModel->getMetabolites()[i->row()])
        pSpecies.append(&pModel->getMetabolites()[i->row()]);
    }

  QList <CMetab *>::const_iterator j;

  for (j = pSpecies.begin(); j != pSpecies.end(); ++j)
    {
      CMetab * pSpecie = *j;

      size_t delRow =
        pModel->getMetabolites().CCopasiVector< CMetab >::getIndex(pSpecie);

      if (delRow == C_INVALID_INDEX)
        continue;

      QMessageBox::StandardButton choice =
        CQMessageBox::confirmDelete(NULL, "species",
                                    FROM_UTF8(pSpecie->getObjectName()),
                                    pSpecie->getDeletedObjects());

      if (choice == QMessageBox::Ok)
        removeRow((int) delRow);
    }

  return true;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:43,代码来源:CQSpecieDM.cpp

示例9: selectedRows

// Helpers to retrieve model data
// Convenience to extract a list of selected indexes
QList<int> selectedRows(const QAbstractItemView *view)
{
    const QModelIndexList indexList = view->selectionModel()->selectedRows(0);
    if (indexList.empty())
        return QList<int>();
    QList<int> rc;
    const QModelIndexList::const_iterator cend = indexList.constEnd();
    for (QModelIndexList::const_iterator it = indexList.constBegin(); it != cend; ++it)
        rc.push_back(it->row());
    return rc;
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:13,代码来源:submiteditorwidget.cpp

示例10: CCopasiUndoCommand

RemoveSpecieRowsCommand::RemoveSpecieRowsCommand(
  QModelIndexList rows, CQSpecieDM * pSpecieDM, const QModelIndex&)
  : CCopasiUndoCommand("Species", SPECIES_REMOVE)
  , mpSpecieDM(pSpecieDM)
  , mRows(rows)
  , mpSpeciesData()
  , mFirstTime(true)
{
  GET_MODEL_OR_RETURN(pModel);

  QModelIndexList::const_iterator i;

  for (i = rows.begin(); i != rows.end(); ++i)
    {
      if (pSpecieDM->isDefaultRow(*i) || &pModel->getMetabolites()[i->row()] == NULL)
        continue;

      UndoSpeciesData *data = new UndoSpeciesData(&pModel->getMetabolites()[i->row()]);
      mpSpeciesData.append(data);
    }

  setText(QObject::tr(": Removed Species"));
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:23,代码来源:RemoveSpeciesRowsCommand.cpp

示例11: removeRows

bool CQCompartmentDM::removeRows(QModelIndexList rows, const QModelIndex& index)
{
  if (rows.isEmpty())
    return false;

  // Build the list of pointers to items to be deleted
  // before actually deleting any item.
  QList <CCompartment *> Compartments;
  QModelIndexList::const_iterator i;

  for (i = rows.begin(); i != rows.end(); ++i)
    if (!isDefaultRow(*i) &&
        &mpCompartments->operator[](i->row()) != NULL)
      {
        Compartments.append(&mpCompartments->operator[](i->row()));
      }

  QList< CCompartment * >::const_iterator j;

  for (j = Compartments.begin(); j != Compartments.end(); ++j)
    {
      CCompartment * pCompartment = *j;

      QMessageBox::StandardButton choice =
        CQMessageBox::confirmDelete(NULL, "compartment",
                                    FROM_UTF8(pCompartment->getObjectName()),
                                    pCompartment);

      if (choice == QMessageBox::Ok)
        {
          removeRows(mpCompartments->getIndex(pCompartment->getObjectName()), 1);
        }
    }

  return true;
}
开发者ID:copasi,项目名称:COPASI,代码行数:36,代码来源:CQCompartmentDM.cpp

示例12: startDrag

void ThumbView::startDrag(Qt::DropActions)
{
	QModelIndexList indexesList = selectionModel()->selectedIndexes();
	if (indexesList.isEmpty()) {
		return;
	}

	QDrag *drag = new QDrag(this);
	QMimeData *mimeData = new QMimeData;
	QList<QUrl> urls;
	for (QModelIndexList::const_iterator it = indexesList.constBegin(),
										end = indexesList.constEnd(); it != end; ++it)
	{
		urls << QUrl(thumbViewModel->item(it->row())->data(FileNameRole).toString());
	}
	mimeData->setUrls(urls);
	drag->setMimeData(mimeData);
	QPixmap pix;
	if (indexesList.count() > 1) {
		pix = QPixmap(128, 112);
		pix.fill(Qt::transparent);
		QPainter painter(&pix);
		painter.setBrush(Qt::NoBrush);
		painter.setPen(QPen(Qt::white, 2));
		int x = 0, y = 0, xMax = 0, yMax = 0;
		for (int i = 0; i < qMin(5, indexesList.count()); ++i) {
			QPixmap pix = thumbViewModel->item(indexesList.at(i).row())->icon().pixmap(72);
			if (i == 4) {
				x = (xMax - pix.width()) / 2;
				y = (yMax - pix.height()) / 2;
			}
			painter.drawPixmap(x, y, pix);
			xMax = qMax(xMax, qMin(128, x + pix.width()));
			yMax = qMax(yMax, qMin(112, y + pix.height()));
			painter.drawRect(x + 1, y + 1, qMin(126, pix.width() - 2), qMin(110, pix.height() - 2));
			x = !(x == y) * 56;
			y = !y * 40;
		}
		painter.end();
		pix = pix.copy(0, 0, xMax, yMax);
		drag->setPixmap(pix);
	} else {
		pix = thumbViewModel->item(indexesList.at(0).row())->icon().pixmap(128);
		drag->setPixmap(pix);
	}
	drag->setHotSpot(QPoint(pix.width() / 2, pix.height() / 2));
	drag->exec(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction, Qt::IgnoreAction);
}
开发者ID:JHooverman,项目名称:phototonic,代码行数:48,代码来源:thumbview.cpp

示例13: selectionModel

std::vector<std::string> CSVWorld::Table::listDeletableSelectedIds() const
{
    std::vector<std::string> deletableIds;

    if (mProxyModel->columnCount()>0)
    {
        QModelIndexList selectedRows = selectionModel()->selectedRows();

        for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
            ++iter)
        {
            QModelIndex index = mProxyModel->mapToSource (mProxyModel->index (iter->row(), 0));

            // check record state
            CSMWorld::RecordBase::State state =
                static_cast<CSMWorld::RecordBase::State> (
                mModel->data (mModel->index (index.row(), 1)).toInt());

            if (state==CSMWorld::RecordBase::State_Deleted)
                continue;

            // check other columns (only relevant for a subset of the tables)
            int dialogueTypeIndex =
                mModel->searchColumnIndex (CSMWorld::Columns::ColumnId_DialogueType);

            if (dialogueTypeIndex!=-1)
            {
                int type = mModel->data (mModel->index (index.row(), dialogueTypeIndex)).toInt();

                if (type!=ESM::Dialogue::Topic && type!=ESM::Dialogue::Journal)
                    continue;
            }

            // add the id to the collection
            int columnIndex = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Id);

            std::string id = mModel->data (mModel->index (index.row(), columnIndex)).
                toString().toUtf8().constData();

            deletableIds.push_back (id);
        }
    }

    return deletableIds;
}
开发者ID:restarian,项目名称:openmw,代码行数:45,代码来源:table.cpp

示例14: removeRows

void SheetTableView::removeRows()
{
    assert(sheet != 0);

    QModelIndexList rows = selectionModel()->selectedRows();
    std::vector<int> sortedRows;

    /* Make sure rows are sorted in descending order */
    for (QModelIndexList::const_iterator it = rows.begin(); it != rows.end(); ++it)
        sortedRows.push_back(it->row());
    std::sort(sortedRows.begin(), sortedRows.end(), std::greater<int>());

    /* Remove rows */
    Gui::Command::openCommand("Remove rows");
    for (std::vector<int>::const_iterator it = sortedRows.begin(); it != sortedRows.end(); ++it) {
        Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.removeRows('%s', %d)", sheet->getNameInDocument(),
                                rowName(*it).c_str(), 1);
    }
    Gui::Command::commitCommand();
    Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
}
开发者ID:pacificIT,项目名称:FreeCAD,代码行数:21,代码来源:SheetTableView.cpp

示例15: deleteSelectedLayouts

void CQLayoutsWidget::deleteSelectedLayouts()
{
  const QItemSelectionModel * pSelectionModel = mpTblLayouts->selectionModel();

  QModelIndexList mappedSelRows;
  size_t i, imax = mpLayoutsDM->rowCount();

  for (i = 0; i < imax; i++)
    {
      if (pSelectionModel->isRowSelected((int) i, QModelIndex()))
        {
          mappedSelRows.append(mpProxyModel->mapToSource(mpProxyModel->index((int) i, 0)));
        }
    }

  if (mappedSelRows.empty()) return;

  // We need to make sure that we remove the window mapped for each layout
  QModelIndexList::const_iterator it = mappedSelRows.begin();
  QModelIndexList::const_iterator end = mappedSelRows.end();

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CListOfLayouts * pListOfLayouts = (*CCopasiRootContainer::getDatamodelList())[0]->getListOfLayouts();

  for (; it != end; ++it)
    {
      LayoutWindowMap::iterator itWindow = mLayoutWindowMap.find((*pListOfLayouts)[it->row()]->getKey());

      if (itWindow != mLayoutWindowMap.end())
        {
          mLayoutWindowMap.erase(itWindow);
          delete itWindow->second;
        }
    }

  mpLayoutsDM->removeRows(mappedSelRows);
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:37,代码来源:CQLayoutsWidget.cpp


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