Implement message editing

The UI still looks ugly, but I have no good idea atm.

fixes #134
This commit is contained in:
Nicolas Werner 2021-02-01 02:22:53 +01:00
parent 00fd4eecec
commit 9b7d33e847
9 changed files with 90 additions and 15 deletions

View file

@ -1529,11 +1529,33 @@ TimelineModel::setEdit(QString newEdit)
if (ev) {
setReply(QString::fromStdString(
mtx::accessors::relations(*ev).reply_to().value_or("")));
// input()->setText(mtx::accessors::body(*ev));
auto msgType = mtx::accessors::msg_type(*ev);
if (msgType == mtx::events::MessageType::Text ||
msgType == mtx::events::MessageType::Notice) {
input()->setText(relatedInfo(newEdit).quoted_body);
} else if (msgType == mtx::events::MessageType::Emote) {
input()->setText("/me " + relatedInfo(newEdit).quoted_body);
} else {
input()->setText("");
}
} else {
input()->setText("");
}
}
}
void
TimelineModel::resetEdit()
{
if (!edit_.isEmpty()) {
edit_ = "";
emit editChanged(edit_);
input()->setText("");
resetReply();
}
}
QString
TimelineModel::roomName() const
{