action->userID = userID;
action->points.append(start);
action->points.append(end);
+ Q_ASSERT(action->points.size() >= 2);
emit actionHappened(action);
//qDebug() << "shareboard.cpp: segment drawn from" << start << "to" << end;
}
localHistory.removeFirst();
}
history.append(action);
- if(viewIndex+1 == history.size()) {
+ jumpToIndex(history.size());
+/* if(viewIndex+1 == history.size()) {
jumpToIndex(viewIndex+1);
- } else {
+ } else { */
qDebug() << "viewIndex = "<< viewIndex;
qDebug() << "history.size = "<< history.size();
- }
+ //}
}
void Shareboard::postLocalAction(Action* action) {
void Shareboard::setUserID(int id) {
userID = id;
+ jumpToIndex(history.size());
}
void Shareboard::jumpToIndex(int index) {
p.begin(&viewImage);
while(i < history.size() && i < index) {
viewTime = history[i]->timestamp;
+ viewIndex = i;
Action* action = history[i];
// Apply action to pixmap
switch(action->type) {
pen.setWidth(a->width);
p.setPen(pen);
qDebug() << "Painting line\tcolor: " << a->color << "\twidth:" << a->width;
- p.drawPolyline(a->points.data(), a->points.size());
+ p.drawPolyline(a->points.data(), a->points.size()-1);
+ qDebug() << a->points;
}
break;
case Action::AddImage:
i++;
}
p.end();
+ canvas->update();
}
/*
void Shareboard::jumpToTime(QDateTime time) {
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;
- p.drawEllipse(0,0,100,100);
+ //qDebug() << "ShareboardCanvas:" << board->view().rect();
+ //qDebug() << "ShareboardCanvas:" << board->viewIndex;
// Now paint our local changes on top of it
//p.set