コード例 #1
0
ファイル: LabelView.cpp プロジェクト: GrimDerp/medusa
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();
}
コード例 #2
0
ファイル: LabelView.cpp プロジェクト: GrimDerp/medusa
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);
}