本文整理汇总了C++中qmodelindexlist::const_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例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;
}
示例5: keyPressEvent
void TorrentContentTreeView::keyPressEvent(QKeyEvent *event) {
if (event->key() != Qt::Key_Space && event->key() != Qt::Key_Select) {
QTreeView::keyPressEvent(event);
return;
}
event->accept();
QModelIndex current = currentNameCell();
QVariant value = current.data(Qt::CheckStateRole);
if (!value.isValid()) {
Q_ASSERT(false);
return;
}
Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
QModelIndexList selection = selectionModel()->selectedRows(TorrentContentModelItem::COL_NAME);
for (QModelIndexList::const_iterator i = selection.begin(); i != selection.end(); ++i) {
QModelIndex index = *i;
Q_ASSERT(i->column() == TorrentContentModelItem::COL_NAME);
model()->setData(index, state, Qt::CheckStateRole);
}
}
示例6: 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;
}
示例7: QObjectVector
// Convert indexes to object vectors taking into account that
// some index lists are multicolumn ranges
static inline QObjectVector indexesToObjects(const ObjectInspectorModel *model, const QModelIndexList &indexes)
{
if (indexes.empty())
return QObjectVector();
QObjectVector rc;
rc.reserve(indexes.size());
const QModelIndexList::const_iterator icend = indexes.constEnd();
for (QModelIndexList::const_iterator it = indexes.constBegin(); it != icend; ++it)
if (it->column() == 0)
rc.push_back(model->objectAt(*it));
return rc;
}
示例8: mimeData
QMimeData* CategoryModel::mimeData(const QModelIndexList& indexes) const {
QMimeData *mimeData = new QMimeData;
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
for (QModelIndexList::const_iterator it = indexes.begin(); it != indexes.end(); ++it) {
quint64 address = reinterpret_cast<quint64>(it->internalPointer());
stream << address;
}
mimeData->setData("application/editor.categorymodel.index", encodedData);
return mimeData;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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);
}
示例12: 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;
}
示例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;
}
示例14: obj
QmitkDataNodeSelection::QmitkDataNodeSelection(
const QItemSelection& sel) :
mitk::DataNodeSelection(), berry::QtItemSelection(sel)
{
QModelIndexList indexes = sel.indexes();
for (QModelIndexList::const_iterator index = indexes.constBegin(); index
!= indexes.constEnd(); ++index)
{
QVariant data = index->data(QmitkDataNodeRole);
mitk::DataNode::Pointer node =
data.value<mitk::DataNode::Pointer> ();
if (node.IsNotNull())
{
berry::Object::Pointer obj(new mitk::DataNodeObject(node));
mitk::DataNodeSelection::m_Selection->push_back(obj);
}
}
}
示例15: editDatumTransform
void QgsDatumTransformTableWidget::editDatumTransform()
{
QModelIndexList selectedIndexes = mTableView->selectionModel()->selectedIndexes();
if ( selectedIndexes.count() > 0 )
{
QgsCoordinateReferenceSystem sourceCrs;
QgsCoordinateReferenceSystem destinationCrs;
int sourceTransform = -1;
int destinationTransform = -1;
for ( QModelIndexList::const_iterator it = selectedIndexes.constBegin(); it != selectedIndexes.constEnd(); it ++ )
{
switch ( it->column() )
{
case QgsDatumTransformTableModel::SourceCrsColumn:
sourceCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
break;
case QgsDatumTransformTableModel::DestinationCrsColumn:
destinationCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
break;
case QgsDatumTransformTableModel::SourceTransformColumn:
sourceTransform = mModel->data( *it, Qt::UserRole ).toInt();
break;
case QgsDatumTransformTableModel::DestinationTransformColumn:
destinationTransform = mModel->data( *it, Qt::UserRole ).toInt();
break;
default:
break;
}
}
if ( sourceCrs.isValid() && destinationCrs.isValid() &&
( sourceTransform != -1 || destinationTransform != -1 ) )
{
QgsDatumTransformDialog dlg( sourceCrs, destinationCrs, qMakePair( sourceTransform, destinationTransform ) );
if ( dlg.exec() )
{
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg.selectedDatumTransforms();
QgsCoordinateTransformContext context = mModel->transformContext();
// QMap::insert takes care of replacing existing value
context.addSourceDestinationDatumTransform( sourceCrs, destinationCrs, dt.first.second, dt.second.second );
mModel->setTransformContext( context );
}
}
}
}