summary refs log tree commit diff
path: root/src/GridImagePackModel.h
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-05-19 22:05:14 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-05-20 00:57:51 +0200
commit777bf9f9f61c85bd560121ceb20bbffe9dbc0f1b (patch)
tree78dbe3f40c601f5bbf51e009bdb0399c06a25e3a /src/GridImagePackModel.h
parentReplace search vector with span (diff)
downloadnheko-777bf9f9f61c85bd560121ceb20bbffe9dbc0f1b.tar.xz
Reimplement search for GridImageModel
Diffstat (limited to '')
-rw-r--r--src/GridImagePackModel.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/GridImagePackModel.h b/src/GridImagePackModel.h
index 1345b103..06dfe734 100644
--- a/src/GridImagePackModel.h
+++ b/src/GridImagePackModel.h
@@ -5,11 +5,14 @@
 #pragma once
 
 #include <QAbstractListModel>
+#include <QMultiMap>
 #include <QObject>
 #include <QString>
 
 #include <mtx/events/mscs/image_packs.hpp>
 
+#include "CompletionProxyModel.h"
+
 struct StickerImage
 {
     Q_GADGET
@@ -41,6 +44,8 @@ public:
 class GridImagePackModel final : public QAbstractListModel
 {
     Q_OBJECT
+    Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY newSearchString)
+
 public:
     enum Roles
     {
@@ -53,6 +58,12 @@ public:
     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
     QVariant data(const QModelIndex &index, int role) const override;
 
+    QString searchString() const { return searchString_; }
+    void setSearchString(QString newValue);
+
+signals:
+    void newSearchString();
+
 private:
     std::string room_id;
 
@@ -69,4 +80,9 @@ private:
     std::vector<PackDesc> packs;
     std::vector<size_t> rowToPack;
     int columns = 3;
+
+    QString searchString_;
+    trie<uint, std::pair<std::uint32_t, std::uint32_t>> trie_;
+    std::vector<std::pair<std::uint32_t, std::uint32_t>> currentSearchResult;
+    std::vector<std::size_t> rowToFirstRowEntryFromSearch;
 };