[packagechooser] Add getters for the *packages* members to the model
This commit is contained in:
parent
5e77d65424
commit
91a29c5885
@ -79,6 +79,33 @@ PackageListModel::addPackage( PackageItem&& p )
|
||||
}
|
||||
}
|
||||
|
||||
QStringList
|
||||
PackageListModel::getInstallPackagesForName( const QString& id ) const
|
||||
{
|
||||
for ( const auto& p : qAsConst( m_packages ) )
|
||||
{
|
||||
if ( p.id == id )
|
||||
{
|
||||
return p.packageNames;
|
||||
}
|
||||
}
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList
|
||||
PackageListModel::getInstallPackagesForNames( const QStringList& ids ) const
|
||||
{
|
||||
QStringList l;
|
||||
for ( const auto& p : qAsConst( m_packages ) )
|
||||
{
|
||||
if ( ids.contains( p.id ) )
|
||||
{
|
||||
l.append( p.packageNames );
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
int
|
||||
PackageListModel::rowCount( const QModelIndex& index ) const
|
||||
{
|
||||
|
@ -98,6 +98,19 @@ public:
|
||||
/// @brief Direct (non-abstract) count of package data
|
||||
int packageCount() const { return m_packages.count(); }
|
||||
|
||||
/** @brief Does a name lookup (based on id) and returns the packages member
|
||||
*
|
||||
* If there is a package with the given @p id, returns its packages
|
||||
* (e.g. the names of underlying packages to install for it); returns
|
||||
* an empty list if the id is not found.
|
||||
*/
|
||||
QStringList getInstallPackagesForName( const QString& id ) const;
|
||||
/** @brief Name-lookup all the @p ids and returns the packages members
|
||||
*
|
||||
* Concatenates installPackagesForName() for each id in @p ids.
|
||||
*/
|
||||
QStringList getInstallPackagesForNames( const QStringList& ids ) const;
|
||||
|
||||
enum Roles : int
|
||||
{
|
||||
NameRole = Qt::DisplayRole,
|
||||
|
Loading…
Reference in New Issue
Block a user