void ArchiveListWidget::addArchives(QList<ArchivePtr > archives) { clear(); std::sort(archives.begin(), archives.end(), ArchiveCompare); foreach (ArchivePtr archive, archives) { ArchiveListItem *item = new ArchiveListItem(archive); connect(item, SIGNAL(requestDelete()), this, SLOT(removeItems())); connect(item, SIGNAL(requestInspect()), this, SLOT(inspectItem())); connect(item, SIGNAL(requestRestore()), this, SLOT(restoreItem())); connect(item, SIGNAL(requestGoToJob()), this, SLOT(goToJob())); this->insertItem(this->count(), item); this->setItemWidget(item, item->widget()); }
void ArchiveListWidget::addArchives(QList<ArchivePtr > archives) { std::sort(archives.begin(), archives.end(), [](const ArchivePtr &a, const ArchivePtr &b) { return (a->timestamp() > b->timestamp()); }); setUpdatesEnabled(false); clear(); foreach(ArchivePtr archive, archives) { ArchiveListItem *item = new ArchiveListItem(archive); connect(item, &ArchiveListItem::requestDelete, this, &ArchiveListWidget::removeItems); connect(item, &ArchiveListItem::requestInspect, this, &ArchiveListWidget::inspectItem); connect(item, &ArchiveListItem::requestRestore, this, &ArchiveListWidget::restoreItem); connect(item, &ArchiveListItem::requestGoToJob, this, &ArchiveListWidget::goToJob); insertItem(count(), item); setItemWidget(item, item->widget()); }