I wasn't sure how else to title this question...

I have a TableView that gets populated with data from a file. Some cells, depending on the data, will have references to other information from the file, but not populated in the table. I flag these cells, so the user will know there's other information pertaining to this data. My goal is to have the user right-click on these flagged cells and have the contextMenuEvent() add a special QAction for these cells only that allows the user to expand on the information (right now I have the returned added information pop up in a QMessageBox). I began by having the program prepend the flagged data with "(OI) - " and then putting the following in MainWindow::contextMenuEvent():

Qt Code:
  1. void MainWindow::contextMenuEvent(QContextMenuEvent *event)
  2. {
  3. QMenu menu(this);
  4. menu.addAction(fileOpenAct);
  5. menu.addAction(fileCloseAct);
  6.  
  7. if (model->data(fileTableView->currentIndex()).toString().contains("(OI)")) {
  8. menu.addSeparator();
  9. menu.addAction(expandInfoAct);
  10. }
  11. menu.exec(event->globalPos());
  12. }
To copy to clipboard, switch view to plain text mode 

So when a user right-clicks on a cell not containing flagged data, they only see "Open" and "Close" as options, but when they do click on a cell with flagged data, they see "Open", "Close" and "Expand..."

expandInfoAct would call a slot that would take the information in the cell and pop up a QMessageBox() with the expanded data.

This works, but I wanted to do away with the "(OI) - " and put an icon in the cell, such as a flag, or an arrow or something.

So as the table is being populated, and the program comes across data that has reference to other information (where it would normally prepend the "(OI) - ") it writes the data to the table along with an icon as follows:

Qt Code:
  1. model->setData(model->index(row, col ,QModelIndex()), data);
  2. model->setData(model->index(row, col, QModelIndex()), QIcon(":MainWindow/images/flag.png"),Qt::DecorationRole);
To copy to clipboard, switch view to plain text mode 

This brings me to my question. Is there a way for contextMenuEvent() to recognize the flag icon in the cell (as it did with "(OI) - ") when the user right-clicks on the cell? I tried the following and it doesn't work:

Qt Code:
  1. void MainWindow::contextMenuEvent(QContextMenuEvent *event)
  2. {
  3. QMenu menu(this);
  4. menu.addAction(fileOpenAct);
  5. menu.addAction(fileCloseAct);
  6. QModelIndexList list;
  7. list << fileTableView->currentIndex();
  8. if (model->mimeData(list)->hasImage()) {
  9. menu.addSeparator();
  10. menu.addAction(expandInfoAct);
  11. }
  12. menu.exec(event->globalPos());
  13. }
To copy to clipboard, switch view to plain text mode 

Or does anybody have any other idea on how to do this?

Thanks!