void PropertyController::invokeMethod(Qt::ConnectionType connectionType) { if (!m_object) { m_methodLogModel->appendRow(new QStandardItem(tr("%1: Invocation failed: Invalid object, probably got deleted in the meantime.") .arg(QTime::currentTime().toString("HH:mm:ss.zzz")))); return; } QMetaMethod method; QItemSelectionModel* selectionModel = ObjectBroker::selectionModel(m_methodModel); if (selectionModel->selectedRows().size() == 1) { const QModelIndex index = selectionModel->selectedRows().first(); method = index.data(ObjectMethodModelRole::MetaMethod).value<QMetaMethod>(); } if (method.methodType() != QMetaMethod::Slot) { m_methodLogModel->appendRow(new QStandardItem(tr("%1: Invocation failed: Invalid method (not a slot?).") .arg(QTime::currentTime().toString("HH:mm:ss.zzz")))); return; } const QVector<MethodArgument> args = m_methodArgumentModel->arguments(); // TODO retrieve return value and add it to the log in case of success // TODO measure executation time and that to the log const bool result = method.invoke(m_object.data(), connectionType, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); if (!result) { m_methodLogModel->appendRow(new QStandardItem(tr("%1: Invocation failed..").arg(QTime::currentTime().toString("HH:mm:ss.zzz")))); return; } m_methodArgumentModel->setMethod(QMetaMethod()); }
void MaterialSettings::on_addRow_clicked() { QItemSelectionModel *select = ui->coordinates->selectionModel(); if(select->hasSelection() && (!select->selectedRows().isEmpty())) { int start = select->selectedRows().first().row(); material.p.insert(material.p.begin()+start, Point(0, 0)); } else material.p.push_back(Point(0, 0)); model->updateView(); }
void MethodsExtension::activateMethod() { QItemSelectionModel *selectionModel = ObjectBroker::selectionModel(m_model); if (selectionModel->selectedRows().size() != 1) { return; } const QModelIndex index = selectionModel->selectedRows().at(0); const QMetaMethod method = index.data(ObjectMethodModelRole::MetaMethod).value<QMetaMethod>(); m_methodArgumentModel->setMethod(method); }
void IntegrationPreferences::slotRemoveItem() { QItemSelectionModel *selection = ui.list->selectionModel(); if (selection->hasSelection()) { while (selection->selectedRows().count()) { const QModelIndex index = selection->selectedRows().first(); m_model->removeRow(index.row()); } emit changed(); } }
void DisassemblerView::copyString() { QAbstractItemModel* model = ui->tvStrings->model(); QItemSelectionModel* selectionmodel = ui->tvStrings->selectionModel(); QModelIndexList addresslist = selectionmodel->selectedRows(0); QModelIndexList stringlist = selectionmodel->selectedRows(1); if(addresslist.isEmpty() || stringlist.isEmpty()) return; QClipboard* clipboard = qApp->clipboard(); clipboard->setText(QString("%1 %2").arg(model->data(addresslist[0]).toString(), model->data(stringlist[0]).toString())); }
void MethodsExtension::connectToSignal() { QItemSelectionModel *selectionModel = ObjectBroker::selectionModel(m_model); if (selectionModel->selectedRows().size() != 1) { return; } const QModelIndex index = selectionModel->selectedRows().at(0); const QMetaMethod method = index.data(ObjectMethodModelRole::MetaMethod).value<QMetaMethod>(); if (method.methodType() == QMetaMethod::Signal) { m_signalMapper->connectToSignal(m_object, method); } }
void PropertyController::activateMethod() { QItemSelectionModel* selectionModel = ObjectBroker::selectionModel(m_methodModel); if (selectionModel->selectedRows().size() != 1) return; const QModelIndex index = selectionModel->selectedRows().first(); const QMetaMethod method = index.data(ObjectMethodModelRole::MetaMethod).value<QMetaMethod>(); if (method.methodType() == QMetaMethod::Slot) { m_methodArgumentModel->setMethod(method); } else if (method.methodType() == QMetaMethod::Signal) { m_signalMapper->connectToSignal(m_object, method); } }
void MaterialSettings::on_removeRow_clicked() { QItemSelectionModel *select = ui->coordinates->selectionModel(); if(select->hasSelection() && (!select->selectedRows().isEmpty())) { int start = select->selectedRows().first().row(); int stop = select->selectedRows().last().row(); for(int k=0; k < stop-start+1; k++) material.p.erase(material.p.begin()+start); } else if (material.p.size() > 0) material.p.erase(material.p.end()-1); model->updateView(); }
void QgsGraduatedSymbolRendererV2Widget::changeSelectedSymbols() { QItemSelectionModel* m = viewGraduated->selectionModel(); QModelIndexList selectedIndexes = m->selectedRows( 1 ); if ( m && !selectedIndexes.isEmpty() ) { QgsSymbolV2* newSymbol = mGraduatedSymbol->clone(); QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this ); dlg.setMapCanvas( mMapCanvas ); if ( !dlg.exec() ) { delete newSymbol; return; } Q_FOREACH ( const QModelIndex& idx, selectedIndexes ) { if ( idx.isValid() ) { int rangeIdx = idx.row(); QgsSymbolV2* newRangeSymbol = newSymbol->clone(); newRangeSymbol->setColor( mRenderer->ranges()[rangeIdx].symbol()->color() ); mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol ); } } }
void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol() { // Change the selected symbols alone if anything is selected QItemSelectionModel* m = viewGraduated->selectionModel(); QModelIndexList i = m->selectedRows(); if ( m && !i.isEmpty() ) { changeSelectedSymbols(); return; } // Otherwise change the base mGraduatedSymbol QgsSymbolV2* newSymbol = mGraduatedSymbol->clone(); QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this ); dlg.setMapCanvas( mMapCanvas ); if ( !dlg.exec() ) { delete newSymbol; return; } delete mGraduatedSymbol; mGraduatedSymbol = newSymbol; mSizeUnitWidget->blockSignals( true ); mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() ); mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() ); mSizeUnitWidget->blockSignals( false ); updateGraduatedSymbolIcon(); mRenderer->updateSymbols( mGraduatedSymbol ); refreshSymbolView(); }
void ProvidersEditor::addItem() { Azahar *myDb = new Azahar; myDb->setDatabase(db); //get selected items from list QItemSelectionModel *selectionModel = ui->productsList->selectionModel(); QModelIndexList indexList = selectionModel->selectedRows(); // pasar el indice que quiera (0=code, 1=name) foreach(QModelIndex index, indexList) { qulonglong code = index.data().toULongLong(); // product CODE ProductInfo pInfo; //get product info from db pInfo = myDb->getProductInfo(QString::number(code)); //check if the product to be added is not already there if (!myDb->providerHasProduct(m_pInfo.id, code)) { qDebug()<<"The product "<<code<<" is not provided by the porvider yet"; //insert into the db. ProductProviderInfo info; info.prodId = code; info.provId = m_pInfo.id; info.price = pInfo.price; myDb->addProductToProvider(info); } }
void QgsGraduatedSymbolRendererV2Widget::updateSymbolsFromWidget() { QgsRendererWidgetContainer* container = qobject_cast<QgsRendererWidgetContainer*>( mStackedWidget->currentWidget() ); QgsSymbolV2SelectorDialog* dlg = qobject_cast<QgsSymbolV2SelectorDialog*>( container->widget() ); delete mGraduatedSymbol; mGraduatedSymbol = dlg->symbol()->clone(); mSizeUnitWidget->blockSignals( true ); mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() ); mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() ); mSizeUnitWidget->blockSignals( false ); QItemSelectionModel* m = viewGraduated->selectionModel(); QModelIndexList selectedIndexes = m->selectedRows( 1 ); if ( m && !selectedIndexes.isEmpty() ) { Q_FOREACH ( const QModelIndex& idx, selectedIndexes ) { if ( idx.isValid() ) { int rangeIdx = idx.row(); QgsSymbolV2* newRangeSymbol = mGraduatedSymbol->clone(); newRangeSymbol->setColor( mRenderer->ranges()[rangeIdx].symbol()->color() ); mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol ); } } }
// Suppression d'un contact. void AddressBook::deleteContact() { QItemSelectionModel *selection = view->selectionModel(); QModelIndexList listeSelections = selection->selectedRows(0); model->removeRow(listeSelections[0].row()); model->submitAll(); editorClear(); }
/*! \fn FormListaPeluqueria::borrar() */ void FormListaPeluqueria::borrar() { //Preguntar al usuario si esta seguro QItemSelectionModel *selectionModel = TVPeluqueria->selectionModel(); QModelIndexList indices = selectionModel->selectedRows(); if( indices.size() < 1 ) { QMessageBox::warning( this, "Seleccione un item", "Por favor, seleccione un item para eliminar", QMessageBox::Ok ); return; } //Hacer dialogo de confirmacion.. int ret; ret = QMessageBox::warning( this, "Esta seguro?", QString( "Esta seguro de eliminar %1 item?").arg( indices.size() ), "Si", "No" ); if ( ret == 0 ) { QModelIndex indice; foreach( indice, indices ) { if( indice.isValid() ) { modelo->removeRow( indice.row() ); } } }
void MainWindow::on_upButton_clicked() { QItemSelectionModel *select = ui->targetListTable->selectionModel(); QModelIndexList selectedRows = select->selectedRows(); QList<int> moveOrder; if (select->hasSelection()) { // Makes sure everything is moved in the correct order for (QList<QModelIndex>::iterator i = selectedRows.begin(); i != selectedRows.end(); i++) { moveOrder.append(i->row()); } qSort(moveOrder.begin(), moveOrder.end()); ui->targetListTable->selectionModel()->clearSelection(); // Deselects all rows QItemSelection selectedItems = ui->targetListTable->selectionModel()->selection(); if (moveOrder[0] != 0) { for (int i = 0; i < moveOrder.length(); i++) { ui->targetListTable->selectRow(moveOrder[i]-1); selectedItems.merge(ui->targetListTable->selectionModel()->selection(), QItemSelectionModel::Select); targetList->moveUp(moveOrder[i]); } ui->targetListTable->selectionModel()->select(selectedItems, QItemSelectionModel::Select); // Reselects new rows } } }
void MainWindow::on_edit_clicked() { QItemSelectionModel *select = ui->targetListTable->selectionModel(); QModelIndexList selectedRows = select->selectedRows(); if (select->hasSelection() && selectedRows.length() == 1) { // only 1 item can be selected QList<QModelIndex>::iterator i = selectedRows.begin(); int selectedRow = i->row(); // gets the selected row number // Creates edit window targetEditor = new TargetMaker(this); targetEditor->setModal(true); targetEditor->setWindowTitle("Edit Target"); // Sets default values targetEditor->defaultFileInput = targetList->rows->at(selectedRow)->imageFilePath; targetEditor->defaultNameInput = targetList->rows->at(selectedRow)->name->text(); targetEditor->defaultCoordInput = targetList->rows->at(selectedRow)->coord->text(); targetEditor->defaultDescInput = targetList->rows->at(selectedRow)->desc->text(); targetEditor->setDefaultInputs(); // Opens edit window targetEditor->exec(); if (targetEditor->accepted) { targetList->editRow(selectedRow, targetEditor->getImageFilePath(), targetEditor->getName(), targetEditor->getCoord(), targetEditor->getDesc()); } } }
QModelIndexList FolderView::selectedRows(int column) const { QItemSelectionModel* selModel = selectionModel(); if(selModel) { return selModel->selectedRows(column); } return QModelIndexList(); }
void QxFileBrowser::delete_() { QModelIndex currentIndex = dirView_->currentIndex(); if (currentIndex.isValid()) { QItemSelectionModel* sm = dirView_->selectionModel(); if (sm->hasSelection()) { QModelIndexList l = sm->selectedRows(); currentIndex = QModelIndex(); // visual HACK, cwdModel_->index(currentIndex.row() + l.count(), 0, currentIndex.parent()); for (int i = 0; i < l.count(); ++i) { QModelIndex mi = l[i]; QDir dest = QDir::home(); dest.mkdir(".Trash"); dest.cd(".Trash"); QString destBasePath = dest.filePath(cwdModel_->fileName(mi)); QString destPath = destBasePath; int i = 1; while (QFileInfo(destPath).exists()) { destPath = QString("%1_%2").arg(destBasePath).arg(i); ++i; } QFile(cwdModel_->filePath(mi)).rename(destPath); } dirView_->setCurrentIndex(currentIndex); } } }
void BuysPage::on_escrowLockButton_clicked() { // get the vendor created escrow lock tx, sign it and broadcast it // ask the user if they really want to pay QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Lock Escrow?", "Do you want to lock escrow for this item? This will send money to the escrow address.", QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::No) { return; } QItemSelectionModel* selectionModel = ui->tableWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedRows(); if(selected.count() == 0) return; QModelIndex index = selected.at(0); int r = index.row(); std::string buyRequestIdHash = ui->tableWidget->item(r, 5)->text().toStdString(); uint256 buyRequestId = uint256(buyRequestIdHash); CBuyRequest buyRequest = mapBuyRequests[buyRequestId]; bool accepted = false; // deserialize the seller's escrow tx BOOST_FOREACH(PAIRTYPE(const uint256, CBuyAccept)& p, mapBuyAccepts) { if(p.second.listingId == buyRequest.listingId && p.second.buyRequestId == buyRequestId) { // found seller's buy accept CWalletTx wtxSeller; CDataStream ssTx(p.second.raw.data(), p.second.raw.data() + p.second.raw.size(), SER_NETWORK, CLIENT_VERSION); ssTx >> wtxSeller; accepted = wtxSeller.AcceptToMemoryPool(); break; } }
/// /// \brief TreeView CurPlotItem slots(曲线条目树形窗口) /// \param index /// void SAChartDatasViewWidget::onTreeViewCurPlotItemClicked(const QModelIndex &index) { Q_UNUSED(index); QItemSelectionModel* sel = ui->treeView->selectionModel(); QModelIndexList indexList = sel->selectedRows(); QList<QwtPlotItem*> items; for(int i = 0;i<indexList.size ();++i) { if(!indexList[i].parent().isValid()) {//说明点击的是父窗口,就是qwtplot,这时显示所有 items.clear(); int childIndex = 0; while (indexList[i].child(childIndex,0).isValid()) { items.append(m_treeModel->getQwtPlotItemFromIndex ( indexList[i].child(childIndex,0))); ++childIndex; } break; } if(indexList[i].column () != 0) { indexList[i] = indexList[i].parent().child(indexList[i].row(),0); } items.append (m_treeModel->getQwtPlotItemFromIndex (indexList[i])); } m_tableModel->setPlotItems (items); }
void caTable::copy() { QItemSelectionModel *select = this->selectionModel(); if( select->hasSelection()) { QClipboard *clipboard = QApplication::clipboard(); QString str; QModelIndexList rows = select->selectedRows(); int i=0; foreach (QModelIndex Row, rows) { if (i > 0) str += "\n"; for(int j = 0; j < columnCount(); ++j) { if (j > 0) str += "\t"; QTableWidgetItem* pWidget = item(Row.row(), j); str += pWidget->text(); } i++; } if(i==0) { //printf("no rows were selected\n"); QModelIndexList cols = select->selectedColumns(); foreach (QModelIndex Col, cols) { if (i > 0) str += "\n"; for(int j = 0; j < rowCount(); ++j) { if (j > 0) str += "\t"; QTableWidgetItem* pWidget = item(j, Col.column()); str += pWidget->text(); } i++; } }
// Insertion/Mise à jour d'un contact. // TODO : Séparer en deux fonctions distinctes. void AddressBook::submitContact() { lastname = lastnameLine->text(); name = nameLine->text(); if (name == "" || lastname == "") { QMessageBox::information(this, tr("Erreur !"), tr("Veuillez saisir au minimum un prénom et un nom.")); return; } // Si login == 0 alors ajout, sinon modification. if(login == 0) { int line_number = model->rowCount(); model->insertRow(line_number); queryBindContactValues(line_number); } else { QItemSelectionModel *selection = view->selectionModel(); QModelIndexList listeSelections = selection->selectedRows(0); int line_number = listeSelections[0].row(); queryBindContactValues(line_number); } editorClear(); model->select(); }
QList<QgsSymbolV2*> QgsGraduatedSymbolRendererV2Widget::selectedSymbols() { QList<QgsSymbolV2*> selectedSymbols; QItemSelectionModel* m = viewGraduated->selectionModel(); QModelIndexList selectedIndexes = m->selectedRows( 1 ); if ( m && selectedIndexes.size() > 0 ) { const QgsRangeList& ranges = mRenderer->ranges(); QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin(); for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt ) { QStandardItem* currentItem = qobject_cast<const QStandardItemModel*>( m->model() )->itemFromIndex( *indexIt ); if ( currentItem ) { QStringList list = currentItem->data( 0 ).toString().split( " " ); if ( list.size() < 3 ) { continue; } double lowerBound = list.at( 0 ).toDouble(); double upperBound = list.at( 2 ).toDouble(); QgsSymbolV2* s = findSymbolForRange( lowerBound, upperBound, ranges ); if ( s ) { selectedSymbols.append( s ); } } } } return selectedSymbols; }
void DialogSelectScenario::sysSelectionChanged() { if (!_curScene) return; // which system within the scenario was selected? QItemSelectionModel* sel = _systable->selectionModel(); if (!sel) return; QModelIndexList selli = sel->selectedRows(); if (selli.empty()) return; int row =selli.first().row(); std::stringstream ss; // get it from active scenario std::vector<const MavSystem*> systems = _curScene->getSystems(); if (row >= 0 && row < (int)systems.size()) { const MavSystem*s = systems[row]; if (s) { std::string summary; s->get_summary(summary); ss << summary << endl; } } _stext->setText(QString::fromStdString(ss.str())); }
QList<QgsSymbolV2*> QgsCategorizedSymbolRendererV2Widget::selectedSymbols() { QList<QgsSymbolV2*> selectedSymbols; QItemSelectionModel* m = viewCategories->selectionModel(); QModelIndexList selectedIndexes = m->selectedRows( 1 ); if ( m && selectedIndexes.size() > 0 ) { const QgsCategoryList& categories = mRenderer->categories(); QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin(); for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt ) { QStandardItem* currentItem = qobject_cast<const QStandardItemModel*>( m->model() )->itemFromIndex( *indexIt ); if ( currentItem ) { QgsSymbolV2* s = categories[mRenderer->categoryIndexForValue( currentItem->data() )].symbol(); if ( s ) { selectedSymbols.append( s ); } } } } return selectedSymbols; }
void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol() { // Change the selected symbols alone if anything is selected QItemSelectionModel* m = viewGraduated->selectionModel(); QModelIndexList i = m->selectedRows(); if ( m && i.size() > 0 ) { changeSelectedSymbols(); return; } // Otherwise change the base mGraduatedSymbol QgsSymbolV2* newSymbol = mGraduatedSymbol->clone(); QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this ); if ( !dlg.exec() ) { delete newSymbol; return; } mGraduatedSymbol = newSymbol; updateGraduatedSymbolIcon(); mRenderer->updateSymbols( mGraduatedSymbol ); refreshSymbolView(); }
void QgsGraduatedSymbolRendererV2Widget::updateSymbolsFromWidget() { QgsSymbolV2SelectorWidget* dlg = qobject_cast<QgsSymbolV2SelectorWidget*>( sender() ); delete mGraduatedSymbol; mGraduatedSymbol = dlg->symbol()->clone(); mSizeUnitWidget->blockSignals( true ); mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() ); mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() ); mSizeUnitWidget->blockSignals( false ); QItemSelectionModel* m = viewGraduated->selectionModel(); QModelIndexList selectedIndexes = m->selectedRows( 1 ); if ( m && !selectedIndexes.isEmpty() ) { Q_FOREACH ( const QModelIndex& idx, selectedIndexes ) { if ( idx.isValid() ) { int rangeIdx = idx.row(); QgsSymbolV2* newRangeSymbol = mGraduatedSymbol->clone(); if ( selectedIndexes.count() > 1 ) { //if updating multiple ranges, retain the existing range colors newRangeSymbol->setColor( mRenderer->ranges().at( rangeIdx ).symbol()->color() ); } mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol ); } } }
void SellsPage::on_cancelButton_clicked() { QItemSelectionModel* selectionModel = ui->listingsTableWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedRows(); if(selected.count() == 0) return; QModelIndex index = selected.at(0); int r = index.row(); std::string id = ui->listingsTableWidget->item(r, 0)->text().toStdString(); uint256 idHash = uint256(id); // ask the user if they really want to put in a buy request QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Cancel Listing", "Are you sure you want to cancel the listing for this item?", QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { CCancelListing cancel; cancel.listingId = idHash; cancel.sellerKey = pwalletMain->GenerateNewKey(); cancel.nDate = GetTime(); SignCancelListing(cancel, cancel.vchSig); ReceiveCancelListing(cancel); cancel.BroadcastToAll(); LoadSells(); } }
void MyStringTable::mousePressEvent (QMouseEvent * event) { QTableView::mousePressEvent(event); QItemSelectionModel *sel = selectionModel(); if(!sel->hasSelection()) return; QModelIndexList list = sel->selectedRows(); //int row = list.at(0).row(); QModelIndex idx = currentIndex(); int c = idx.column(); int r = idx.row(); int ck = Check(r,c); if(ck) ck=0; else ck=2; if(ColChkbx(c)) { setCheck(r,c,ck); emit rowEvent(r, 4); } }
void SellsPage::on_rejectButton_clicked() { QItemSelectionModel* selectionModel = ui->buysTableWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedRows(); if(selected.count() == 0) return; QModelIndex index = selected.at(0); int r = index.row(); std::string id = ui->buysTableWidget->item(r, 4)->text().toStdString(); uint256 listingIdHash = uint256(id); std::string rid = ui->buysTableWidget->item(r, 5)->text().toStdString(); uint256 requestIdHash = uint256(rid); // ask the user if they really want to reject the buy request QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Reject Buy", "Are you sure you want to reject the buy request for this item?", QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { CBuyReject reject; reject.listingId = listingIdHash; reject.buyRequestId = requestIdHash; reject.nDate = GetTime(); reject.sellerKey = pwalletMain->GenerateNewKey(); SignBuyReject(reject, reject.vchSig); ReceiveBuyReject(reject); reject.BroadcastToAll(); LoadSells(); LoadBuyRequests(); } }