aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsample/modelindex.h
blob: 48e1b7de3364ebc47e44a5336d103d57b052b7da (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef MODELINDEX_H
#define MODELINDEX_H

class ModelIndex
{
public:
    ModelIndex() = default;

    inline void setValue(int value) { m_value = value; }
    inline int value() const { return m_value; }
    static int getValue(const ModelIndex &index) { return index.value(); }

private:
    int m_value = 0;
};

class ReferentModelIndex
{
public:
    ReferentModelIndex() = default;

    explicit ReferentModelIndex(const ModelIndex &index) : m_index(index) {}

    inline void setValue(int value) { m_index.setValue(value); }
    inline int value() const { return m_index.value(); }
    operator const ModelIndex&() const { return m_index; }

private:
    ModelIndex m_index;
};

class PersistentModelIndex
{
public:
    PersistentModelIndex() = default;

    explicit PersistentModelIndex(const ModelIndex &index) : m_index(index) {}

    inline void setValue(int value) { m_index.setValue(value); }
    inline int value() const { return m_index.value(); }
    operator ModelIndex() const { return m_index; }

private:
    ModelIndex m_index;
};

#endif // MODELINDEX_H