本文整理汇总了C++中qmodelindexlist::iterator::row方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::row方法的具体用法?C++ iterator::row怎么用?C++ iterator::row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qmodelindexlist::iterator
的用法示例。
在下文中一共展示了iterator::row方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeRows
void CommandDataModel::removeRows(QModelIndexList indices)
{
while (!indices.empty()) {
const int row = indices.takeFirst().row();
if (row >= mCommands.size())
continue;
beginRemoveRows(QModelIndex(), row, row);
mCommands.removeAt(row);
// Decrement later indices since we removed a row
for (QModelIndexList::iterator i = indices.begin(); i != indices.end();
++i)
if (i->row() > row)
*i = i->sibling(i->row() - 1, i->column());
endRemoveRows();
}
}
示例2: updateButtonsStates
void TourWidgetPrivate::updateButtonsStates()
{
QModelIndexList selectedIndexes = m_tourUi.m_listView->selectionModel()->selectedIndexes();
if ( selectedIndexes.isEmpty() ) {
m_tourUi.m_actionDelete->setEnabled( false );
m_tourUi.m_actionMoveDown->setEnabled( false );
m_tourUi.m_actionMoveUp->setEnabled( false );
} else {
m_tourUi.m_actionDelete->setEnabled( true );
qSort( selectedIndexes.begin(), selectedIndexes.end(), qLess<QModelIndex>() );
QModelIndexList::iterator end = selectedIndexes.end()-1;
QModelIndexList::iterator start = selectedIndexes.begin();
m_tourUi.m_actionMoveUp->setEnabled( ( start->row() != 0 ) ); // if we can move up enable action else disable.
GeoDataObject *rootObject = rootIndexObject();
if ( rootObject && rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
m_tourUi.m_actionMoveDown->setEnabled( ( end->row() != playlist->size()-1 ) ); // if we can move down enable action else disable.
}
}
}
示例3: on_deselectPlyButton_pressed
void LineEditDialog::on_deselectPlyButton_pressed()
{
QModelIndexList selected = this->selectedPlyView->selectionModel()->selectedIndexes();
QStringList list = _allPly->stringList();
for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it)
{
list.append(it->data().toString());
_selPly->removeRow(it->row());
}
_allPly->setStringList(list);
}
示例4: on_selectGeoButton_pressed
void GMSHPrefsDialog::on_selectGeoButton_pressed()
{
QModelIndexList selected = this->allGeoView->selectionModel()->selectedIndexes();
QStringList list = _selGeo->stringList();
for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it)
{
list.append(it->data().toString());
_allGeo->removeRow(it->row());
}
_selGeo->setStringList(list);
}
示例5: on_m_pAddB_clicked
void DoubleList::on_m_pAddB_clicked()
{
QItemSelectionModel* pSelMdl (m_pAvailableG->selectionModel());
QModelIndexList lSel (pSelMdl->selection().indexes());
set<int> sSelPos; // the rows must be sorted
for (QModelIndexList::iterator it = lSel.begin(), end = lSel.end(); it != end; ++it)
{
int nRow (it->row());
CB_ASSERT (nRow >= 0);
sSelPos.insert(nRow);
}
add(sSelPos);
}
示例6: on_m_pDeleteB_clicked
void DoubleList::on_m_pDeleteB_clicked()
{
if (m_listPainter.m_vSel.empty()) { return; }
QItemSelectionModel* pSelMdl (m_pSelectedG->selectionModel());
QModelIndexList lSel (pSelMdl->selection().indexes());
set<int> sSelPos; // the rows must be sorted and the last must be processed first, so removal of elements doesn't change the row number for the remaining ones
for (QModelIndexList::iterator it = lSel.begin(), end = lSel.end(); it != end; ++it)
{
int nRow (it->row());
CB_ASSERT (nRow >= 0);
sSelPos.insert(nRow);
}
remove(sSelPos);
}
示例7: fixSelection
void FilesModel::fixSelection() // deselects cells that are selected but are on a different row from the "current" cell and selects the file name
{
// it works OK when getFltHandlers() is empty
QItemSelectionModel* pSelModel (m_pCommonData->m_pFilesG->selectionModel());
QModelIndexList lstSel (pSelModel->selection().indexes());
QModelIndex crt (m_pCommonData->m_pFilesG->selectionModel()->currentIndex());
int nCrtRow (crt.row());
int nCrtCol (crt.column());
if (0 == nCrtCol)
{
for (QModelIndexList::iterator it = lstSel.begin(), end = lstSel.end(); it != end; ++it)
{
if (0 != it->column())
{
pSelModel->select(*it, QItemSelectionModel::Deselect);
}
}
}
else
{
set<int> sSelectableColumns;
sSelectableColumns.insert(0);
for (int i = 0, n = cSize(m_pCommonData->getCrtNotes()); i < n; ++i) // ttt2 poor performance
{
const Note* pNote (m_pCommonData->getCrtNotes()[i]);
sSelectableColumns.insert(m_pCommonData->findPos(pNote) + 1);
}
for (QModelIndexList::iterator it = lstSel.begin(), end = lstSel.end(); it != end; ++it)
{
if ((it->row() != nCrtRow && 0 != it->column()) || 0 == sSelectableColumns.count(it->column()))
{
pSelModel->select(*it, QItemSelectionModel::Deselect);
}
}
if (nCrtRow >= 0)
{
pSelModel->select(index(nCrtRow, 0), QItemSelectionModel::Select);
}
}
}
示例8: moveDown
void TourWidgetPrivate::moveDown()
{
GeoDataObject *rootObject = rootIndexObject();
if ( rootObject && rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
QModelIndexList selected = m_tourUi.m_listView->selectionModel()->selectedIndexes();
qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
QModelIndexList::iterator end = selected.end();
QModelIndexList::iterator iter = selected.begin();
for( ; iter != end; ++iter ) {
int const index = iter->row();
Q_ASSERT( index < playlist->size()-1 );
m_widget->model()->treeModel()->swapTourPrimitives( playlistIndex, index, index+1 );
}
m_isChanged = true;
m_tourUi.m_actionSaveTour->setEnabled( true );
updateButtonsStates();
}
}
示例9: deleteSelected
void TourWidgetPrivate::deleteSelected()
{
QString title = QObject::tr( "Remove Selected Items" );
QString text = QObject::tr( "Are you sure want to remove selected items?" );
QPointer<QMessageBox> dialog = new QMessageBox( QMessageBox::Question, title, text, QMessageBox::Yes | QMessageBox::No, q );
dialog->setDefaultButton( QMessageBox::No );
if ( dialog->exec() == QMessageBox::Yes ) {
GeoDataObject *rootObject = rootIndexObject();
if ( rootObject && rootObject->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( rootObject );
QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
QModelIndexList selected = m_tourUi.m_listView->selectionModel()->selectedIndexes();
qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
QModelIndexList::iterator end = selected.end();
QModelIndexList::iterator iter = selected.begin();
for( ; iter != end; ++iter ) {
m_widget->model()->treeModel()->removeTourPrimitive( playlistIndex, iter->row() );
}
m_isChanged = true;
m_tourUi.m_actionSaveTour->setEnabled( true );
}
}
delete dialog;
}
示例10: matchSelToNotes
void FilesModel::matchSelToNotes()
{
QItemSelectionModel* pNotesSelModel (m_pCommonData->m_pNotesG->selectionModel());
QModelIndexList notesLstSel (pNotesSelModel->selection().indexes());
set<int> sSel;
for (QModelIndexList::iterator it = notesLstSel.begin(), end = notesLstSel.end(); it != end; ++it)
{
//cout << "cell sel at " << it->row() << "x" << it->column() << endl;
const Note* pNote (m_pCommonData->getCrtNotes()[it->row()]);
int nPos (m_pCommonData->findPos(pNote));
sSel.insert(nPos);
}
m_pCommonData->m_pFilesG->selectionModel()->clearSelection();
for (set<int>::const_iterator it = sSel.begin(), end = sSel.end(); it != end; ++it)
{
m_pCommonData->m_pFilesG->selectionModel()->select(index(m_pCommonData->getFilesGCrtRow(), *it + 1), QItemSelectionModel::Select);
//cout << "selecting " << m_pCommonData->getFilesGCrtRow() << "x" << *it + 1 << endl;
}
m_pCommonData->m_pFilesG->selectionModel()->select(index(m_pCommonData->getFilesGCrtRow(), 0), QItemSelectionModel::Select);
}