mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-18 17:32:00 +00:00
modellist: reduce updateData indent
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
9ec0f92f67
commit
62186a007e
@ -820,18 +820,24 @@ QVariant ModelList::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
|
||||
void ModelList::updateData(const QString &id, const QVector<QPair<int, QVariant>> &data)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
updateDataInternal(id, data, lock, /*relock*/ false);
|
||||
}
|
||||
|
||||
void ModelList::updateDataInternal(const QString &id, const QVector<QPair<int, QVariant>> &data,
|
||||
QMutexLocker<QMutex> &lock, bool relock)
|
||||
{
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
int index;
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
Q_ASSERT(lock.isLocked());
|
||||
|
||||
if (!m_modelMap.contains(id)) {
|
||||
qWarning() << "ERROR: cannot update as model map does not contain" << id;
|
||||
return;
|
||||
}
|
||||
|
||||
ModelInfo *info = m_modelMap.value(id);
|
||||
index = m_models.indexOf(info);
|
||||
int index = m_models.indexOf(info);
|
||||
if (index == -1) {
|
||||
qWarning() << "ERROR: cannot update as model list does not contain" << id;
|
||||
return;
|
||||
@ -1009,9 +1015,12 @@ void ModelList::updateData(const QString &id, const QVector<QPair<int, QVariant>
|
||||
return ModelList::lessThan(lhs, rhs, s, d);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
emit dataChanged(createIndex(index, 0), createIndex(index, 0));
|
||||
emit selectableModelListChanged();
|
||||
if (relock)
|
||||
lock.relock();
|
||||
}
|
||||
|
||||
void ModelList::resortModel()
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
template <typename> class QMutexLocker;
|
||||
|
||||
|
||||
struct ModelInfo {
|
||||
Q_GADGET
|
||||
@ -495,6 +497,10 @@ private Q_SLOTS:
|
||||
void handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||
|
||||
private:
|
||||
// call with lock held
|
||||
void updateDataInternal(const QString &id, const QVector<QPair<int, QVariant>> &data, QMutexLocker<QMutex> &lock,
|
||||
bool relock = true);
|
||||
|
||||
void removeInternal(const ModelInfo &model);
|
||||
void clearDiscoveredModels();
|
||||
bool modelExists(const QString &fileName) const;
|
||||
|
Loading…
Reference in New Issue
Block a user