aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/collectioneditor/datastoremodelnode.h
blob: 1c855bca7a21c609041c08f7e4439fef5fb90d4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <modelnode.h>

#include <QMap>

namespace Utils {
class FilePath;
}

namespace QmlDesigner {

class Model;

class DataStoreModelNode
{
public:
    DataStoreModelNode();

    void reloadModel();
    QStringList collectionNames() const;

    Model *model() const;
    ModelNode modelNode() const;

    void setCollectionNames(const QStringList &newCollectionNames);
    void renameCollection(const QString &oldName, const QString &newName);
    void removeCollection(const QString &collectionName);

    void assignCollectionToNode(AbstractView *view,
                                const ModelNode &targetNode,
                                const QString &collectionName);

private:
    QString getModelQmlText();

    void reset();
    void preloadFile();
    void updateDataStoreProperties();
    void updateSingletonFile();
    void update();
    void addCollectionNameToTheModel(const QString &collectionName,
                                     const PropertyName &dataStorePropertyName);
    Utils::FilePath dataStoreQmlFilePath() const;

    PropertyName getUniquePropertyName(const QString &collectionName);

    ModelPointer m_model;
    QMap<QString, PropertyName> m_collectionPropertyNames;
    QString m_dataRelativePath;
};

} // namespace QmlDesigner