Sort groups alphabetically
parent
8ce72bb9da
commit
6eee9e8b89
|
|
@ -258,6 +258,7 @@ void registerQmlTypes() {
|
|||
qmlRegisterUncreatableType<Tag>(uri, 1, 0, "Tag", "Get it from Tags");
|
||||
qmlRegisterType<TagsProxyModel>(uri, 1, 0, "TagsProxyModel");
|
||||
qmlRegisterType<TagListModel>(uri, 1, 0, "TagListModel");
|
||||
qmlRegisterType<TagListProxyModel>(uri, 1, 0, "TagListProxyModel");
|
||||
|
||||
qmlRegisterType<NetworkManagerController>(uri, 1, 0, "NetworkManagerController");
|
||||
qmlRegisterType<BluetoothDiscovery>(uri, 1, 0, "BluetoothDiscovery");
|
||||
|
|
|
|||
|
|
@ -127,3 +127,31 @@ void TagListModel::update()
|
|||
endResetModel();
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
TagListProxyModel::TagListProxyModel(QObject *parent):
|
||||
QSortFilterProxyModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TagListModel *TagListProxyModel::tagListModel() const
|
||||
{
|
||||
return m_tagListModel;
|
||||
}
|
||||
|
||||
void TagListProxyModel::setTagListModel(TagListModel *tagListModel)
|
||||
{
|
||||
if (m_tagListModel != tagListModel) {
|
||||
m_tagListModel = tagListModel;
|
||||
setSourceModel(tagListModel);
|
||||
emit tagListModelChanged();
|
||||
|
||||
connect(tagListModel, &TagListModel::countChanged, this, &TagListProxyModel::countChanged);
|
||||
|
||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
setSortRole(TagListModel::RoleTagId);
|
||||
sort(0);
|
||||
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#define TAGLISTMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class TagsProxyModel;
|
||||
class Tag;
|
||||
|
|
@ -71,4 +72,27 @@ private:
|
|||
QList<Tag*> m_list;
|
||||
};
|
||||
|
||||
class TagListProxyModel: public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(TagListModel *tagListModel READ tagListModel WRITE setTagListModel NOTIFY tagListModelChanged)
|
||||
|
||||
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
||||
|
||||
public:
|
||||
TagListProxyModel(QObject *parent = nullptr);
|
||||
|
||||
TagListModel *tagListModel() const;
|
||||
void setTagListModel(TagListModel *tagListModel);
|
||||
|
||||
signals:
|
||||
void tagListModelChanged();
|
||||
|
||||
void countChanged();
|
||||
|
||||
private:
|
||||
TagListModel *m_tagListModel = nullptr;
|
||||
};
|
||||
|
||||
#endif // TAGLISTMODEL_H
|
||||
|
|
|
|||
|
|
@ -47,10 +47,12 @@ MainViewBase {
|
|||
readonly property int minTileWidth: 172
|
||||
readonly property int tilesPerRow: root.width / minTileWidth
|
||||
|
||||
model: TagListModel {
|
||||
tagsProxy: TagsProxyModel {
|
||||
tags: engine.tagsManager.tags
|
||||
filterTagId: "group-.*"
|
||||
model: TagListProxyModel {
|
||||
tagListModel: TagListModel {
|
||||
tagsProxy: TagsProxyModel {
|
||||
tags: engine.tagsManager.tags
|
||||
filterTagId: "group-.*"
|
||||
}
|
||||
}
|
||||
}
|
||||
cellWidth: width / tilesPerRow
|
||||
|
|
|
|||
Loading…
Reference in New Issue