board->postAction(act);
- qDebug() << "Dispatched action with type " << act->type << " that was " << data.size() << " bytes long";
+ //qDebug() << "Dispatched action with type " << act->type << " that was " << data.size() << " bytes long";
}
}
localHistory.removeFirst();
}
history.append(action);
- jumpToIndex(history.size());
-/* if(viewIndex+1 == history.size()) {
- jumpToIndex(viewIndex+1);
- } else { */
- qDebug() << "viewIndex = "<< viewIndex;
- qDebug() << "history.size = "<< history.size();
- //}
+ jumpToIndex(history.size()); // Jump to the most recent state
}
void Shareboard::postLocalAction(Action* action) {
viewImage = QImage(1024,768,QImage::Format_ARGB32_Premultiplied);
viewImage.fill(Qt::white);
viewCursors.clear();
+ viewUsers.clear();
} else {
i = viewIndex;
}
QPainter p;
- qDebug() << "\t\tjumpToIndex():" << viewImage.valid(0,0) << viewImage.rect();
p.begin(&viewImage);
while(i < history.size() && i < index) {
viewTime = history[i]->timestamp;
// Apply action to pixmap
switch(action->type) {
case Action::INVALID:
+ break;
case Action::UserJoin:
+ {
+ UserJoinAction* a = static_cast<UserJoinAction*>(action);
+ viewUsers[a->userID] = a->username;
+ qDebug() << "Saw user" << a->username << "join";
+ }
break;
case Action::UserPart:
{
+ qDebug() << "Saw user" << viewUsers[action->userID] << "part";
viewCursors.remove(action->userID);
+ viewUsers.remove(action->userID);
}
break;
case Action::MouseMove:
QPen pen(a->color);
pen.setWidth(a->width);
p.setPen(pen);
- qDebug() << "Painting line\tcolor: " << a->color << "\twidth:" << a->width;
p.drawPolyline(a->points.data(), a->points.size()-1);
- qDebug() << a->points;
}
break;
case Action::AddImage:
QImage viewImage;
int viewIndex; // The index of the first action we haven't applied.
QMap<int, QPointF> viewCursors;
+ QMap<int, QString> viewUsers;
// QPixmap renderAtTime(QDateTime time);
// QPixmap renderOneChange();
#include <QPaintEvent>
#include <QPainter>
#include <QPixmap>
+#include <QPen>
+#include <QColor>
#include <QDebug>
#include "shareboard.h"
QPainter p(this);
// Paint the background from the saved state
p.drawImage(0, 0, board->view());
- //qDebug() << "ShareboardCanvas:" << board->view().rect();
- //qDebug() << "ShareboardCanvas:" << board->viewIndex;
// Now paint our local changes on top of it
//p.set
// Now paint the set of mouse cursors on top of that
+ QMap<int, QPointF>::const_iterator i;
+ for (i = board->viewCursors.constBegin(); i!=board->viewCursors.constEnd(); ++i) {
+ p.setPen(QPen(QColor(255,0,0,50)));
+ p.setBrush(QBrush(QColor(255,0,0,50)));
+ p.drawEllipse(i.value(),4,4);
+ p.setPen(Qt::black);
+ p.setBrush(Qt::black);
+ p.drawText(i.value(),board->viewUsers[i.key()]);
+ }
}