diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-08-17 00:56:17 +0200 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-08-17 00:56:17 +0200 |
commit | c6713d0876ce2d99f912151c9884477606909681 (patch) | |
tree | 07717d3ffb8d78095f83bee5b0779a6bd264149a /taglistmodel.cpp | |
parent | 2deadc6cfbf71e06908963fb1bae628cfe370f9d (diff) | |
download | numberator-c6713d0876ce2d99f912151c9884477606909681.tar.gz numberator-c6713d0876ce2d99f912151c9884477606909681.tar.bz2 numberator-c6713d0876ce2d99f912151c9884477606909681.zip |
More UI work
Diffstat (limited to 'taglistmodel.cpp')
-rw-r--r-- | taglistmodel.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/taglistmodel.cpp b/taglistmodel.cpp index d68fc57..435f5f1 100644 --- a/taglistmodel.cpp +++ b/taglistmodel.cpp @@ -17,10 +17,24 @@ int TagListModel::rowCount(const QModelIndex &parent) const return cached_tags.size();
}
+bool collateTagNames(QString a, QString b) {
+ QRegularExpression name_re("^(\\d*)(.*?)(\\d*)$");
+ auto res_a = name_re.match(a), res_b = name_re.match(b);
+
+ if (res_a.captured(1).isEmpty() && !res_b.captured(1).isEmpty())
+ return true;
+
+ if (res_a.captured().toInt() < res_b.captured().toInt())
+ return true;
+ /* FIXME TODO */
+}
+
void TagListModel::reloadTags()
{
+ qDebug() << "TagListModel::reloadTags()";
beginResetModel();
cached_tags = backend.getAllTags();
+ std::sort(cached_tags.begin(), cached_tags.end(), [](const Tag &a, const Tag &b) { return collateTagNames(a.name, b.name); });
endResetModel();
}
@@ -47,6 +61,11 @@ QVariant TagListModel::headerData(int section, Qt::Orientation orientation, int return QString("Tag");
}
+QModelIndex TagListModel::indexOf(const Tag &t) const
+{
+ return index(cached_tags.indexOf(t));
+}
+
Qt::ItemFlags TagListModel::flags(const QModelIndex &index) const
{
Q_UNUSED(index);
|