void FrameInfoWindow::showEvent(QShowEvent* event) { QDialog::showEvent(event); readSettings(); refreshIDList(); if (ui->listFrameID->count() > 0) { updateDetailsWindow(ui->listFrameID->item(0)->text()); ui->listFrameID->setCurrentRow(0); } }
//remember, negative numbers are special -1 = all frames deleted, -2 = totally new set of frames. void FrameInfoWindow::updatedFrames(int numFrames) { if (numFrames == -1) //all frames deleted. Kill the display { ui->listFrameID->clear(); ui->treeDetails->clear(); refreshIDList(); } else if (numFrames == -2) //all new set of frames. Reset { refreshIDList(); if (ui->listFrameID->count() > 0) { updateDetailsWindow(ui->listFrameID->item(0)->text()); ui->listFrameID->setCurrentRow(0); } } else //just got some new frames. See if they are relevant. { if (numFrames > modelFrames->count()) return; int currID = ui->listFrameID->currentItem()->text().toInt(NULL, 16); bool foundID = false; for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++) { if (currID == modelFrames->at(x).ID) { foundID = true; break; } } if (foundID) { //the problem here is that it'll blast us out of the details as soon as this //happens. The only way to do this properly is to actually traverse //the details structure and change the text. We don't do that yet. //so, the line is commented out. If people need to see the updated //data they can click another ID and back and it'll be OK //updateDetailsWindow(ui->listFrameID->currentItem()->text()); } } }
//remember, negative numbers are special -1 = all frames deleted, -2 = totally new set of frames. void FrameInfoWindow::updatedFrames(int numFrames) { if (numFrames == -1) //all frames deleted. Kill the display { //qDebug() << "Delete all frames in Info Window"; ui->listFrameID->clear(); ui->treeDetails->clear(); foundID.clear(); refreshIDList(); } else if (numFrames == -2) //all new set of frames. Reset { //qDebug() << "All new set of frames in Info Window"; ui->listFrameID->clear(); ui->treeDetails->clear(); foundID.clear(); refreshIDList(); if (ui->listFrameID->count() > 0) { updateDetailsWindow(ui->listFrameID->item(0)->text()); ui->listFrameID->setCurrentRow(0); } } else //just got some new frames. See if they are relevant. { //qDebug() << "Got frames in Info Window"; if (numFrames > modelFrames->count()) return; unsigned int currID = 0; if (ui->listFrameID->currentItem()) currID = (unsigned int)ui->listFrameID->currentItem()->text().toInt(NULL, 16); bool thisID = false; for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++) { CANFrame thisFrame = modelFrames->at(x); unsigned int id = thisFrame.ID; if (!foundID.contains(id)) { foundID.append(id); ui->listFrameID->addItem(Utility::formatCANID(id, thisFrame.extended)); } if (currID == modelFrames->at(x).ID) { thisID = true; break; } } if (thisID) { //the problem here is that it'll blast us out of the details as soon as this //happens. The only way to do this properly is to actually traverse //the details structure and change the text. We don't do that yet. //so, the line is commented out. If people need to see the updated //data they can click another ID and back and it'll be OK //updateDetailsWindow(ui->listFrameID->currentItem()->text()); } //default is to sort in ascending order ui->listFrameID->sortItems(); ui->lblFrameID->setText(tr("Frame IDs: (") + QString::number(ui->listFrameID->count()) + tr(" unique ids)")); } }