if(msglist.isEmpty())
return;
- int processedMsgs = insertMessagesGracefully(msglist);
- int remainingMsgs = msglist.count() - processedMsgs;
- if(remainingMsgs > 0) {
- if(msglist.first().msgId() < msglist.last().msgId()) {
- // in Order - we have just successfully processed "processedMsg" messages from the end of the list
- _messageBuffer << msglist.mid(0, remainingMsgs);
- } else {
- _messageBuffer << msglist.mid(processedMsgs);
+ if(_messageBuffer.isEmpty()) {
+ int processedMsgs = insertMessagesGracefully(msglist);
+ int remainingMsgs = msglist.count() - processedMsgs;
+ if(remainingMsgs > 0) {
+ if(msglist.first().msgId() < msglist.last().msgId()) {
+ // in Order - we have just successfully processed "processedMsg" messages from the end of the list
+ _messageBuffer = msglist.mid(0, remainingMsgs);
+ } else {
+ _messageBuffer = msglist.mid(processedMsgs);
+ }
+ qSort(_messageBuffer);
+ QCoreApplication::postEvent(this, new ProcessBufferEvent());
}
+ } else {
+ _messageBuffer << msglist;
qSort(_messageBuffer);
- QCoreApplication::postEvent(this, new ProcessBufferEvent());
}
}
void MessageModel::insertMessageGroup(const QList<Message> &msglist) {
Q_ASSERT(!msglist.isEmpty()); // the msglist can be assumed to be non empty
+// int last = msglist.count() - 1;
+// Q_ASSERT(0 == last || msglist.at(0).msgId() != msglist.at(last).msgId() || msglist.at(last).type() == Message::DayChange);
int start = indexForId(msglist.first().msgId());
int end = start + msglist.count() - 1;
MessageModelItem *dayChangeItem = 0;
pos++; // needed for the following assert
}
endInsertRows();
+
+// Q_ASSERT(start == end || _messageList.at(start)->msgId() != _messageList.at(end)->msgId() || _messageList.at(end)->msgType() == Message::DayChange);
Q_ASSERT(start == 0 || _messageList[start - 1]->msgId() < _messageList[start]->msgId());
Q_ASSERT(end + 1 == _messageList.count() || _messageList[end]->msgId() < _messageList[end + 1]->msgId());
Q_ASSERT(pos - 1 == end);
// depending on the order we have to traverse from the front to the back or vice versa
QList<Message> grouplist;
- MsgId id;
+ MsgId minId;
MsgId dupeId;
int processedMsgs = 1; // we know the list isn't empty, so we at least process one message
int idx;
}
idx = indexForId((*iter).msgId());
- if(idx >= 0 && !_messageList.isEmpty())
+ if(idx < _messageList.count())
dupeId = _messageList[idx]->msgId();
// we always compare to the previous entry...
// if there isn't, we can fastforward to the top
if(idx - 1 >= 0)
- id = _messageList[idx - 1]->msgId();
+ minId = _messageList[idx - 1]->msgId();
else
fastForward = true;
- if((*iter).msgId() != dupeId)
+ if((*iter).msgId() != dupeId) {
grouplist << *iter;
+ dupeId = (*iter).msgId();
+ }
if(!inOrder)
iter++;
while(iter != msglist.constBegin()) {
iter--;
- if(!fastForward && (*iter).msgId() < id)
+ if(!fastForward && (*iter).msgId() < minId)
break;
processedMsgs++;
}
} else {
while(iter != msglist.constEnd()) {
- if(!fastForward && (*iter).msgId() < id)
+ if(!fastForward && (*iter).msgId() < minId)
break;
processedMsgs++;
QList<Message>::iterator removeStart = _messageBuffer.begin() + remainingMsgs;
QList<Message>::iterator removeEnd = _messageBuffer.end();
_messageBuffer.erase(removeStart, removeEnd);
-
if(!_messageBuffer.isEmpty())
QCoreApplication::postEvent(this, new ProcessBufferEvent());
}
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 rowCount(const QModelIndex &parent = QModelIndex()) const { return parent.isValid() ? 0 : _messageList.count(); }
inline int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return 3; }
virtual QVariant data(const QModelIndex &index, int role) const;
coreinfodlg.cpp
debugconsole.cpp
debuglogwidget.cpp
+ debugmessagemodelfilter.cpp
inputwidget.cpp
jumpkeyhandler.cpp
mainwin.cpp
coreinfodlg.h
debugconsole.h
debuglogwidget.h
+ debugmessagemodelfilter.h
inputwidget.h
jumpkeyhandler.h
mainwin.h
void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) {
Q_UNUSED(index);
-// QModelIndex sidx = model()->index(start, 0);
-// QModelIndex eidx = model()->index(end, 0);
-// qDebug() << "rowsInserted" << start << end << "-" << sidx.data(MessageModel::MsgIdRole).value<MsgId>() << eidx.data(MessageModel::MsgIdRole).value<MsgId>();
+
+
+// QModelIndex sidx = model()->index(start, 2);
+// QModelIndex eidx = model()->index(end, 2);
+// qDebug() << "rowsInserted:";
+// if(start > 0) {
+// QModelIndex ssidx = model()->index(start - 1, 2);
+// qDebug() << "Start--:" << start - 1 << ssidx.data(MessageModel::MsgIdRole).value<MsgId>()
+// << ssidx.data(Qt::DisplayRole).toString();
+// }
+// qDebug() << "Start:" << start << sidx.data(MessageModel::MsgIdRole).value<MsgId>()
+// << sidx.data(Qt::DisplayRole).toString();
+// qDebug() << "End:" << end << eidx.data(MessageModel::MsgIdRole).value<MsgId>()
+// << eidx.data(Qt::DisplayRole).toString();
+// if(end + 1 < model()->rowCount()) {
+// QModelIndex eeidx = model()->index(end + 1, 2);
+// qDebug() << "End++:" << end + 1 << eeidx.data(MessageModel::MsgIdRole).value<MsgId>()
+// << eeidx.data(Qt::DisplayRole).toString();
+// }
qreal h = 0;
qreal y = 0;
#include "coreinfodlg.h"
#include "coreconnectdlg.h"
#include "debuglogwidget.h"
+#include "debugmessagemodelfilter.h"
#include "iconloader.h"
#include "inputwidget.h"
#include "inputline.h"
qApp, SLOT(aboutQt())));
coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll,
this, SLOT(on_actionDebugNetworkModel_triggered())));
+ coll->addAction("DebugMessageModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &MessageModel"), coll,
+ this, SLOT(on_actionDebugMessageModel_triggered())));
coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll,
this, SLOT(on_actionDebugLog_triggered())));
}
_helpMenu->addSeparator();
_helpDebugMenu = _helpMenu->addMenu(SmallIcon("tools-report-bug"), tr("Debug"));
_helpDebugMenu->addAction(coll->action("DebugNetworkModel"));
+ _helpDebugMenu->addAction(coll->action("DebugMessageModel"));
_helpDebugMenu->addAction(coll->action("DebugLog"));
}
view->show();
}
+void MainWin::on_actionDebugMessageModel_triggered() {
+ QTableView *view = new QTableView(0);
+ DebugMessageModelFilter *filter = new DebugMessageModelFilter(view);
+ filter->setSourceModel(Client::messageModel());
+ view->setModel(filter);
+ view->setAttribute(Qt::WA_DeleteOnClose, true);
+ view->verticalHeader()->hide();
+ view->horizontalHeader()->setStretchLastSection(true);
+ view->show();
+}
+
void MainWin::on_actionDebugLog_triggered() {
DebugLogWidget *logWidget = new DebugLogWidget(0);
logWidget->show();
void on_actionManageViews_triggered();
void on_actionLockDockPositions_toggled(bool lock);
void on_actionDebugNetworkModel_triggered();
+ void on_actionDebugMessageModel_triggered();
void on_actionDebugLog_triggered();
void clientNetworkCreated(NetworkId);