Sort groups alphabetically
This commit is contained in:
parent
8ce72bb9da
commit
6eee9e8b89
@ -258,6 +258,7 @@ void registerQmlTypes() {
|
|||||||
qmlRegisterUncreatableType<Tag>(uri, 1, 0, "Tag", "Get it from Tags");
|
qmlRegisterUncreatableType<Tag>(uri, 1, 0, "Tag", "Get it from Tags");
|
||||||
qmlRegisterType<TagsProxyModel>(uri, 1, 0, "TagsProxyModel");
|
qmlRegisterType<TagsProxyModel>(uri, 1, 0, "TagsProxyModel");
|
||||||
qmlRegisterType<TagListModel>(uri, 1, 0, "TagListModel");
|
qmlRegisterType<TagListModel>(uri, 1, 0, "TagListModel");
|
||||||
|
qmlRegisterType<TagListProxyModel>(uri, 1, 0, "TagListProxyModel");
|
||||||
|
|
||||||
qmlRegisterType<NetworkManagerController>(uri, 1, 0, "NetworkManagerController");
|
qmlRegisterType<NetworkManagerController>(uri, 1, 0, "NetworkManagerController");
|
||||||
qmlRegisterType<BluetoothDiscovery>(uri, 1, 0, "BluetoothDiscovery");
|
qmlRegisterType<BluetoothDiscovery>(uri, 1, 0, "BluetoothDiscovery");
|
||||||
|
|||||||
@ -127,3 +127,31 @@ void TagListModel::update()
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
emit countChanged();
|
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
|
#define TAGLISTMODEL_H
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
class TagsProxyModel;
|
class TagsProxyModel;
|
||||||
class Tag;
|
class Tag;
|
||||||
@ -71,4 +72,27 @@ private:
|
|||||||
QList<Tag*> m_list;
|
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
|
#endif // TAGLISTMODEL_H
|
||||||
|
|||||||
@ -47,10 +47,12 @@ MainViewBase {
|
|||||||
readonly property int minTileWidth: 172
|
readonly property int minTileWidth: 172
|
||||||
readonly property int tilesPerRow: root.width / minTileWidth
|
readonly property int tilesPerRow: root.width / minTileWidth
|
||||||
|
|
||||||
model: TagListModel {
|
model: TagListProxyModel {
|
||||||
tagsProxy: TagsProxyModel {
|
tagListModel: TagListModel {
|
||||||
tags: engine.tagsManager.tags
|
tagsProxy: TagsProxyModel {
|
||||||
filterTagId: "group-.*"
|
tags: engine.tagsManager.tags
|
||||||
|
filterTagId: "group-.*"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cellWidth: width / tilesPerRow
|
cellWidth: width / tilesPerRow
|
||||||
|
|||||||
Reference in New Issue
Block a user