Instantiate the QmlChatView instead of the QGV-based ChatView
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 9 Aug 2011 16:53:02 +0000 (18:53 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 10 Aug 2011 13:31:22 +0000 (15:31 +0200)
If Quassel is built with -DWITH_QML=ON, we now create and display the
ChatView component rather than the traditional QGraphicsView-based widget.

Note that some features like the ChatMonitor are disabled for now.

src/qtui/bufferwidget.cpp
src/qtui/mainwin.cpp
src/qtui/qtui.cpp

index 7b4e954..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),
@@ -112,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);
@@ -133,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());
   }
 }
 
index 5d50acc..ecdeb98 100644 (file)
@@ -47,7 +47,6 @@
 #include "bufferviewoverlayfilter.h"
 #include "bufferwidget.h"
 #include "channellistdlg.h"
-#include "chatlinemodel.h"
 #include "chatmonitorfilter.h"
 #include "chatmonitorview.h"
 #include "chatview.h"
@@ -71,6 +70,7 @@
 #include "irclistmodel.h"
 #include "ircconnectionwizard.h"
 #include "legacysystemtray.h"
+#include "messagemodel.h"
 #include "msgprocessorstatuswidget.h"
 #include "nicklistwidget.h"
 #include "qtuiapplication.h"
@@ -353,13 +353,13 @@ void MainWin::setupActions() {
 
   // Settings
   QAction *configureShortcutsAct = new Action(SmallIcon("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
-                                             this, SLOT(showShortcutsDlg()));
+                                              this, SLOT(showShortcutsDlg()));
   configureShortcutsAct->setMenuRole(QAction::NoRole);
   coll->addAction("ConfigureShortcuts", configureShortcutsAct);
 
   #ifdef Q_WS_MAC
   QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll,
-                                           this, SLOT(showSettingsDlg()));
+                                            this, SLOT(showSettingsDlg()));
   configureQuasselAct->setMenuRole(QAction::PreferencesRole);
   #else
   QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll,
@@ -369,12 +369,12 @@ void MainWin::setupActions() {
 
   // Help
   QAction *aboutQuasselAct = new Action(SmallIcon("quassel"), tr("&About Quassel"), coll,
-                                       this, SLOT(showAboutDlg()));
+                                        this, SLOT(showAboutDlg()));
   aboutQuasselAct->setMenuRole(QAction::AboutRole);
   coll->addAction("AboutQuassel", aboutQuasselAct);
 
   QAction *aboutQtAct = new Action(QIcon(":/pics/qt-logo.png"), tr("About &Qt"), coll,
-                                  qApp, SLOT(aboutQt()));
+                                   qApp, SLOT(aboutQt()));
   aboutQtAct->setMenuRole(QAction::AboutQtRole);
   coll->addAction("AboutQt", aboutQtAct);
   coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll,
@@ -763,6 +763,8 @@ void MainWin::setupNickWidget() {
 }
 
 void MainWin::setupChatMonitor() {
+// FIXME QML
+#ifndef HAVE_QML
   VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this);
   dock->setObjectName("ChatMonitorDock");
 
@@ -776,6 +778,7 @@ void MainWin::setupChatMonitor() {
   addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
   _viewMenu->addAction(dock->toggleViewAction());
   dock->toggleViewAction()->setText(tr("Show Chat Monitor"));
+#endif
 }
 
 void MainWin::setupInputWidget() {
@@ -1250,16 +1253,16 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
   bool hasFocus = QApplication::activeWindow() != 0;
 
   for(int i = start; i <= end; i++) {
-    QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn);
+    QModelIndex idx = Client::messageModel()->index(i, MessageModel::ContentsColumn);
     if(!idx.isValid()) {
       qDebug() << "MainWin::messagesInserted(): Invalid model index!";
       continue;
     }
-    Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt();
+    Message::Flags flags = (Message::Flags)idx.data(MessageModel::FlagsRole).toInt();
     if(flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self))
       continue;
 
-    BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
+    BufferId bufId = idx.data(MessageModel::BufferIdRole).value<BufferId>();
     BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);
 
     if(hasFocus && bufId == Client::bufferModel()->currentBuffer())
@@ -1269,9 +1272,9 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
       && !(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value<Message>(),
                                                                              Client::networkModel()->networkName(bufId))))
     {
-      QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn);
-      QString sender = senderIdx.data(ChatLineModel::EditRole).toString();
-      QString contents = idx.data(ChatLineModel::DisplayRole).toString();
+      QModelIndex senderIdx = Client::messageModel()->index(i, MessageModel::SenderColumn);
+      QString sender = senderIdx.data(MessageModel::EditRole).toString();
+      QString contents = idx.data(MessageModel::DisplayRole).toString();
       AbstractNotificationBackend::NotificationType type;
 
       if(bufType == BufferInfo::QueryBuffer && !hasFocus)
index 8844848..99a6eae 100644 (file)
 #include "types.h"
 #include "util.h"
 
+#ifdef HAVE_QML
+#  include "qmlmessagemodel.h"
+#endif
+
 #ifdef Q_WS_X11
 #  include <QX11Info>
 #endif
@@ -81,7 +85,11 @@ void QtUi::init() {
 }
 
 MessageModel *QtUi::createMessageModel(QObject *parent) {
+#ifdef HAVE_QML
+  return new QmlMessageModel(parent);
+#else
   return new ChatLineModel(parent);
+#endif
 }
 
 AbstractMessageProcessor *QtUi::createMessageProcessor(QObject *parent) {