File indexing completed on 2025-03-16 05:18:27

0001 /*
0002  * Copyright 2018 by Marco Martin <mart@kde.org>
0003  *
0004  * Licensed under the Apache License, Version 2.0 (the "License");
0005  * you may not use this file except in compliance with the License.
0006  * You may obtain a copy of the License at
0007  *
0008  *    http://www.apache.org/licenses/LICENSE-2.0
0009  *
0010  * Unless required by applicable law or agreed to in writing, software
0011  * distributed under the License is distributed on an "AS IS" BASIS,
0012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013  * See the License for the specific language governing permissions and
0014  * limitations under the License.
0015  *
0016  */
0017 
0018 #pragma once
0019 
0020 #include <QQmlPropertyMap>
0021 
0022 class QTimer;
0023 class AbstractSkillView;
0024 
0025 class SessionDataMap : public QQmlPropertyMap
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     SessionDataMap(const QString &skillId, AbstractSkillView *parent);
0031     ~SessionDataMap() override;
0032 
0033     /**
0034      * Like insert, but will emit the valueChanged() signal
0035      */
0036     void insertAndNotify(const QString &key, const QVariant &value);
0037 
0038     /**
0039      * Like clear(), but will emit the dataCleared() signal
0040      */
0041     void clearAndNotify(const QString &key);
0042 
0043 Q_SIGNALS:
0044     /**
0045      * Key has been removed fro the map
0046      */
0047     void dataCleared(const QString &key);
0048 
0049 protected:
0050     QVariant updateValue(const QString &key, const QVariant &input) override;
0051 
0052 private:
0053     QString m_skillId;
0054     QVariantMap m_propertiesToUpdate;
0055     QStringList m_propertiesToDelete;
0056     QTimer *m_updateTimer;
0057     AbstractSkillView *m_view;
0058 };
0059