diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/logic/minecraft/ComponentList.cpp | 30 | ||||
-rw-r--r-- | api/logic/minecraft/ComponentList.h | 1 | ||||
-rw-r--r-- | api/logic/minecraft/ComponentList_p.h | 1 |
3 files changed, 26 insertions, 6 deletions
diff --git a/api/logic/minecraft/ComponentList.cpp b/api/logic/minecraft/ComponentList.cpp index b2afdb17..51fe214d 100644 --- a/api/logic/minecraft/ComponentList.cpp +++ b/api/logic/minecraft/ComponentList.cpp @@ -43,6 +43,8 @@ ComponentList::ComponentList(MinecraftInstance * instance) d->m_instance = instance; d->m_saveTimer.setSingleShot(true); d->m_saveTimer.setInterval(5000); + d->interactionDisabled = instance->isRunning(); + connect(d->m_instance, &BaseInstance::runningStatusChanged, this, &ComponentList::disableInteraction); connect(&d->m_saveTimer, &QTimer::timeout, this, &ComponentList::save_internal); } @@ -765,8 +767,9 @@ QVariant ComponentList::data(const QModelIndex &index, int role) const { switch (column) { - case NameColumn: - return d->components.at(row)->isEnabled() ? Qt::Checked : Qt::Unchecked; + case NameColumn: { + return patch->isEnabled() ? Qt::Checked : Qt::Unchecked; + } default: return QVariant(); } @@ -776,7 +779,7 @@ QVariant ComponentList::data(const QModelIndex &index, int role) const switch (column) { case NameColumn: - return d->components.at(row)->getName(); + return patch->getName(); case VersionColumn: { if(patch->isCustom()) @@ -856,21 +859,25 @@ QVariant ComponentList::headerData(int section, Qt::Orientation orientation, int } return QVariant(); } + +// FIXME: zero precision mess Qt::ItemFlags ComponentList::flags(const QModelIndex &index) const { - if (!index.isValid()) + if (!index.isValid()) { return Qt::NoItemFlags; + } Qt::ItemFlags outFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; int row = index.row(); - if (row < 0 || row >= d->components.size()) + if (row < 0 || row >= d->components.size()) { return Qt::NoItemFlags; + } auto patch = d->components.at(row); // TODO: this will need fine-tuning later... - if(patch->canBeDisabled()) + if(patch->canBeDisabled() && !d->interactionDisabled) { outFlags |= Qt::ItemIsUserCheckable; } @@ -1205,3 +1212,14 @@ QString ComponentList::getComponentVersion(const QString& uid) const } return QString(); } + +void ComponentList::disableInteraction(bool disable) +{ + if(d->interactionDisabled != disable) { + d->interactionDisabled = disable; + auto size = d->components.size(); + if(size) { + emit dataChanged(index(0), index(size - 1)); + } + } +} diff --git a/api/logic/minecraft/ComponentList.h b/api/logic/minecraft/ComponentList.h index cb20c559..7b5e1385 100644 --- a/api/logic/minecraft/ComponentList.h +++ b/api/logic/minecraft/ComponentList.h @@ -134,6 +134,7 @@ private slots: void updateSucceeded(); void updateFailed(const QString & error); void componentDataChanged(); + void disableInteraction(bool disable); private: bool load(); diff --git a/api/logic/minecraft/ComponentList_p.h b/api/logic/minecraft/ComponentList_p.h index aed65337..7a3d498b 100644 --- a/api/logic/minecraft/ComponentList_p.h +++ b/api/logic/minecraft/ComponentList_p.h @@ -38,5 +38,6 @@ struct ComponentListData QTimer m_saveTimer; shared_qobject_ptr<Task> m_updateTask; bool loaded = false; + bool interactionDisabled = true; }; |