mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-06 20:23:08 +00:00
Keep unsend typed message in memory when changing of chat room
This commit is contained in:
parent
644998fe85
commit
af8b7faaf5
5 changed files with 22 additions and 4 deletions
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
QString ChatProxyModel::gCachedText;
|
||||
|
||||
// Fetch the L last filtered chat entries.
|
||||
class ChatProxyModel::ChatModelFilter : public QSortFilterProxyModel {
|
||||
public:
|
||||
|
|
@ -100,7 +102,6 @@ ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent)
|
|||
); \
|
||||
}
|
||||
|
||||
CREATE_PARENT_MODEL_FUNCTION(compose);
|
||||
CREATE_PARENT_MODEL_FUNCTION(removeAllEntries);
|
||||
|
||||
CREATE_PARENT_MODEL_FUNCTION_WITH_PARAM(sendFileMessage, const QString &);
|
||||
|
|
@ -117,6 +118,13 @@ CREATE_PARENT_MODEL_FUNCTION_WITH_ID(resendMessage);
|
|||
#undef CREATE_PARENT_MODEL_FUNCTION_WITH_PARAM
|
||||
#undef CREATE_PARENT_MODEL_FUNCTION_WITH_ID
|
||||
|
||||
|
||||
void ChatProxyModel::compose (const QString& text) {
|
||||
if (mChatModel)
|
||||
mChatModel->compose();
|
||||
gCachedText = text;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatProxyModel::loadMoreEntries () {
|
||||
|
|
@ -194,6 +202,10 @@ bool ChatProxyModel::getIsRemoteComposing () const {
|
|||
return mChatModel ? mChatModel->getIsRemoteComposing() : false;
|
||||
}
|
||||
|
||||
QString ChatProxyModel::getCachedText() const{
|
||||
return gCachedText;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatProxyModel::reload () {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class ChatProxyModel : public QSortFilterProxyModel {
|
|||
Q_PROPERTY(QString fullPeerAddress READ getFullPeerAddress WRITE setFullPeerAddress NOTIFY fullPeerAddressChanged);
|
||||
Q_PROPERTY(QString fullLocalAddress READ getFullLocalAddress WRITE setFullLocalAddress NOTIFY fullLocalAddressChanged);
|
||||
Q_PROPERTY(bool isRemoteComposing READ getIsRemoteComposing NOTIFY isRemoteComposingChanged);
|
||||
Q_PROPERTY(QString cachedText READ getCachedText);
|
||||
|
||||
public:
|
||||
ChatProxyModel (QObject *parent = Q_NULLPTR);
|
||||
|
|
@ -58,7 +59,7 @@ public:
|
|||
Q_INVOKABLE void openFile (int id);
|
||||
Q_INVOKABLE void openFileDirectory (int id);
|
||||
|
||||
Q_INVOKABLE void compose ();
|
||||
Q_INVOKABLE void compose (const QString& text);
|
||||
|
||||
Q_INVOKABLE void resetMessageCount();
|
||||
|
||||
|
|
@ -90,6 +91,8 @@ private:
|
|||
void setFullLocalAddress (const QString &localAddress);
|
||||
|
||||
bool getIsRemoteComposing () const;
|
||||
|
||||
QString getCachedText() const;
|
||||
|
||||
void reload ();
|
||||
|
||||
|
|
@ -105,6 +108,7 @@ private:
|
|||
QString mLocalAddress;
|
||||
QString mFullPeerAddress;
|
||||
QString mFullLocalAddress;
|
||||
static QString gCachedText;
|
||||
|
||||
std::shared_ptr<ChatModel> mChatModel;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ Item {
|
|||
|
||||
property alias placeholderText: textArea.placeholderText
|
||||
property alias text: textArea.text
|
||||
property alias cursorPosition: textArea.cursorPosition
|
||||
|
||||
property bool dropEnabled: true
|
||||
property string dropDisabledReason
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ function handleMovementStarted () {
|
|||
chat.bindToEnd = false
|
||||
}
|
||||
|
||||
function handleTextChanged () {
|
||||
container.proxyModel.compose()
|
||||
function handleTextChanged (text) {
|
||||
container.proxyModel.compose(text)
|
||||
}
|
||||
|
||||
function sendMessage (text) {
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ Rectangle {
|
|||
onDropped: Logic.handleFilesDropped(files)
|
||||
onTextChanged: Logic.handleTextChanged(text)
|
||||
onValidText: Logic.sendMessage(text)
|
||||
Component.onCompleted: {text = proxyModel.cachedText; cursorPosition=text.length}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue