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