added limited queue
This commit is contained in:
+12
-10
@@ -47,17 +47,19 @@ ChatWidgetView::layoutMessages()
|
||||
|
||||
bool showScrollbar = false;
|
||||
|
||||
auto messages = c->getMessagesClone();
|
||||
auto messages = c->getMessageSnapshot();
|
||||
|
||||
bool redraw = false;
|
||||
|
||||
for (std::shared_ptr<messages::Message> &message : messages) {
|
||||
redraw |= message.get()->layout(this->width(), true);
|
||||
}
|
||||
// for (std::shared_ptr<messages::Message> &message : messages) {
|
||||
// redraw |= message.get()->layout(this->width(), true);
|
||||
// }
|
||||
|
||||
redraw = true;
|
||||
|
||||
int h = this->height() - 8;
|
||||
|
||||
for (int i = messages.size() - 1; i >= 0; i--) {
|
||||
for (int i = messages.getLength() - 1; i >= 0; i--) {
|
||||
auto *message = messages[i].get();
|
||||
|
||||
message->layout(this->width(), true);
|
||||
@@ -65,7 +67,7 @@ ChatWidgetView::layoutMessages()
|
||||
h -= message->getHeight();
|
||||
|
||||
if (h < 0) {
|
||||
this->scrollbar.setLargeChange((messages.size() - i) +
|
||||
this->scrollbar.setLargeChange((messages.getLength() - i) +
|
||||
(qreal)h / message->getHeight());
|
||||
this->scrollbar.setDesiredValue(this->scrollbar.getDesiredValue());
|
||||
|
||||
@@ -76,7 +78,7 @@ ChatWidgetView::layoutMessages()
|
||||
|
||||
this->scrollbar.setVisible(showScrollbar);
|
||||
|
||||
this->scrollbar.setMaximum(c->getMessages().size());
|
||||
this->scrollbar.setMaximum(messages.getLength());
|
||||
|
||||
return redraw;
|
||||
}
|
||||
@@ -138,18 +140,18 @@ ChatWidgetView::paintEvent(QPaintEvent *)
|
||||
if (c == NULL)
|
||||
return;
|
||||
|
||||
auto messages = c->getMessagesClone();
|
||||
auto messages = c->getMessageSnapshot();
|
||||
|
||||
int start = this->scrollbar.getCurrentValue();
|
||||
|
||||
if (start >= messages.length()) {
|
||||
if (start >= messages.getLength()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int y = -(messages[start].get()->getHeight() *
|
||||
(fmod(this->scrollbar.getCurrentValue(), 1)));
|
||||
|
||||
for (int i = start; i < messages.size(); ++i) {
|
||||
for (int i = start; i < messages.getLength(); ++i) {
|
||||
messages::Message *message = messages[i].get();
|
||||
|
||||
for (messages::WordPart const &wordPart : message->getWordParts()) {
|
||||
|
||||
@@ -133,12 +133,8 @@ Notebook::tabAt(QPoint point, int &index)
|
||||
void
|
||||
Notebook::rearrangePage(NotebookPage *page, int index)
|
||||
{
|
||||
int i1 = pages.indexOf(page);
|
||||
|
||||
pages.move(pages.indexOf(page), index);
|
||||
|
||||
int i2 = pages.indexOf(page);
|
||||
|
||||
performLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,11 @@ ScrollBar::ScrollBar(QWidget *widget)
|
||||
, currentValueChanged()
|
||||
, currentValue()
|
||||
{
|
||||
resize(16, 100);
|
||||
this->resize(16, 100);
|
||||
|
||||
currentValueAnimation.setDuration(300);
|
||||
currentValueAnimation.setEasingCurve(QEasingCurve(QEasingCurve::OutCubic));
|
||||
this->currentValueAnimation.setDuration(300);
|
||||
this->currentValueAnimation.setEasingCurve(
|
||||
QEasingCurve(QEasingCurve::OutCubic));
|
||||
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
@@ -211,7 +212,7 @@ ScrollBar::updateScroll()
|
||||
|
||||
this->thumbRect =
|
||||
QRect(0,
|
||||
(int)(this->desiredValue / this->maximum * this->trackHeight) +
|
||||
(int)(this->currentValue / this->maximum * this->trackHeight) +
|
||||
1 + this->buttonHeight,
|
||||
width(),
|
||||
(int)(this->largeChange / this->maximum * this->trackHeight) +
|
||||
|
||||
+2
-2
@@ -63,8 +63,6 @@ public:
|
||||
value = std::max(this->minimum,
|
||||
std::min(this->maximum - this->largeChange, value));
|
||||
|
||||
this->desiredValue = value;
|
||||
|
||||
if (this->desiredValue != value) {
|
||||
if (animated) {
|
||||
this->currentValueAnimation.stop();
|
||||
@@ -78,6 +76,8 @@ public:
|
||||
this->setCurrentValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
this->desiredValue = value;
|
||||
}
|
||||
|
||||
qreal
|
||||
|
||||
Reference in New Issue
Block a user