本文整理汇总了C++中qmodelindexlist::iterator类的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iterator类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: keyPressEvent
/*
* F:
* void Editor::keyPressEvent(QKeyEvent *key_event)
* I:
* QKeyEvent *key_event - событие - нажатая кнопка
* O:
* --
* D:
* Функция реагирует на нажатие клавиш клавиатуры. если нажата клавиша delete и есть выделенные строки, то выделенные строки удалются.
*/
void EditorNew::keyPressEvent(QKeyEvent *key_event)
{
if (key_event->matches(QKeySequence::Delete) && sel_model->selectedRows().size() > 0)
{
QModelIndexList list; // список выделенных строк
QModelIndexList::iterator i; // итератор по выделенным строкам
int ind = 0;
int *sel_rows; // массив, элементы которого номера выделенных строк
sel_rows = new int[sel_model->selectedRows().size() + 1];
list = sel_model->selectedRows();
// Определяются номеров строк для удаления
for (i = list.begin(); i < list.end(); i ++)
{
if (i->row() < current_model->rowCount(QModelIndex()) - 1)
{
sel_rows[ind] = i->row();
ind ++;
}
}
sel_rows[ind] = -1;
// Удаление строк
if (sel_rows[0] != -1)
{
current_model->setItemsToDelete(sel_rows);
}
switch(tabs->currentIndex())
{
case 0:
item_edited = true;
break;
case 1:
item_type_edited = true;
break;
case 2:
water_edited = true;
break;
case 3:
location_edited = true;
break;
case 4:
factor_edited = true;
break;
default:
break;
}
delete sel_rows;
}
}
示例4: 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);
}
示例5: 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);
}
示例6: 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();
}
}
示例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: 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.
}
}
}
示例10: keyPressEvent
void Clean_tree_view::keyPressEvent(QKeyEvent* ev)
{
if (ev->key() == Qt::Key_Delete)
{
QModelIndexList indexes = selectedIndexes();
int row = -1;
int first_row = -1;
for (QModelIndexList::iterator i = indexes.begin(); i != indexes.end(); ++i)
{
if (row != i->row())
{
row = i->row();
if (first_row == -1)
first_row = i->row();
model()->removeRow(i->row(), i->parent());
}
}
// All rows removed
// Now select the new one selected row for fast massive deleting
if (first_row != -1)
{
selectionModel()->select(model()->index(first_row, 0, QModelIndex()),
QItemSelectionModel::Select);
}
emit clean_updated();
}
}
示例11: 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;
}
示例12: 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);
}