added basic buggy text copying

This commit is contained in:
fourtf
2018-01-16 02:39:31 +01:00
parent a33ac76f99
commit 0ca916717c
6 changed files with 68 additions and 274 deletions
+6 -34
View File
@@ -235,48 +235,20 @@ const MessageLayoutElement *MessageLayout::getElementAt(QPoint point)
return this->container.getElementAt(point);
}
// XXX(pajlada): This is probably not the optimal way to calculate this
int MessageLayout::getLastCharacterIndex() const
{
// fourtf: xD
// // find out in which line the cursor is
// int lineNumber = 0, lineStart = 0, lineEnd = 0;
// for (size_t i = 0; i < this->wordParts.size(); i++) {
// const LayoutItem &part = this->wordParts[i];
// if (part.getLineNumber() != lineNumber) {
// lineStart = i;
// lineNumber = part.getLineNumber();
// }
// lineEnd = i + 1;
// }
// // count up to the cursor
// int index = 0;
// for (int i = 0; i < lineStart; i++) {
// const LayoutItem &part = this->wordParts[i];
// index += part.getWord().isImage() ? 2 : part.getText().length() + 1;
// }
// for (int i = lineStart; i < lineEnd; i++) {
// const LayoutItem &part = this->wordParts[i];
// index += part.getCharacterLength();
// }
// return index;
return 0;
return this->container.getLastCharacterIndex();
}
int MessageLayout::getSelectionIndex(QPoint position)
{
return this->container.getSelectionIndex(position);
}
void MessageLayout::addSelectionText(QString &str, int from, int to)
{
this->container.addSelectionText(str, from, to);
}
} // namespace layouts
} // namespace messages
} // namespace chatterino