Beispiel #1
0
void MainWindow::onLabelAdded(medusa::Label const & label)
{
  QString labelName = QString::fromStdString(label.GetName());

  switch (label.GetType())
  {
  case medusa::Label::LabelData: dataList->addItem(labelName); break;
  case medusa::Label::LabelCode: codeList->addItem(labelName); break;
  case medusa::Label::LabelString: stringList->addItem(labelName); break;
  default: break;
  }

  if (label.GetType() & medusa::Label::LabelImported)
    importedList->addItem(labelName);
  else if (label.GetType() & medusa::Label::LabelExported)
    exportedList->addItem(labelName);
}
Beispiel #2
0
void MainWindow::onLabelRemoved(medusa::Label const & label)
{
  QString labelName = QString::fromStdString(label.GetName());
  QListWidget *curList = nullptr;

  switch (label.GetType())
  {
  case medusa::Label::LabelData:   curList = dataList;   break;
  case medusa::Label::LabelCode:   curList = codeList;   break;
  case medusa::Label::LabelString: curList = stringList; break;
  default:                                               break;
  }

  if (curList != nullptr)
  {
    auto items = curList->findItems(labelName, Qt::MatchExactly);

    // something bad happened
    if (items.size() != 1) return;

    auto item = items.takeFirst();
    curList->removeItemWidget(item);
    delete item;
  }

  if (label.GetType() & medusa::Label::LabelImported)
    curList = importedList;
  else if (label.GetType() & medusa::Label::LabelExported)
    curList = exportedList;

  if (curList != nullptr)
  {
    auto items = curList->findItems(labelName, Qt::MatchExactly);

    // something bad happened
    if (items.size() != 1) return;

    auto item = items.takeFirst();
    curList->removeItemWidget(item);
    delete item;
  }
}
Beispiel #3
0
void LabelView::onRemoveLabel(medusa::Address const& address, medusa::Label const& label)
{
  auto model = this->model();
  _mutex.lock();
  auto const& res = model->match(model->index(0, 0), 0, QString::fromStdString(label.GetLabel()), 1, Qt::MatchExactly);
  if (res.isEmpty())
  {
    _mutex.unlock();
    return;
  }
  model->removeRow(res.at(0).row());
  _mutex.unlock();
}
Beispiel #4
0
void LabelView::onAddLabel(medusa::Address const& address, medusa::Label const& label)
{
  if (label.GetType() & medusa::Label::Local)
    return;

  setUpdatesEnabled(false);
  QString labelType = "";
  switch (label.GetType() & medusa::Label::AccessMask)
  {
  case medusa::Label::Exported: labelType += "exported "; break;
  case medusa::Label::Imported: labelType += "imported "; break;
  default:                                                break;
  }
  switch (label.GetType() & medusa::Label::CellMask)
  {
  case medusa::Label::Code:     labelType += "code";    break;
  case medusa::Label::Function: labelType += "function"; break;
  case medusa::Label::Data:     labelType += "data";    break;
  case medusa::Label::String:   labelType += "string";  break;
  default:                      labelType += "unknown"; break;
  }

  auto model = this->model();
  _mutex.lock();
  const int row = model->rowCount();
  model->insertRow(row);
  model->setData(model->index(row, 0), QString::fromStdString(label.GetLabel()));
  model->setData(model->index(row, 1), labelType);
  model->setData(model->index(row, 2), QString::fromStdString(address.ToString()));

  // This method can assert
  //resizeColumnToContents(0);
  //resizeColumnToContents(1);
  //resizeColumnToContents(2);
  _mutex.unlock();
  setUpdatesEnabled(true);
}