Search
j0ke.net Open Build Service
>
Projects
>
home:netmax
:
playground
>
owncloud-client211
> nolambda.diff
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File nolambda.diff of Package owncloud-client211
diff --git a/src/gui/sharee.cpp b/src/gui/sharee.cpp index 08aae3c..86f6a20 100644 --- a/src/gui/sharee.cpp +++ b/src/gui/sharee.cpp @@ -140,6 +140,18 @@ QSharedPointer<Sharee> ShareeModel::parseSharee(const QVariantMap &data) return QSharedPointer<Sharee>(new Sharee(shareWith, displayName, type)); } + +// Helper function for setNewSharees (could be a lambda when we can use them) +static QSharedPointer<Sharee> shareeFromModelIndex(const QModelIndex &idx) +{ return idx.data(Qt::UserRole).value<QSharedPointer<Sharee>>(); } + +struct FindShareeHelper { + const QSharedPointer<Sharee> &sharee; + bool operator()(const QSharedPointer<Sharee> &s2) const { + return s2->format() == sharee->format() && s2->displayName() == sharee->format(); + } +}; + /* Set the new sharee Do that while preserving the model index so the selection stays @@ -152,17 +164,15 @@ void ShareeModel::setNewSharees(const QVector<QSharedPointer<Sharee>>& newSharee oldPersistantSharee.reserve(persistent.size()); std::transform(persistent.begin(), persistent.end(), std::back_inserter(oldPersistantSharee), - [](const QModelIndex &idx) { return idx.data(Qt::UserRole).value<QSharedPointer<Sharee>>(); }); + shareeFromModelIndex); _sharees = newSharees; QModelIndexList newPersistant; newPersistant.reserve(persistent.size()); foreach(const QSharedPointer<Sharee> &sharee, oldPersistantSharee) { - auto it = std::find_if(_sharees.constBegin(), _sharees.constEnd(), - [&sharee](const QSharedPointer<Sharee> &s2) { - return s2->format() == sharee->format() && s2->displayName() == sharee->format(); - }); + FindShareeHelper helper = { sharee }; + auto it = std::find_if(_sharees.constBegin(), _sharees.constEnd(), helper); if (it == _sharees.constEnd()) { newPersistant << QModelIndex(); } else {