diff --git a/src/messages/layouts/messagelayoutcontainer.cpp b/src/messages/layouts/messagelayoutcontainer.cpp index e6459a02a..596842d8a 100644 --- a/src/messages/layouts/messagelayoutcontainer.cpp +++ b/src/messages/layouts/messagelayoutcontainer.cpp @@ -134,7 +134,8 @@ void MessageLayoutContainer::breakLine() } this->lineStart = this->elements.size(); - this->currentX = (int)(this->scale * 8); + // this->currentX = (int)(this->scale * 8); + this->currentX = 0; this->currentY += this->lineHeight; this->height = this->currentY + (this->margin.bottom * this->scale); this->lineHeight = 0; @@ -409,19 +410,21 @@ int MessageLayoutContainer::getLastCharacterIndex() const void MessageLayoutContainer::addSelectionText(QString &str, int from, int to) { int index = 0; - bool xd = true; + bool first = true; for (std::unique_ptr &ele : this->elements) { int c = ele->getSelectionIndexCount(); - if (xd) { + qDebug() << c; + + if (first) { if (index + c > from) { - ele->addCopyTextToString(str, index - from, to - from); - xd = false; + ele->addCopyTextToString(str, from - index, to - from); + first = false; } } else { - if (index + c > from) { - ele->addCopyTextToString(str, 0, index - to); + if (index + c > to) { + ele->addCopyTextToString(str, 0, to - index); break; } else { ele->addCopyTextToString(str); diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 74b6b7c37..3deceb9fe 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -279,14 +279,18 @@ QString ChannelView::getSelectedText() return result; } - for (int msg = selection.min.messageIndex; msg <= selection.min.messageIndex; msg++) { + qDebug() << "xd >>>>"; + for (int msg = selection.min.messageIndex; msg <= selection.max.messageIndex; msg++) { MessageLayoutPtr layout = messagesSnapshot[msg]; int from = msg == selection.min.messageIndex ? selection.min.charIndex : 0; int to = msg == selection.max.messageIndex ? selection.max.charIndex - : layout->getLastCharacterIndex(); + : layout->getLastCharacterIndex() + 1; + + qDebug() << "from:" << from << ", to:" << to; layout->addSelectionText(result, from, to); } + qDebug() << "xd <<<<"; return result; }