Originally Posted by
jpn
man I made it work....but wanted something simpler...it wasnt hard of course...
foreach
(QModelIndex index, msgTableView
->selectionModel
()->selectedRows
()){ QModelIndex sourceIndex
= filterModel
->mapToSource
(index
);
int row = sourceIndex.row();
for(int i = 0; i < model->columnCount(); i++){
if(i == 0){
sendMsg.id = prepMsg.toString().toULong();
qDebug("Message id = %ld", sendMsg.id);
}
if(i == 1){
sendMsg.flags = prepMsg.toString().toInt();
qDebug("Message flags = %d", sendMsg.flags);
}
if(i == 2){
int length = qMin(sendData.size(), CAN_MSG_LENGTH);
qDebug("LENGTH = %d", length);
memcpy(sendMsg.data, (const unsigned char*)sendData.constData(), length);
sendMsg.length = length;
}
}
parentWindow->getNetworkIfc()->sendCanMsg(&sendMsg);
QVcaCanMsg sharedMsg(&sendMsg);
emit msgHistoryEnqueue(sharedMsg);
}
foreach(QModelIndex index, msgTableView->selectionModel()->selectedRows()){
QModelIndex sourceIndex = filterModel->mapToSource(index);
int row = sourceIndex.row();
for(int i = 0; i < model->columnCount(); i++){
QModelIndex index2 = model->index(row, i);
QVariant prepMsg = model->data(index2);
if(i == 0){
sendMsg.id = prepMsg.toString().toULong();
qDebug("Message id = %ld", sendMsg.id);
}
if(i == 1){
sendMsg.flags = prepMsg.toString().toInt();
qDebug("Message flags = %d", sendMsg.flags);
}
if(i == 2){
QByteArray sendData = QByteArray::fromHex(prepMsg.toString().toAscii());
int length = qMin(sendData.size(), CAN_MSG_LENGTH);
qDebug("LENGTH = %d", length);
memcpy(sendMsg.data, (const unsigned char*)sendData.constData(), length);
sendMsg.length = length;
}
}
parentWindow->getNetworkIfc()->sendCanMsg(&sendMsg);
QVcaCanMsg sharedMsg(&sendMsg);
emit msgHistoryEnqueue(sharedMsg);
}
To copy to clipboard, switch view to plain text mode
Bookmarks