File: generictable.h

package info (click to toggle)
latte-dock 0.10.9-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 11,480 kB
  • sloc: cpp: 43,957; xml: 833; javascript: 734; sh: 43; makefile: 3
file content (72 lines) | stat: -rw-r--r-- 1,757 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
    SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
    SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef GENERICTABLEDATA_H
#define GENERICTABLEDATA_H

// local
#include "genericdata.h"

// Qt
#include <QList>

namespace Latte {
namespace Data {

template <class T>
class GenericTable
{

public:
    GenericTable();
    GenericTable(GenericTable<T> &&o);
    GenericTable(const GenericTable<T> &o);

    //! Operators
    GenericTable<T> &operator=(const GenericTable<T> &rhs);
    GenericTable<T> &operator=(GenericTable<T> &&rhs);
    GenericTable<T> &operator<<(const T &rhs);
    GenericTable<T> &operator<<(const GenericTable<T> &rhs);
    GenericTable<T> &insert(const int &pos, const T &rhs);
    GenericTable<T> &insertBasedOnName(const T &rhs);
    GenericTable<T> &insertBasedOnId(const T &rhs);

    bool operator==(const GenericTable<T> &rhs) const;
    bool operator!=(const GenericTable<T> &rhs) const;
    T &operator[](const QString &id);
    const T operator[](const QString &id) const;
    T &operator[](const uint &index);
    const T operator[](const uint &index) const;
    operator QString() const;

    bool containsId(const QString &id) const;
    bool containsName(const QString &name) const;
    bool isEmpty() const;
    bool rowExists(const int &row) const;

    int indexOf(const QString &id) const;
    int rowCount() const;
    int sortedPosForName(const QString &name) const;
    int sortedPosForId(const QString &id) const;

    QString idForName(const QString &name) const;

    QStringList ids() const;
    QStringList names() const;

    void clear();
    void remove(const int &row);
    void remove(const QString &id);

protected:
    //! #id, record
    QList<T> m_list;

};

}
}

#endif