summaryrefslogtreecommitdiff
path: root/taglistmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'taglistmodel.cpp')
-rw-r--r--taglistmodel.cpp19
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);