Beispiel #1
0
void PackageRepository::setAURData(const QList<PackageListData>*const listOfForeignPackages,
                                   const QSet<QString>& unrequiredPackages)
{
  //  std::cout << "received new foreign package list" << std::endl;

    std::for_each(m_dependingModels.begin(), m_dependingModels.end(), BeginResetModel());

    // delete AUR items in list
    /*for (TListOfPackages::iterator it = m_listOfPackages.begin(); it != m_listOfPackages.end(); ++it) {
      if (*it != NULL && (*it)->managedByAUR) {
        delete *it;
        it = m_listOfPackages.erase(it);
      }
    }*/
    m_listOfAURPackages.clear();

    for (QList<PackageListData>::const_iterator it = listOfForeignPackages->begin();
         it != listOfForeignPackages->end(); ++it)
    {
      //qDebug() << "Status: " << (*it).status;

      PackageData*const pkg = new PackageData(*it, unrequiredPackages.contains(it->name) == false);
      m_listOfPackages.push_back(pkg);
      m_listOfAURPackages.push_back(pkg);
    }   

    qSort(m_listOfPackages.begin(), m_listOfPackages.end(), TSort());
    qSort(m_listOfAURPackages.begin(), m_listOfAURPackages.end(), TSort());
    std::for_each(m_dependingModels.begin(), m_dependingModels.end(), EndResetModel());
}
Beispiel #2
0
/*
 * Iterates over the package list to mark outdated foreign packages
 */
void PackageRepository::setAUROutdatedData(QList<PackageListData>*const listOfForeignPackages,
                                           const QStringList& outdatedAURPackages)
{
  std::for_each(m_dependingModels.begin(), m_dependingModels.end(), BeginResetModel());

  //delete AUR items in list
  for (TListOfPackages::iterator it = m_listOfPackages.begin(); it != m_listOfPackages.end(); ++it) {
    if (*it != NULL && ((*it)->status == ectn_FOREIGN || (*it)->status == ectn_FOREIGN_OUTDATED)) {
      delete *it;
      it = m_listOfPackages.erase(it);
    }
  }
  m_listOfAURPackages.clear();

  for (QList<PackageListData>::iterator it = listOfForeignPackages->begin();
       it != listOfForeignPackages->end(); ++it)
  {
    if (outdatedAURPackages.contains(it->name))
    {
      it->status = ectn_FOREIGN_OUTDATED;
    }

    PackageData*const pkg = new PackageData(*it, true, true);
    m_listOfPackages.push_back(pkg);
    m_listOfAURPackages.push_back(pkg);
  }

  qSort(m_listOfPackages.begin(), m_listOfPackages.end(), TSort());
  qSort(m_listOfAURPackages.begin(), m_listOfAURPackages.end(), TSort());
  std::for_each(m_dependingModels.begin(), m_dependingModels.end(), EndResetModel());
}
Beispiel #3
0
/**
 * @brief if the repository groups differ from %listOfGroups they will be reset
 * @param listOfGroups == group names
 */
void PackageRepository::checkAndSetGroups(const QStringList& listOfGroups)
{
  if (memberListOfGroupsEquals(listOfGroups) == false) {
    std::for_each(m_dependingModels.begin(), m_dependingModels.end(), BeginResetModel());
    for (QList<Group*>::const_iterator it = m_listOfGroups.begin(); it != m_listOfGroups.end(); ++it) {
      if (*it != NULL) delete *it;
    }
    m_listOfGroups.clear();

    for (QStringList::const_iterator it = listOfGroups.begin(); it != listOfGroups.end(); ++it) {
      m_listOfGroups.push_back(new Group(*it));
    }
    std::for_each(m_dependingModels.begin(), m_dependingModels.end(), EndResetModel());
  }
}
Beispiel #4
0
/**
 * @brief checks the PackageRepository if the members of %groupName differ from %members and replaces with %members if necessary
 * @param groupName (name of the group)
 * @param members (should be output of Package::getPackagesOfGroup)
 */
void PackageRepository::checkAndSetMembersOfGroup(const QString& groupName, const QStringList& members)
{
  QList<Group*>::const_iterator groupIt = m_listOfGroups.begin();
  for (; groupIt != m_listOfGroups.end(); ++groupIt) {
    if (*groupIt != NULL && (*groupIt)->getName() == groupName) {
      break;
    }
  }
  if (groupIt != m_listOfGroups.end()) {
    Group& group = **groupIt;
//    std::cout << "processing group " << group.getName().toStdString() << std::endl;
    if (group.memberListEquals(members) == false) {

      // invalidate and register all group members if lists are different
      std::for_each(m_dependingModels.begin(), m_dependingModels.end(), BeginResetModel());
      group.invalidateList();

      for (QStringList::const_iterator it = members.begin(); it != members.end(); ++it) {
        typedef TListOfPackages::const_iterator TIter;
        std::pair<TIter, TIter> packageIt =  std::equal_range(m_listOfPackages.begin(), m_listOfPackages.end(), *it, TComp());

        for (TIter iter = packageIt.first; iter != packageIt.second; ++iter) {
          //if ((*iter)->managedByAUR == false) {
            group.addPackage(**iter);
            break;
          //}
        }
      }
      std::for_each(m_dependingModels.begin(), m_dependingModels.end(), EndResetModel());

    }
  }
  else {
    std::cerr << "did not find package group " << groupName.toStdString() << std::endl;
    assert(false);
  }
}
Beispiel #5
0
void PackageRepository::setData(const QList<PackageListData>*const listOfPackages, const QSet<QString>& unrequiredPackages)
{
//  std::cout << "received new package list" << std::endl;

  std::for_each(m_dependingModels.begin(), m_dependingModels.end(), BeginResetModel());

  // delete items in groups list
  for (QList<Group*>::const_iterator it = m_listOfGroups.begin(); it != m_listOfGroups.end(); ++it) {
    if (*it != NULL) (*it)->invalidateList();
  }
  // delete items in list
  for (TListOfPackages::const_iterator it = m_listOfPackages.begin(); it != m_listOfPackages.end(); ++it) {
    if (*it != NULL) delete *it;
  }
  m_listOfAURPackages.clear();
  m_listOfPackages.clear();

  for (QList<PackageListData>::const_iterator it = listOfPackages->begin(); it != listOfPackages->end(); ++it) {
    m_listOfPackages.push_back(new PackageData(*it, unrequiredPackages.contains(it->name) == false));
  }

  qSort(m_listOfPackages.begin(), m_listOfPackages.end(), TSort());
  std::for_each(m_dependingModels.begin(), m_dependingModels.end(), EndResetModel());
}