chatwidget (via #ifdef SPUTDEV). Allows me to b0rk code in the new files without breaking compiling
for the non-SPUTDEV users.
_bufferModel = new BufferModel(_networkModel);
#ifdef SPUTDEV
- _messageModel = new MessageModel(this);
+ _messageModel = mainUi->createMessageModel(this);
#endif
SignalProxy *p = signalProxy();
}
}
+#ifndef SPUTDEV
void Client::recvMessage(const Message &message) {
Message msg = message;
Buffer *b;
// TODO: make redirected messages show up in the correct buffer!
-#ifndef SPUTDEV
if(msg.flags() & Message::Redirected) {
BufferSettings bufferSettings;
bool inStatus = bufferSettings.value("UserMessagesInStatusBuffer", QVariant(true)).toBool();
b = buffer(msg.bufferInfo());
b->appendMsg(msg);
}
-#endif
-
//bufferModel()->updateBufferActivity(msg);
- // monitor buffer goes away
-#ifndef SPUTDEV
if(msg.type() == Message::Plain || msg.type() == Message::Notice || msg.type() == Message::Action) {
const Network *net = network(msg.bufferInfo().networkId());
QString networkName = net != 0
Message mmsg = Message(msg.timestamp(), msg.bufferInfo(), msg.type(), msg.text(), sender, msg.flags());
monitorBuffer()->appendMsg(mmsg);
}
-#endif
-
emit messageReceived(msg);
}
+#else
+
+void Client::recvMessage(const Message &msg) {
+
+
+}
+
+#endif /* SPUTDEV */
void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) {
//recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg)));
qWarning() << "Client::recvBacklogData(): received Backlog for unknown Buffer:" << bufferId;
return;
}
-#endif
if(msgs.isEmpty())
return; // no work to be done...
if(!layoutTimer->isActive()) {
layoutTimer->start();
}
+#endif
}
void Client::layoutMsg() {
DEPMOD = common
QT_MOD = core network gui
-SRCS += buffer.cpp buffersettings.cpp clientbacklogmanager.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp client.cpp clientsettings.cpp clientsyncer.cpp \
- mappedselectionmodel.cpp selectionmodelsynchronizer.cpp
-HDRS += buffer.h buffersettings.h clientbacklogmanager.h treemodel.h networkmodel.h buffermodel.h client.h clientsettings.h clientsyncer.h quasselui.h \
- mappedselectionmodel.h selectionmodelsynchronizer.h
+SRCS += buffer.cpp buffersettings.cpp clientbacklogmanager.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp \
+ client.cpp clientsettings.cpp clientsyncer.cpp mappedselectionmodel.cpp selectionmodelsynchronizer.cpp
+HDRS += buffer.h buffersettings.h clientbacklogmanager.h treemodel.h networkmodel.h buffermodel.h \
+ client.h clientsettings.h clientsyncer.h quasselui.h mappedselectionmodel.h selectionmodelsynchronizer.h
+
+sputdev {
+ SRCS += messagemodel.cpp
+ HDRS += messagemodel.h
+}
+
#include "messagemodel.h"
+#include "message.h"
+
MessageModel::MessageModel(QObject *parent) : QAbstractItemModel(parent) {
bool MessageModel::setData(const QModelIndex &index, const QVariant &value, int role) {
int row = index.row();
if(row < 0 || row >= _messageList.count()) return false;
- if(_messageList[row]->setData(index.column(), role)) {
+ if(_messageList[row]->setData(index.column(), value, role)) {
emit dataChanged(index, index); // FIXME make msg emit this (too)
return true;
}
void MessageModel::insertMessage(const Message &msg) {
MsgId id = msg.msgId();
+ int idx = indexForId(id); qDebug() << "inserting at" << idx << msg.text();
MessageItem *item = createMessageItem(msg);
- if(id > )
-
+ beginInsertRows(QModelIndex(), idx, idx);
+ _messageList.insert(idx, item);
+ endInsertRows();
+}
+
+void MessageModel::insertMessages(const QList<Message> &msglist) {
+ if(msglist.isEmpty()) return;
+ // FIXME make this more efficient by grouping msgs
+ foreach(Message msg, msglist) insertMessage(msg);
+
}
// returns index of msg with given Id or of the next message after that (i.e., the index where we'd insert this msg)
int MessageModel::indexForId(MsgId id) {
- if(!_messageList.count() || id <= _messageList[0]->data(0, MsgIdRole).value<MsgId>()) return 0;
+ if(_messageList.isEmpty() || id <= _messageList[0]->data(0, MsgIdRole).value<MsgId>()) return 0;
if(id > _messageList.last()->data(0, MsgIdRole).value<MsgId>()) return _messageList.count();
// binary search
int start = 0; int end = _messageList.count()-1;
- int idx;
while(1) {
- if(start == end) return start;
- idx = (end + start) / 2;
-
+ if(end - start == 1) return end;
+ int pivot = (end + start) / 2;
+ if(id <= _messageList[pivot]->data(0, MsgIdRole).value<MsgId>()) end = pivot;
+ else start = pivot;
+ }
}
/**********************************************************************************/
#include <QAbstractItemModel>
+class Message;
class MessageItem;
+class MsgId;
class MessageModel : public QAbstractItemModel {
Q_OBJECT
MessageModel(QObject *parent);
virtual ~MessageModel();
- inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const { return createIndex(row, column); }
- inline QModelIndex parent(const QModelIndex &index) const { return QModelIndex(); }
- inline int rowCount(const QModelIndex &parent = QModelIndex()) const { return _messageList.count(); }
- inline int columnCount(const QModelIndex &parent = QModelIndex()) const { return 3; }
+ inline QModelIndex index(int row, int column, const QModelIndex &/*parent*/ = QModelIndex()) const { return createIndex(row, column); }
+ inline QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
+ inline int rowCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return _messageList.count(); }
+ inline int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return 3; }
virtual QVariant data(const QModelIndex &index, int role) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
private:
QList<MessageItem *> _messageList;
+ int indexForId(MsgId);
+
};
class MessageItem {
#include <QObject>
#include "message.h"
+class MessageModel;
+
class AbstractUiMsg {
public:
public:
virtual void init() {}; // called after the client is initialized
+ virtual MessageModel *createMessageModel(QObject *parent = 0) = 0;
virtual AbstractUiMsg *layoutMsg(const Message &) = 0;
protected slots:
inline bool operator==(const SignedId &other) const { return id == other.id; }
inline bool operator!=(const SignedId &other) const { return id != other.id; }
inline bool operator<(const SignedId &other) const { return id < other.id; }
+ inline bool operator<=(const SignedId &other) const { return id <= other.id; }
inline bool operator>(const SignedId &other) const { return id > other.id; }
inline bool operator>=(const SignedId &other) const { return id >= other.id; }
inline bool operator==(int i) const { return id == i; }
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel IRC Team *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "chatlinemodel.h"
+
+ChatlineModel::ChatlineModel(QObject *parent) : MessageModel(parent) {
+
+
+}
+
+ChatlineModel::~ChatlineModel() {
+
+}
+
+
+MessageItem *ChatlineModel::createMessageItem(const Message &msg) {
+ return 0;
+
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel IRC Team *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef CHATLINEMODEL_H_
+#define CHATLINEMODEL_H_
+
+#include "messagemodel.h"
+
+class ChatlineModel : public MessageModel {
+ Q_OBJECT
+
+ public:
+ ChatlineModel(QObject *parent = 0);
+ virtual ~ChatlineModel();
+
+ protected:
+ virtual MessageItem *createMessageItem(const Message &);
+
+};
+
+#endif
+
}
void MainWin::setupChatMonitor() {
+#ifndef SPUTDEV
VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this);
dock->setObjectName("ChatMonitorDock");
addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical);
ui.menuViews->addAction(dock->toggleViewAction());
+#endif /* SPUTDEV */
}
void MainWin::setupInputWidget() {
#include "qtui.h"
+#ifdef SPUTDEV
+# include "chatlinemodel.h"
+#endif
#include "mainwin.h"
QtUiStyle *QtUi::_style;
return _style;
}
+MessageModel *QtUi::createMessageModel(QObject *parent) {
+#ifndef SPUTDEV
+ Q_UNUSED(parent)
+ return 0;
+#else
+ return new ChatlineModel(parent);
+#endif
+}
+
AbstractUiMsg *QtUi::layoutMsg(const Message &msg) {
return mainWin->layoutMsg(msg);
}
#include "quasselui.h"
class MainWin;
+class MessageModel;
//! This class encapsulates Quassel's Qt-based GUI.
/** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
QtUi();
~QtUi();
//void init();
+ MessageModel *createMessageModel(QObject *parent = 0);
AbstractUiMsg *layoutMsg(const Message &);
static QtUiStyle *style();
DEPMOD = client common uisupport
QT_MOD = core gui network
-SRCS += aboutdlg.cpp bufferwidget.cpp chatitem.cpp chatline.cpp chatline-old.cpp chatscene.cpp chatview.cpp chatwidget.cpp \
+SRCS += aboutdlg.cpp bufferwidget.cpp chatline-old.cpp chatwidget.cpp \
coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \
mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \
titlesetter.cpp topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
-HDRS += aboutdlg.h bufferwidget.h chatitem.h chatline.h chatline-old.h chatscene.h chatview.h chatwidget.h \
+HDRS += aboutdlg.h bufferwidget.h chatline-old.h chatwidget.h \
coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \
coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \
titlesetter.h topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
+# new chatline model stuff
+sputdev {
+ SRCS += chatitem.cpp chatline.cpp chatlinemodel.cpp chatscene.cpp chatview.cpp
+ HDRS += chatitem.h chatline.h chatlinemodel.h chatscene.h chatview.h
+ SRCS -= chatline-old.cpp chatwidget.cpp
+ HDRS -= chatline-old.h chatwidget.h
+}
+
FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \
settingspagedlg.ui topicwidget.ui debugconsole.ui inputwidget.ui \
coreconfigwizardintropage.ui coreconfigwizardadminuserpage.ui coreconfigwizardstorageselectionpage.ui coreconfigwizardsyncpage.ui