summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-03-13 23:45:05 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-03-13 23:45:05 +0100
commit7a356f3832c2c401d963cd8a654f62ab56a9288b (patch)
treed34e679a6a9f99e579124c55f5b74674c8c7a655 /src/timeline
parentDisable bundled OpenSSL by default, even with hunter (diff)
parentchange allowed mistakes, fix minor style issues, remove old completer functio... (diff)
downloadnheko-7a356f3832c2c401d963cd8a654f62ab56a9288b.tar.xz
Merge branch 'quickswitcher_qml' of git://github.com/Jedi18/nheko into Jedi18-quickswitcher_qml
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/InputBar.cpp22
-rw-r--r--src/timeline/InputBar.h2
-rw-r--r--src/timeline/TimelineViewManager.cpp42
-rw-r--r--src/timeline/TimelineViewManager.h3
4 files changed, 45 insertions, 24 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp
index 490fccc3..d5a6a1dd 100644
--- a/src/timeline/InputBar.cpp
+++ b/src/timeline/InputBar.cpp
@@ -192,28 +192,6 @@ InputBar::nextText()
         return text();
 }
 
-QObject *
-InputBar::completerFor(QString completerName)
-{
-        if (completerName == "user") {
-                auto userModel = new UsersModel(room->roomId().toStdString());
-                auto proxy     = new CompletionProxyModel(userModel);
-                userModel->setParent(proxy);
-                return proxy;
-        } else if (completerName == "emoji") {
-                auto emojiModel = new emoji::EmojiModel();
-                auto proxy      = new CompletionProxyModel(emojiModel);
-                emojiModel->setParent(proxy);
-                return proxy;
-        } else if (completerName == "room") {
-                auto roomModel = new RoomsModel(true);
-                auto proxy     = new CompletionProxyModel(roomModel);
-                roomModel->setParent(proxy);
-                return proxy;
-        }
-        return nullptr;
-}
-
 void
 InputBar::send()
 {
diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h
index 5af46b0d..acd9e22c 100644
--- a/src/timeline/InputBar.h
+++ b/src/timeline/InputBar.h
@@ -55,8 +55,6 @@ public slots:
         bool uploading() const { return uploading_; }
         void message(QString body, MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED);
 
-        QObject *completerFor(QString completerName);
-
 private slots:
         void startTyping();
         void stopTyping();
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index 74427855..3ed1c21c 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -15,13 +15,16 @@
 #include "BlurhashProvider.h"
 #include "ChatPage.h"
 #include "ColorImageProvider.h"
+#include "CompletionProxyModel.h"
 #include "DelegateChooser.h"
 #include "DeviceVerificationFlow.h"
 #include "Logging.h"
 #include "MainWindow.h"
 #include "MatrixClient.h"
 #include "MxcImageProvider.h"
+#include "RoomsModel.h"
 #include "UserSettingsPage.h"
+#include "UsersModel.h"
 #include "dialogs/ImageOverlay.h"
 #include "emoji/EmojiModel.h"
 #include "emoji/Provider.h"
@@ -334,6 +337,12 @@ TimelineViewManager::setHistoryView(const QString &room_id)
         }
 }
 
+void
+TimelineViewManager::highlightRoom(const QString &room_id)
+{
+        ChatPage::instance()->highlightRoom(room_id);
+}
+
 QString
 TimelineViewManager::escapeEmoji(QString str) const
 {
@@ -556,3 +565,36 @@ TimelineViewManager::focusMessageInput()
 {
         emit focusInput();
 }
+
+QObject *
+TimelineViewManager::completerFor(QString completerName, QString roomId)
+{
+        if (completerName == "user") {
+                auto userModel = new UsersModel(roomId.toStdString());
+                auto proxy     = new CompletionProxyModel(userModel);
+                userModel->setParent(proxy);
+                return proxy;
+        } else if (completerName == "emoji") {
+                auto emojiModel = new emoji::EmojiModel();
+                auto proxy      = new CompletionProxyModel(emojiModel);
+                emojiModel->setParent(proxy);
+                return proxy;
+        } else if (completerName == "room") {
+                auto roomModel = new RoomsModel(false);
+                auto proxy     = new CompletionProxyModel(roomModel, 4);
+                roomModel->setParent(proxy);
+                return proxy;
+        } else if (completerName == "roomAliases") {
+                auto roomModel = new RoomsModel(true);
+                auto proxy     = new CompletionProxyModel(roomModel);
+                roomModel->setParent(proxy);
+                return proxy;
+        }
+        return nullptr;
+}
+
+void
+TimelineViewManager::focusTimeline()
+{
+        getWidget()->setFocus();
+}
\ No newline at end of file
diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 097fccfc..e3ed4991 100644
--- a/src/timeline/TimelineViewManager.h
+++ b/src/timeline/TimelineViewManager.h
@@ -104,6 +104,8 @@ public slots:
         }
 
         void setHistoryView(const QString &room_id);
+        void highlightRoom(const QString &room_id);
+        void focusTimeline();
         TimelineModel *getHistoryView(const QString &room_id)
         {
                 auto room = models.find(room_id);
@@ -142,6 +144,7 @@ public slots:
         }
 
         void backToRooms() { emit showRoomList(); }
+        QObject *completerFor(QString completerName, QString roomId = "");
 
 private:
 #ifdef USE_QUICK_VIEW