// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL // SPDX-FileCopyrightText: 2024 Harald Sitter #pragma once #include #include #include "devicerenamemodel.h" class DeviceRenameSaver : public QObject { Q_OBJECT Q_PROPERTY(QList models MEMBER m_models WRITE setModels NOTIFY modelsChanged REQUIRED) Q_PROPERTY(bool busy MEMBER m_busy NOTIFY busyChanged) Q_PROPERTY(QString error MEMBER m_error NOTIFY errorChanged) Q_PROPERTY(bool dirty READ isDirty NOTIFY dirtyChanged) public: explicit DeviceRenameSaver(QObject *parent = nullptr); void setModels(const QList &models); [[nodiscard]] bool containsOverride(const QString &name) const; [[nodiscard]] QVariantMap override(const QString &name) const; void insertOverride(const QString &name, const QVariantMap &override); void removeOverride(const QString &name); [[nodiscard]] bool isDirty() const; [[nodiscard]] bool containsOriginalOverride(const QString &name) const; Q_SIGNALS: void modelsChanged(); void busyChanged(); void errorChanged(); void dirtyChanged(); public Q_SLOTS: void saveChanges(); private: void setError(const QString &error); static QHash readOverrides(); bool writeOverrides(const QHash &overrides); void restartWirePlumber(); QList m_models; QHash m_originalOverrides = readOverrides(); QHash m_overrides = m_originalOverrides; QString m_error; bool m_busy = false; // happens when we have data reloading pending QTimer m_readyTimer; };