void CEventItem::clearTraceList() { int count = m_traceList.count(); if (count > 0) { emit rowRemoved(this, 0, count-1); qDeleteAll(m_traceList); m_traceList.clear(); } }
void FormPerson::loadLayout(QString tableName) { // Recupero link al database QSqlDatabase db = QSqlDatabase::database("ConnectionToDB"); // Creo un modello sche si riferirà alla tabella delle mail QSqlTableModel *model = new QSqlTableModel(this, db); // Imposto la tabella a cui si riferirà il modello model->setTable(tableName); // Imposto un filtro sulla persona a cui la tabella è collegata model->setFilter("id_person=" + QString::number(this->personId)); model->select(); // Per ciascuna riga della tabella... for (int i=0; i<model->rowCount(); i++) { QHBoxLayout *hbl = new QHBoxLayout(); // Creo un nuovo oggetto QLineEdit QLineEdit *qlineedit = new QLineEdit(); // Creo un pulsante per la successiva rimozione dell'entry nel database RemoveRowFromModel *button = new RemoveRowFromModel(i, model, tableName); // Collego il pulante alla funzione di refresh QObject::connect(button, SIGNAL(rowRemoved(QString)), this, SLOT(refreshLayout(QString))); // Creo un mapper QDataWidgetMapper *mapperEmailPerson = new QDataWidgetMapper(); // Collego al mapper il modello della tabella mapperEmailPerson->setModel(model); // Aggiungo un mapping tra l'oggetto QLineEdit e il modello mapperEmailPerson->addMapping(qlineedit, 1); // Posiziono il mapper sull'indice opportuno mapperEmailPerson->setCurrentIndex(i); // Inserisco il mapper nella lista dei mapper per le email getQDataWidgetMapperList(tableName)->append(mapperEmailPerson); // qlineedit e button, li visualizzo sulla stessa riga (li inserisco in un layout orizzontale) hbl->addWidget(qlineedit); hbl->addWidget(button); // Inserisco il layout orizzontale nel layout delle mail getVerticalLayout(tableName)->addLayout(hbl); // Collego il pulsante ad uno slot, in modo che venga gestita la rimozione di una riga dal // modello } }
void TableGroupBox::removeRow() { QModelIndexList selectedRows = m_table->selectionModel()->selectedRows(); m_table->model()->removeRows( selectedRows.first().row(), selectedRows.size()); // Update the insert and remove buttons m_insertButton->setEnabled(false); m_removeButton->setEnabled(false); // Notify that the row has been removed emit rowRemoved(); // Signal that the data has changed emit dataChanged(); }
void ParseExcelWidget::on__pushButtonRemove_clicked() { emit rowRemoved(_sheet, _nRow); clearData(); }