void Window::connectAsSpectatorSelected() { QModelIndexList selectedIndexes = planetTreeView->selectionModel()->selectedIndexes(); if (selectedIndexes.size() == 0) { return; } QString configPath = getBasenfkPath()+ "spec.cfg"; QFile config(configPath); if (!config.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) { error("Couldn't open:\n\"" + configPath + "\""); return; } QString configContent = "spectator 1\necho spectator on\nconnect " + selectedIndexes.at(4).data().toString(); config.write(configContent.toLatin1()); config.flush(); startGame("+exec spec "); }
void AddressBookPage::onEditAction() { if(!ui->tableView->selectionModel()) return; QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows(); if(indexes.isEmpty()) return; EditAddressDialog dlg( tab == SendingTab ? EditAddressDialog::EditSendingAddress : EditAddressDialog::EditReceivingAddress); dlg.setModel(model); QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0)); dlg.loadRow(origIndex.row()); dlg.exec(); }
void ui_module_articulos::on_pushButton_editar_2_clicked() { QModelIndexList list = ui->tableView_articulos->selectionModel()->selectedRows(); int filas = list.size(); if(filas>1) { QMessageBox::information(this,"Error","Solo se puede editar una fila a la vez"); } else { if(filas==0) { QMessageBox::information(this,"Error","Por favor, seleccione una fila para editar"); } else { object_e_articulo articulo; QSqlRelationalTableModel * model = (QSqlRelationalTableModel*)ui->tableView_articulos->model(); QSqlRecord record = model->record(list.at(0).row()); articulo.mf_set_pk_articulo(record.value(COD).toString()); articulo.mf_set_descripcion(record.value(DESCRIPCION).toString()); articulo.mf_set_fk_marca(record.value(MARCA).toString()); articulo.mf_set_fk_grupo(record.value(GRUPO).toString()); articulo.mf_set_fk_medida(record.value(MEDIDA).toString()); articulo.mf_set_precio_lista(record.value(PRECIO).toString()); articulo.mf_set_stock(record.value(STOCK).toString()); ui_edit_articulo form_edit_articulos(&articulo) ; form_edit_articulos.exec(); //Actualizamos la tabla de articulos update_table_articulos(); } } }
//create table input context menu void RouteView::tablev_customContextMenu( const QPoint& pt) { curRow = ui->rowAt(pt.y()); curCol = ui->columnAt(pt.x()); // check is item in QTableView exist or not if(boolGetItemTableView(ui)) { //menu = QMenu(m_parent*); menu.clear(); menu.addAction(copyAction); menu.addAction(pasteAction); QItemSelectionModel * model = ui->selectionModel(); QModelIndexList indexes = model->selectedIndexes(); //qint32 row = model->currentIndex().row(); //qint32 col =model->currentIndex().column(); QModelIndex Index = indexes.at(0); QString txtSegmentId = Index.data().toString(); txtSegmentId.replace("!", ""); txtSegmentId.replace("*", ""); qint32 segmentId = txtSegmentId.toInt(); if(sourceModel->isSegmentMarkedForDelete(segmentId)) menu.addAction(unDeleteSegmentAct); else menu.addAction(deleteSegmentAct); //if(curRow == 0) menu.addAction(selectSegmentAct); menu.addAction(reSequenceAction); // if(!startTerminal) // { startTerminal = menu.addMenu(tr("Set start terminal...")); startTerminal->addAction(startTerminalStartAct); startTerminal->addAction(startTerminalEndAct); endTerminal =menu.addMenu(tr("Set end terminal...")); endTerminal->addAction(endTerminalStartAct); endTerminal->addAction(endTerminalEndAct); // } menu.addAction(editSegmentAct); if(sourceModel->changedRows.count() > 0) { menu.addSeparator(); menu.addAction(saveChangesAct); } menu.exec(QCursor::pos()); } }
void VanityGenPage::customMenuRequested(QPoint pos) { QModelIndex index = ui->tableView->indexAt(pos); tableIndexClicked = index.row(); QModelIndexList selection = ui->tableView->selectionModel()->selectedRows(); if(index.isValid()) { importIntoWalletAction->setText("Import into Wallet"); deleteAction->setText("Delete"); importIntoWalletAction->setEnabled(false); copyPrivateKeyAction->setEnabled(false); copyAddressAction->setEnabled(false); deleteAction->setEnabled(false); if(VanityGenWorkList[tableIndexClicked].privkey != ""){ if(this->walletModel->getEncryptionStatus() != 1){ int atLeastOneImportable = 0; for(int i=0; i< selection.count(); i++) { if(VanityGenWorkList[selection.at(i).row()].privkey != ""){ atLeastOneImportable++; } } importIntoWalletAction->setText("Import into Wallet ("+QString::number(atLeastOneImportable)+")"); importIntoWalletAction->setEnabled(true); } if(selection.count() == 1){ copyPrivateKeyAction->setEnabled(true); } } if(VanityGenWorkList[tableIndexClicked].pubkey != "" && selection.count() == 1){ copyAddressAction->setEnabled(true); } if(!VanityGenRunning){ deleteAction->setText("Delete ("+QString::number(selection.count())+")"); deleteAction->setEnabled(true); } contextMenu->popup(ui->tableView->viewport()->mapToGlobal(pos)); } }
void SideBarView::slotSidebarContextMenu(){ QItemSelectionModel *s_m = selectionModel(); QModelIndexList selected = s_m->selectedRows(0); if (selected.size() < 1) return; SideBarItem *item = reinterpret_cast<SideBarItem*>(selected.at(0).internalPointer()); QMenu *menu = NULL; if (item && item->childCount() > 0){ menu = new QMenu(this); menu->addAction(WICON(WulforUtil::eiEDITDELETE), tr("Close all")); if (menu->exec(QCursor::pos())){ QList<SideBarItem*> childs = item->childItems; for (const auto &child : childs){ if (child && child->getWidget()) ArenaWidgetManager::getInstance()->rem(child->getWidget()); } } menu->deleteLater(); } else if (item && item->getWidget()){ menu = item->getWidget()->getMenu(); if (!menu && (item->getWidget()->state() & ArenaWidget::Singleton)) return; if(!menu){ menu = new QMenu(this); menu->addAction(WICON(WulforUtil::eiEDITDELETE), tr("Close")); if (menu->exec(QCursor::pos())) ArenaWidgetManager::getInstance()->rem(item->getWidget()); menu->deleteLater(); } else menu->exec(QCursor::pos()); } }
void TransactionView::editLabel() { if(!transactionView->selectionModel() ||!model) return; QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { AddressTableModel *addressBook = model->getAddressTableModel(); if(!addressBook) return; QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString(); if(address.isEmpty()) { // If this transaction has no associated address, exit return; } // Is address in address book? Address book can miss address when a transaction is // sent from outside the UI. int idx = addressBook->lookupAddress(address); if(idx != -1) { // Edit sending / receiving address QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex()); // Determine type of address, launch appropriate editor dialog type QString type = modelIdx.data(AddressTableModel::TypeRole).toString(); EditAddressDialog dlg(type==AddressTableModel::Receive ? EditAddressDialog::EditReceivingAddress : EditAddressDialog::EditSendingAddress, this); dlg.setModel(addressBook); dlg.loadRow(idx); dlg.exec(); } else { // Add sending address EditAddressDialog dlg(EditAddressDialog::NewSendingAddress, this); dlg.setModel(addressBook); dlg.setAddress(address); dlg.exec(); } } }
void ContactsTable::onDeleteContact() { //remove selected contacts from inbox model (and database) QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model()); //model->setUpdatesEnabled(false); QItemSelectionModel* selection_model = ui->contact_table->selectionModel(); QModelIndexList sortFilterIndexes = selection_model->selectedRows(); QModelIndexList indexes; foreach(QModelIndex sortFilterIndex,sortFilterIndexes) indexes.append(model->mapToSource(sortFilterIndex)); qSort(indexes); auto sourceModel = model->sourceModel(); for(int i = indexes.count() - 1; i > -1; --i) sourceModel->removeRows(indexes.at(i).row(),1); //model->setUpdatesEnabled(true); //TODO Remove fullname/bitname for deleted contacts from QCompleter }
void HotkeysLibrarySingleshotView::startDrag(QMouseEvent *event) { QModelIndexList indices = this->selectedIndexes(); QByteArray objects; for(int i=0;i<indices.length(); i++) { objects.append(model()->index(indices.at(i).row(), 0).data().toByteArray()); objects.append(" "); } objects.remove(objects.length() - 1, 1); //qDebug() << objects; QMimeData *mimedata = new QMimeData(); mimedata->setData("application/sg-action-singleshot-reference", objects); QDrag *drag = new QDrag(this); drag->setMimeData(mimedata); QPixmap pixmap(this->style()->standardPixmap(QStyle::SP_FileIcon)); drag->setPixmap(pixmap); Qt::DropAction dropAction = drag->exec(Qt::CopyAction); }
void AcceptedOfferListPage::on_messageButton_clicked() { if(!model) return; if(!ui->tableView->selectionModel()) return; QModelIndexList selection = ui->tableView->selectionModel()->selectedRows(); if(selection.isEmpty()) { return; } QString offerAlias = selection.at(0).data(OfferAcceptTableModel::AliasRole).toString(); // send message to seller NewMessageDialog dlg(NewMessageDialog::NewMessage, offerAlias); dlg.exec(); }
void MessagePage::on_deleteButton_clicked() { QListView *list = ui->listConversation; if(!list->selectionModel()) return; QModelIndexList indexes = list->selectionModel()->selectedIndexes(); if(!indexes.isEmpty()) { list->model()->removeRow(indexes.at(0).row()); indexes = list->selectionModel()->selectedIndexes(); if(indexes.isEmpty()) on_backButton_clicked(); } }
void PreferencesDialog::on_button_settings_clicked() { //Uploader settings QModelIndex selectedIndex; QModelIndexList indexes = ui->list_uploaders->selectionModel()->selectedIndexes(); if(indexes.size() > 0) { selectedIndex = indexes.at(0); QString shortname = selectedIndex.model()->data(selectedIndex, Qt::UserRole).toString(); if(shortname != "screencloud") { uploadManager->getUploader(shortname)->showSettingsUI(this); }else { ui->tabWidget->setCurrentIndex(1); } } }
int QT1::getRepoListSelectedIndex() { if (this->repoList->count() == 0)return -1; QModelIndexList index = this->repoList->selectionModel()->selectedIndexes(); if (index.size() == 0) { this->nameEdit->clear(); this->breedEdit->clear(); this->ageEdit->clear(); this->linkEdit->clear(); return -1; } int idx = index.at(0).row(); return idx; }
QString HAlarm::buildFilterString(QModelIndexList list) { QString res; int size=list.count(); for (int is=0;is<size; is++) { res += list.at(is).data(0).toString(); if (is<list.count()-1) { res+="-"; } } return res; }
void build::on_buildDialogButton_clicked(){ QItemSelectionModel* selectionModel = ui->tableWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedRows(); if(selected.count() == 0){ ui->errorLabel->setText("Please select a type."); }else{ for(int i= 0; i< selected.count();i++){ QModelIndex index = selected.at(i); choice = index.row(); } /* Request and location are set in ingame buildButton method */ clientManager->addInfo("typeindex", std::to_string(choice)); clientManager->sendRequestAndRecv(); clientManager->addInfo("showmessagebox", "true"); close(); } }
bool ClipboardModel::moveItemsWithKeyboard(QModelIndexList indexList, int key, int count) { int from, to; bool res = false; QList<int> list; for ( int i = 0; i < indexList.length(); ++i ) list.append( indexList.at(i).row() ); if ( key == Qt::Key_Down || key == Qt::Key_End ) qSort( list.begin(), list.end(), qGreater<int>() ); else qSort( list.begin(), list.end(), qLess<int>() ); for ( int i = 0, d = 0; i<list.length(); ++i ) { from = list.at(i) + d; switch (key) { case Qt::Key_Down: to = from + count; break; case Qt::Key_Up: to = from - count; break; case Qt::Key_End: to = rowCount()-i-1; break; default: to = 0+i; break; } if ( to < 0 ) --d; else if (to >= rowCount() ) ++d; if ( !move(from, to) ) return false; if (!res) res = to==0 || from==0 || to == rowCount(); } return res; }
// Function to deleting record from table bool creatordialog::delete_record(QSqlRelationalTableModel* rmodel) { int row_to_delete; QModelIndexList selectedList = ui->tableView_CREATOR_1->selectionModel()->selectedRows(); for( int i=0; i<selectedList.count(); i++) { row_to_delete=selectedList.at(i).row(); } if(selectedList.isEmpty()) { QMessageBox::information(this,"Informacja","Nie zaznaczono wiersza do usunięcia."); return false; } QSqlQueryModel model; model.setQuery("SELECT * FROM "+relational_table_2+""); int id_first = model.data(model.index(row_to_delete, 0)).toInt(); int id_second = model.data(model.index(row_to_delete, 1)).toInt(); QSqlQuery query; if(relational_table_2=="Maszyny_has_Daneosobowe") { query.prepare("Delete from Maszyny_has_Daneosobowe where idMaszyny_MaszynyDaneosobowe=:first_id and idDaneosobowe_MaszynyDaneosobowe=:second_id"); } else if(relational_table_2=="Maszyny_has_Czesci") { query.prepare("Delete from Maszyny_has_Czesci where idMaszyny_MaszynyCzesci=:first_id and idCzesci_MaszynyCzesci=:second_id"); } query.bindValue(":first_id", id_first); query.bindValue(":second_id", id_second); if(query.exec()) { QMessageBox::information(this,"Informacja","USUNIĘTO"); rmodel->select(); count=false; return true; } else { QMessageBox::information(this,"Informacja",query.lastError().text()); return false; } }
void FilesListWindow::on_deleteButton_pressed() { QModelIndexList indexes = ui->filesTable->selectionModel()->selection().indexes(); for (int i = 0; i < indexes.count(); ++i) { WSqlQuery q, r; q.prepare("DELETE FROM files WHERE id = ?"); r.prepare("DELETE FROM mirrors WHERE file_id = ?"); QModelIndex index = indexes.at(i); if(index.column() == 0) { q.addBindValue(index.data().toInt()); q.exec(); r.addBindValue(index.data().toInt()); r.exec(); } } refresh(); }
unique_ptr<Team> TeamTableView::getSelectedTeam() { // make sure we have a non-empty model auto mod = model(); if (mod == nullptr) return nullptr; if (mod->rowCount() == 0) return nullptr; // make sure we have one item selected QModelIndexList indexes = selectionModel()->selection().indexes(); if (indexes.count() == 0) { return nullptr; } // return the selected item TeamMngr tm{db}; int selectedSourceRow = sortedModel->mapToSource(indexes.at(0)).row(); return tm.getTeamBySeqNum_up(selectedSourceRow); }
void HWMapContainer::updateModelViews() { // restore theme selection // do this before map selection restore, because map may overwrite theme if (!m_theme.isEmpty()) { QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), Qt::DisplayRole, m_theme); if (mdl.size() > 0) updateTheme(mdl.at(0)); else setRandomTheme(); } // restore map selection if (!m_curMap.isEmpty()) intSetMap(m_curMap); else updatePreview(); }
Song LibraryPage::coverRequest() const { QModelIndexList selected = view->selectedIndexes(false); // Dont need sorted selection here... if (1==selected.count()) { QModelIndex idx=proxy.mapToSource(selected.at(0)); QList<Song> songs=MusicLibraryModel::self()->songs(QModelIndexList() << idx, false); if (!songs.isEmpty()) { Song s=songs.at(0); if (MusicLibraryItem::Type_Artist==static_cast<MusicLibraryItem *>(idx.internalPointer())->itemType() && !static_cast<MusicLibraryItemArtist *>(idx.internalPointer())->isComposer()) { s.setArtistImageRequest(); } return s; } } return Song(); }
void ItemList::move_to_trash() { QModelIndexList ids = selectionModel()->selectedIndexes(); if (ids.size() == 0) return; QModelIndex index = ids.at(0); if (!index.isValid()) return; PassItem *item = (PassItem*) index.internalPointer(); if (NULL == item) return; ItemListModel *m = dynamic_cast<ItemListModel*>(model()); assert(NULL != m); Sqlite3Db *db = m->get_db(); const int trash_did = db->check_directory_path(Sqlite3Db::TRASH_PATH); db->move_item(item->get_id(), trash_did); m->_remove_after_drag(index.row()); }
/** * Delete the given profile preference * */ void CAMProfileSettingsList::on_bDelete_clicked() { // Get all selections QModelIndexList indexes = ui->tableView->selectionModel()->selection().indexes(); QList<int> list; for (int i = 0; i < indexes.count(); ++i) { list.append(indexes.at(i).row()); } list=QSet<int>::fromList(list).toList(); qSort(list.begin(), list.end()); while (!list.empty()) { camProfileDataModel->removeRows(list.takeLast(),1); } savePreferences(); ui->tableView->resizeColumnsToContents(); }
void CRestoreTM::on_pushButton_2_clicked() ////////////////////////////////////////// { QStandardItemModel *model = (QStandardItemModel *)ui->treeView->model(); QModelIndexList il = ui->treeView->selectionModel()->selectedIndexes(); if (il.count() == 0) return; QStandardItem *item = model->itemFromIndex(il.at(0)); item_t *e = (item_t *)item->data().toLongLong(); m_jd = e->jd; m_ra = e->ra; m_dec = e->dec; SkFile f(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/data/timemarks/timemarks.dat"); QTextStream s(&f); if (f.open(SkFile::WriteOnly | SkFile::Text)) { for (int i = 0; i < model->rowCount(); i++) { QStandardItem *item = model->item(i, 0); item_t *e = (item_t *)item->data().toLongLong(); s << e->desc << ";" << QString::number(e->jd, 'f', 8); if (e->ra > CM_UNDEF) { s << ";" << R2D(e->ra) << ";" << R2D(e->dec); } s << "\n"; delete e; } } model->removeRows(0, model->rowCount()); done(DL_OK); }
void RepoEditor::updateMovers( const QItemSelection &cur, const QItemSelection &) { QModelIndexList list = cur.indexes(); if( !list.count() ) return; int row = list.at( 0 ).row(); if( row > 0 ) ui->moveUp->setEnabled( true ); else ui->moveUp->setEnabled( false ); if( row < ui->tableView->model()->rowCount() - 1) ui->moveDown->setEnabled( true ); else ui->moveDown->setEnabled( false ); }
int MainWindow::deleteSelectedMode() { QModelIndexList list = ui.modeListView->selectionModel()->selectedIndexes(); if (list.length() == 0) { QMessageBox::about(this, tr("Error"), tr("No mode chosen!")); return 0; } QModelIndex index = list.at(0); string name; name = index.data(ModeListItemDelegate::modeNameRole).toString().toStdString(); processController.deleteMode(name); this->fillModeModel(); return 0; }
/** Edits selected item */ void medDatabaseView::onEditRequested(void) { QModelIndexList indexes = this->selectedIndexes(); if(!indexes.count()) return; QModelIndex index = indexes.at(0); medAbstractDatabaseItem *item = NULL; if(QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(this->model())) item = static_cast<medAbstractDatabaseItem *>(proxy->mapToSource(index).internalPointer()); if(item) { QList<QVariant> attributes = item->attributes(); QList<QVariant> values = item->values(); QList<QString> labels; foreach(QVariant attrib, attributes) { const medMetaDataKeys::Key* key = medMetaDataKeys::Key::fromKeyName(attrib.toString().toStdString().c_str()); if(key) labels << key->label(); else labels << ""; } medDatabaseEditItemDialog editDialog(labels,values,this); int res = editDialog.exec(); medDataIndex index = item->dataIndex(); if(res == QDialog::Accepted) { int i=0; foreach(QString label, labels) { QVariant data = editDialog.value(label); QVariant variant = item->attribute(i); medDataManager::instance()->setMetadata(index, variant.toString(), data.toString()); i++; } }
void QgsAuthConfigEditor::on_btnRemoveConfig_clicked() { QModelIndexList selection = tableViewConfigs->selectionModel()->selectedRows( 0 ); if ( selection.empty() ) return; QModelIndex indx = selection.at( 0 ); QString name = indx.sibling( indx.row(), 1 ).data().toString(); if ( QMessageBox::warning( this, tr( "Remove Configuration" ), tr( "Are you sure you want to remove '%1'?\n\n" "Operation can NOT be undone!" ).arg( name ), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel ) == QMessageBox::Ok ) { mConfigModel->removeRow( indx.row() ); } }
void wid_stranke::on_btn_kopiraj_clicked() { QClipboard *odlozisce = QApplication::clipboard(); QModelIndexList selectedList = ui->tbl_stranke->selectionModel()->selectedRows(); QString html_besedilo = "<table>"; html_besedilo += "<tr>"; html_besedilo += "<th>ID</th>"; html_besedilo += "<th>Ime/Naziv</th>"; html_besedilo += "<th>Priimek/Polni naziv</th>"; html_besedilo += "<th>Telefon</th>"; html_besedilo += "<th>GSM</th>"; html_besedilo += "<th>Elektronski naslov</th>"; html_besedilo += "<th>Izobrazevalna ustanova</th>"; html_besedilo += "<th>Tip stranke</th>"; html_besedilo += "</tr>"; for( int i = 0; i < selectedList.count(); i++) { html_besedilo += "<tr>"; for ( int a = 0; a < 8; a++ ) { html_besedilo += "<td>"; html_besedilo += ui->tbl_stranke->item(selectedList.at(i).row(), a)->text(); html_besedilo += "</td>"; } html_besedilo += "</tr>"; } html_besedilo += "</table>"; QTextEdit *textedit = new QTextEdit; textedit->setHtml(html_besedilo); html_besedilo = textedit->toHtml(); odlozisce->clear(); QMimeData *mimeData = new QMimeData(); mimeData->setData("text/html", html_besedilo.toUtf8()); odlozisce->setMimeData(mimeData, QClipboard::Clipboard); }
// 打开菜单 void RelateDocDialog::openRelateDoc() { QItemSelectionModel *selections = docsView->selectionModel(); QModelIndexList selected = selections->selectedIndexes(); // 选择第一个 QModelIndex index = selected.at(0); QStandardItem* item = model->item(index.row(), 3); QString docUuid = qvariant_cast<QString>(item->data(Qt::DisplayRole)); Doc doc = DocDao::selectDoc(docUuid); QString filepath = doc.DOCUMENT_LOCATION; QFileInfo fileInfo(filepath); if(!fileInfo.exists()){ QMessageBox::warning(this, tr("Warning"), tr("Please Confirm The original file has Deleted Or Moved. "), QMessageBox::Yes); return; } QDesktopServices::openUrl ( QUrl::fromLocalFile(filepath) ); }