QList<QED2KHandle> search_widget::on_actionDownload_triggered() { QList<QED2KHandle> result; QModelIndexList selected = treeResult->selectionModel()->selectedRows(); QModelIndexList::const_iterator iter; for (iter = selected.begin(); iter != selected.end(); ++iter) { result << addTransfer(*iter); } return result; }
void GMSHPrefsDialog::on_deselectGeoButton_pressed() { QModelIndexList selected = this->selectedGeoView->selectionModel()->selectedIndexes(); QStringList list = _allGeo->stringList(); for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) { list.append(it->data().toString()); _selGeo->removeRow(it->row()); } _allGeo->setStringList(list); }
void LineEditDialog::on_selectPlyButton_pressed() { QModelIndexList selected = this->allPlyView->selectionModel()->selectedIndexes(); QStringList list = _selPly->stringList(); for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); ++it) { list.append(it->data().toString()); _allPly->removeRow(it->row()); } _selPly->setStringList(list); }
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; }
bool QuadDataManager::get_tva_state ( const eTreeViewActions &action ) { uint num_checked_items = 0; uint num_unchecked_items = 0; QModelIndexList indexes = m_ui->datapiece_treeView->selectionModel()->selectedIndexes(); for ( QModelIndexList::iterator ind_it = indexes.begin();ind_it != indexes.end(); ++ind_it ) { TreeModel::_treeitem *item = static_cast<TreeModel::_treeitem*> ( ( *ind_it ).internalPointer() ); switch ( action ) { case TVA_SURF : if ( item->node->m_bShowSurface ) ++num_checked_items; else ++num_unchecked_items; break; case TVA_CPS : if ( item->node->m_bShowCps ) ++num_checked_items; else ++num_unchecked_items; break; case TVA_GRAPH : if ( item->node->m_bShowMsGraph ) ++num_checked_items; else ++num_unchecked_items; break; case TVA_QUADS : if ( item->node->m_bShowMsQuads ) ++num_checked_items; else ++num_unchecked_items; break; case TVA_GRAD : if ( item->node->m_bShowGrad ) ++num_checked_items; else ++num_unchecked_items; break; case TVA_CANCELABLE_PAIRS : if ( item->node->m_bShowCancelablePairs )++num_checked_items; else ++num_unchecked_items; break; } } if ( num_checked_items > num_unchecked_items ) return true; else return false; }
void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& file_details) { file_details.clear() ; #ifdef RDM_DEBUG std::cerr << "recommendSelected()" << std::endl; #endif if (RemoteMode) { #ifdef RDM_DEBUG std::cerr << "Cannot recommend remote! (should download)" << std::endl; #endif } /* Fire off requests */ std::set<std::string> already_in ; for(QModelIndexList::const_iterator it(list.begin()); it != list.end(); ++it) if(it->column()==0) { void *ref = it -> internalPointer(); DirDetails details; FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; if (!requestDirDetails(ref, details, flags)) continue; if(details.type == DIR_TYPE_PERSON) continue ; #ifdef RDM_DEBUG std::cerr << "::::::::::::FileRecommend:::: " << std::endl; std::cerr << "Name: " << details.name << std::endl; std::cerr << "Hash: " << details.hash << std::endl; std::cerr << "Size: " << details.count << std::endl; std::cerr << "Path: " << details.path << std::endl; #endif // Note: for directories, the returned hash, is the peer id, so if we collect // dirs, we need to be a bit more conservative for the if(already_in.find(details.hash+details.name) == already_in.end()) { file_details.push_back(details) ; already_in.insert(details.hash+details.name) ; } } #ifdef RDM_DEBUG std::cerr << "::::::::::::Done FileRecommend" << std::endl; #endif }
/* * 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; } }
QStringList Channel::findUserName(QString searchStr) { QStringList userList = QStringList(); QModelIndex startIndex = users->index(0, 0); QModelIndexList foundUsers = users->match(startIndex, User::UserDataName, searchStr, -1, Qt::MatchStartsWith); for(QModelIndexList::Iterator iter = foundUsers.begin(); iter != foundUsers.end(); iter++) { QStandardItem *user = users->itemFromIndex(*iter); QString username = user->data(User::UserDataName).value<QString>(); userList.append(username); } return userList; }
void RegisterDialog::removeRegisterRow() { // get list of selected rows QItemSelectionModel *selected = _pUi->registerView->selectionModel(); QModelIndexList rowList = selected->selectedRows(); // sort QModelIndexList // We need to remove the highest rows first std::sort(rowList.begin(), rowList.end(), &RegisterDialog::sortRegistersLastFirst); foreach(QModelIndex rowIndex, rowList) { _pRegisterModel->removeRow(rowIndex.row(), rowIndex.parent()); }
QList<CustomSymbol*> CustomSymbolView::getSelectedCustomSymbols() { QList<CustomSymbol*> ret; QModelIndexList selected = selectedIndexes(); for (QModelIndexList::iterator it = selected.begin(); it != selected.end(); it++) { CustomSymbolItem* itm = (CustomSymbolItem*) ((CustomSymbolItemModel*) model())->itemFromIndex(*it); if (itm) { ret.append(itm->getCustomSymbol()); } } return ret; }
void TableView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { QTableView::selectionChanged(selected,deselected); //on change la couleur des éléments selectionnés QModelIndexList list = selected.indexes(); QModelIndexList::Iterator it = list.begin(); for (int i=0;it!=list.end();it++,i++) { elementBase * elem = getSourceModel()->getElement((*it).row()); elem->invertColor(); } // on restaure la couleur original des éléments désélectionnés list = deselected.indexes(); it = list.begin(); for (int i=0;it!=list.end();it++,i++) { elementBase * elem = getSourceModel()->getElement((*it).row()); elem->invertColor(); } }
void FChannelListDialog::on_buttonBox_accepted() { QStringList channels; QModelIndexList selected = chTable->selectionModel()->selectedRows(FChannelListModel::colTitle); for (QModelIndexList::ConstIterator i = selected.begin(); i != selected.end(); i++) { QModelIndex realIndex = datasort->mapToSource(*i); uint rownum = realIndex.row(); FChannelSummary chan = data->byIndex(rownum); channels.push_back(chan.name); } emit joinRequested(channels); chTable->clearSelection(); }
//remove button clicked void AddFile_GUI::on_pushButton_4_clicked() { //get selected rows QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows(); qSort(indexes.begin(), indexes.end()); //remove last index in list while (!indexes.isEmpty()) { model->removeRows(indexes.last().row(), 1); indexes.removeLast(); } }
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; }
void ContactPanel::onContactDeletionRequested() { QItemSelectionModel* selectionModel = ui->ContactList->selectionModel(); QModelIndexList selectedList = selectionModel->selectedIndexes(); for (QModelIndexList::iterator it = selectedList.begin(); it != selectedList.end(); it++) { QString alias = m_contactListModel->data(*it, Qt::DisplayRole).toString(); for (int i = 0; i < m_contactAliasList.size(); i++) if (m_contactAliasList[i] == alias) { emit removeContact(m_contactIdList[i]); return; } } }
void CQMiriamWidget::deleteSelectedReferences() { QModelIndexList selRows = mpTblReferences->selectionModel()->selectedRows(0); if (selRows.empty()) {return;} QModelIndexList mappedSelRows; QModelIndexList::const_iterator i; for (i = selRows.begin(); i != selRows.end(); ++i) {mappedSelRows.append(mpReferencePDM->mapToSource(*i));} mpReferenceDM->removeRows(mappedSelRows); }
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; }
void CookiesDialog::onButtonDeleteClicked() { QModelIndexList idxs = m_ui->treeView->selectionModel()->selectedRows(); // sort in descending order std::sort(idxs.begin(), idxs.end(), [](const QModelIndex &l, const QModelIndex &r) { return (l.row() > r.row()); } ); for (const QModelIndex &idx : asConst(idxs)) m_cookiesModel->removeRow(idx.row()); }
QStringList ClipboardUrlsDialog::selectedUrls() const { if (!m_view->selectionModel()->hasSelection()) { return QStringList(); } QStringList list; QModelIndexList rows = m_view->selectionModel()->selectedRows(); qSort(rows.begin(), rows.end(), rowLessThan); for (int i = 0; i < rows.size(); i++) { list << rows.at(i).data().toString(); } return list; }
FmPathList* FolderView::selectedFilePaths() const { if(model_) { QModelIndexList selIndexes = mode == DetailedListMode ? selectedRows() : selectedIndexes(); if(!selIndexes.isEmpty()) { FmPathList* paths = fm_path_list_new(); QModelIndexList::const_iterator it; for(it = selIndexes.begin(); it != selIndexes.end(); ++it) { FmFileInfo* file = model_->fileInfoFromIndex(*it); fm_path_list_push_tail(paths, fm_file_info_get_path(file)); } return paths; } } return nullptr; }
void MainWindow::logSourceChange( QWidget* pWidget ) { QCheckBox* checkbox = qobject_cast<QCheckBox*>( pWidget ); QAbstractItemModel* model = mUI.logListWidget->model(); QModelIndexList list = model->match( model->index( 0, 0 ), Qt::UserRole + 1, checkbox->text(), -1 ); for( QModelIndexList::iterator i = list.begin();i != list.end(); ++i ) { model->setData( *i, checkbox->isChecked(), Qt::UserRole + 3 ); MainWindow::checkLogItem( *i ); } if( !list.empty() ) mUI.logListWidget->scrollToBottom(); }
void ExecutionListView::moveIndexToFolder() { QModelIndexList sel = selectedIndexes(); ExecutionListModel *model_p=_model(); if (! model_p) return; SortFilterProxy *sort_model_p=_sort_model(); for (QModelIndexList::Iterator it=sel.begin(); it!=sel.end(); ++it) { bool ok; QModelIndex index; if (sort_model_p) index=sort_model_p->mapToSource(*it); else index=*it; QString old_full_name=model_p->executionName(index); int pos=old_full_name.lastIndexOf("/"); QString old_path,old_name; if (pos>0) { old_path=old_full_name.mid(0,pos); old_name=old_full_name.mid(pos+1); } else { old_path=""; old_name=old_full_name; } QString new_path=QInputDialog::getText(this,tr("Move to folder"),tr("Folder:"),QLineEdit::Normal,old_path,&ok); QString new_full_name; if (new_path=="") new_full_name=old_name; else new_full_name=new_path+"/"+old_name; if (old_full_name==new_full_name) return; if (ok) ok=model_p->renameIndex(index,new_full_name); else return ; if (!ok) QMessageBox::warning ( this, tr("Renaming") , tr("Renaming %1 failed").arg(old_full_name),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); } }
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; }
QVector<int> toListViewFormatter::selectedRows( const QModelIndexList &selected) { QVector<int> ret; for (QList<QModelIndex>::const_iterator it = selected.begin(); it != selected.end(); it++) { int r = (*it).row(); if (!ret.contains(r)) ret.append(r); } return ret; }
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); }
void MainWindow::on_btn_Remove_clicked() { QModelIndexList qlst = ui->listView_selected->selectionModel()->selectedIndexes(); ui->listView_selected->setUpdatesEnabled(false); //QModelIndexList indexes = ui->listView->selectionModel()->selectedIndexes(); qSort(qlst.begin(), qlst.end()); for(int i = qlst.count() - 1; i > -1; --i) dataModel->compNameSelected->removeRow(qlst.at(i).row()); //qDebug()<<dataModel->compNameSelected->stringList().size(); int s = dataModel->compNameSelected->stringList().size(); dataModel->tlSelsListView.clear(); for(int i = 0; i<s; i++) dataModel->tlSelsListView.insert(i); ui->listView_selected->setUpdatesEnabled(true); emit timeLineChanged(); }
QVector<int> toListViewFormatter::selectedColumns( const QModelIndexList &selected) { QVector<int> ret; ret.append(0); // for later check for row headers for (QList<QModelIndex>::const_iterator it = selected.begin(); it != selected.end(); it++) { int c = (*it).column(); if (!ret.contains(c)) ret.append(c); } return ret; }
bool CQSpecieDM::removeRows(QModelIndexList rows, const QModelIndex&) { if (rows.isEmpty()) return false; assert(CCopasiRootContainer::getDatamodelList()->size() > 0); CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[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 <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) { QMessageBox::StandardButton choice = CQMessageBox::confirmDelete(NULL, "species", FROM_UTF8(pSpecie->getObjectName()), pSpecie->getDeletedObjects()); if (choice == QMessageBox::Ok) removeRow((int) delRow); } } return true; }
void ListingTable::updateData() { QModelIndexList sel = selectionModel()->selectedRows(); QList<unsigned int> selIds; for (QModelIndexList::iterator it = sel.begin() ; it != sel.end() ; it++) { QModelIndex idx = *it; selIds << model->getIndexID(idx); } QModelIndex cidx = currentIndex(); unsigned int cidxId = model->getIndexID(cidx); model->updateData(); QItemSelection newSel; unsigned int ns = 0; for (QList<unsigned int>::iterator it = selIds.begin() ; it != selIds.end() ; it++) { unsigned int id = *it; QModelIndex idx = model->getIndexWithID(id); if (idx.isValid()) { newSel.select(idx, model->index(idx.row(), model->columnCount()-1)); ns++; } } selectionModel()->select(newSel, QItemSelectionModel::Select); cidx = model->getIndexWithID(cidxId); setCurrentIndex(cidx); if (!cidx.isValid()) { // There is no current part. One way this could happen is if parts were previously selected, but they were all // removed. In this case, setCurrentIndex(cidx) above was a no-op because the model was previously reset which // clears any current part selection WITHOUT EMITTING THE currentRowChanged SIGNAL! In this case, we have to emit // currentPartChanged() manually. emit currentPartChanged(INVALID_PART_ID); } if (!selectionModel()->hasSelection()) { // Same as above, but for selection. emit selectedPartsChanged(QList<unsigned int>()); } }
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); }