From: Manuel Nickschas Date: Tue, 9 Aug 2011 16:53:02 +0000 (+0200) Subject: Instantiate the QmlChatView instead of the QGV-based ChatView X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=6721aa2039d9e4e7af548a03aabbb4f73483de0d Instantiate the QmlChatView instead of the QGV-based ChatView 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. --- diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index 7b4e9545..fecdbd5c 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -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(_chatViews.value(id)); +#else ChatView *view = qobject_cast(_chatViews.value(id)); +#endif Q_ASSERT(view); ui.stackedWidget->setCurrentWidget(view); - _chatViewSearchController->setScene(view->scene()); + //_chatViewSearchController->setScene(view->scene()); } } diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 5d50acca..ecdeb981 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -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 bufId = idx.data(MessageModel::BufferIdRole).value(); 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(), 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) diff --git a/src/qtui/qtui.cpp b/src/qtui/qtui.cpp index 88448486..99a6eae3 100644 --- a/src/qtui/qtui.cpp +++ b/src/qtui/qtui.cpp @@ -33,6 +33,10 @@ #include "types.h" #include "util.h" +#ifdef HAVE_QML +# include "qmlmessagemodel.h" +#endif + #ifdef Q_WS_X11 # include #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) {