示例#1
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;
  }
}
void OBSBasicFilters::EditItem(QListWidgetItem *item, bool async)
{
	Qt::ItemFlags flags = item->flags();
	OBSSource filter    = item->data(Qt::UserRole).value<OBSSource>();
	const char *name    = obs_source_get_name(filter);
	QListWidget *list   = async ? ui->asyncFilters : ui->effectFilters;

	item->setText(QT_UTF8(name));
	item->setFlags(flags | Qt::ItemIsEditable);
	list->removeItemWidget(item);
	list->editItem(item);
	item->setFlags(flags);
}
示例#3
0
void PredicatXUVParmis::delUv()
{
    QListWidget *candidat = sender()->parent()->findChild<QListWidget*>("candidat");
    if(!candidat)
        UTPROFILER_EXCEPTION("L'editeur de prédicat est corrompu");

    QList<QListWidgetItem*> selection = candidat->selectedItems();

    if(selection.isEmpty())
        return;

    for(auto it = selection.begin() ; it != selection.end() ; it++)
    {
        QListWidgetItem *item = *it;
        qDebug() << item->text();
        candidat->removeItemWidget(item);
        candidats.removeOne(item->text()); //TODO changer le nom de tout ça
    }
}