1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSTRINGLISTMODEL_H
5#define QSTRINGLISTMODEL_H
6
7#include <QtCore/qabstractitemmodel.h>
8#include <QtCore/qstringlist.h>
9
10QT_REQUIRE_CONFIG(stringlistmodel);
11
12QT_BEGIN_NAMESPACE
13
14class Q_CORE_EXPORT QStringListModel : public QAbstractListModel
15{
16 Q_OBJECT
17public:
18 explicit QStringListModel(QObject *parent = nullptr);
19 explicit QStringListModel(const QStringList &strings, QObject *parent = nullptr);
20
21 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
22 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
23
24 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
25 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
26 bool clearItemData(const QModelIndex &index) override;
27
28 Qt::ItemFlags flags(const QModelIndex &index) const override;
29
30 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
31 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
32 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
33
34 QMap<int, QVariant> itemData(const QModelIndex &index) const override;
35 bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
36
37 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
38
39 QStringList stringList() const;
40 void setStringList(const QStringList &strings);
41
42 Qt::DropActions supportedDropActions() const override;
43
44private:
45 Q_DISABLE_COPY(QStringListModel)
46 QStringList lst;
47};
48
49QT_END_NAMESPACE
50
51#endif // QSTRINGLISTMODEL_H
52

source code of qtbase/src/corelib/itemmodels/qstringlistmodel.h