Instantiate the QmlChatView instead of the QGV-based ChatView
[quassel.git] / src / qtui / bufferwidget.cpp
index 047759e..fecdbd5 100644 (file)
@@ -37,6 +37,9 @@
 #include "qtui.h"
 #include "settings.h"
 
+#ifdef HAVE_QML
+#  include "qmlchatview.h"
+#endif
 
 BufferWidget::BufferWidget(QWidget *parent)
   : AbstractBufferContainer(parent),
@@ -94,6 +97,10 @@ BufferWidget::BufferWidget(QWidget *parent)
   setMarkerLine->setText(tr("Set Marker Line"));
   setMarkerLine->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
 
+  Action *jumpToMarkerLine = QtUi::actionCollection("Navigation")->add<Action>("JumpToMarkerLine", this, SLOT(jumpToMarkerLine()));
+  jumpToMarkerLine->setText(tr("Go to Marker Line"));
+  jumpToMarkerLine->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
+
   ChatViewSettings s;
   s.initAndNotify("AutoMarkerLine", this, SLOT(setAutoMarkerLine(QVariant)), true);
 }
@@ -108,8 +115,13 @@ void BufferWidget::setAutoMarkerLine(const QVariant &v) {
 }
 
 AbstractChatView *BufferWidget::createChatView(BufferId id) {
+#ifdef HAVE_QML
+  QmlChatView *chatView;
+  chatView = new QmlChatView(id, this);
+#else
   ChatView *chatView;
   chatView = new ChatView(id, this);
+#endif
   chatView->setBufferContainer(this);
   _chatViews[id] = chatView;
   ui.stackedWidget->addWidget(chatView);
@@ -129,10 +141,14 @@ void BufferWidget::showChatView(BufferId id) {
   if(!id.isValid()) {
     ui.stackedWidget->setCurrentWidget(ui.page);
   } else {
+#ifdef HAVE_QML
+    QmlChatView *view = qobject_cast<QmlChatView *>(_chatViews.value(id));
+#else
     ChatView *view = qobject_cast<ChatView *>(_chatViews.value(id));
+#endif
     Q_ASSERT(view);
     ui.stackedWidget->setCurrentWidget(view);
-    _chatViewSearchController->setScene(view->scene());
+    //_chatViewSearchController->setScene(view->scene());
   }
 }
 
@@ -250,3 +266,12 @@ void BufferWidget::setMarkerLine(ChatView *view, bool allowGoingBack) {
     view->setMarkerLine(msgId);
   }
 }
+
+void BufferWidget::jumpToMarkerLine(ChatView *view, bool requestBacklog) {
+  if(!view)
+    view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+  if(!view)
+    return;
+
+  view->jumpToMarkerLine(requestBacklog);
+}