Disabled completer in private chat.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6484 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-07-06 15:37:22 +00:00
parent e9db631f8f
commit dc29793da6

View File

@ -70,6 +70,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
isChatLobby = false; isChatLobby = false;
firstShow = true; firstShow = true;
inChatCharFormatChanged = false; inChatCharFormatChanged = false;
completer = NULL;
lastStatusSendTime = 0 ; lastStatusSendTime = 0 ;
@ -128,16 +129,6 @@ ChatWidget::ChatWidget(QWidget *parent) :
#endif #endif
resetStatusBar(); resetStatusBar();
completer = new QCompleter(this);
completer->setModel(modelFromPeers());
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setWrapAround(false);
ui->chatTextEdit->setCompleter(completer);
ui->chatTextEdit->setCompleterKeyModifiers(Qt::ControlModifier);
ui->chatTextEdit->setCompleterKey(Qt::Key_Space);
} }
ChatWidget::~ChatWidget() ChatWidget::~ChatWidget()
@ -197,6 +188,15 @@ void ChatWidget::init(const std::string &peerId, const QString &title)
QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(peerId).c_str()); QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(peerId).c_str());
updatePeersCustomStateString(QString::fromStdString(peerId), customStateString); updatePeersCustomStateString(QString::fromStdString(peerId), customStateString);
} else { } else {
completer = new QCompleter(this);
completer->setModel(modelFromPeers());
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setWrapAround(false);
ui->chatTextEdit->setCompleter(completer);
ui->chatTextEdit->setCompleterKeyModifiers(Qt::ControlModifier);
ui->chatTextEdit->setCompleterKey(Qt::Key_Space);
updateTitle(); updateTitle();
} }
@ -256,6 +256,8 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
completionWord.clear(); completionWord.clear();
} }
} }
if (completer) {
if ((keyEvent->modifiers() & ui->chatTextEdit->getCompleterKeyModifiers()) && keyEvent->key() == ui->chatTextEdit->getCompleterKey()) { if ((keyEvent->modifiers() & ui->chatTextEdit->getCompleterKeyModifiers()) && keyEvent->key() == ui->chatTextEdit->getCompleterKey()) {
completer->setModel(modelFromPeers()); completer->setModel(modelFromPeers());
} }
@ -263,6 +265,8 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
ui->chatTextEdit->forceCompleterShowNextKeyEvent("@"); ui->chatTextEdit->forceCompleterShowNextKeyEvent("@");
completer->setModel(modelFromPeers()); completer->setModel(modelFromPeers());
} }
}
if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) {
// Enter pressed // Enter pressed
if (Settings->getChatSendMessageWithCtrlReturn()) { if (Settings->getChatSendMessageWithCtrlReturn()) {
@ -436,7 +440,6 @@ QAbstractItemModel *ChatWidget::modelFromPeers()
if (!lobby) if (!lobby)
return new QStringListModel(completer); return new QStringListModel(completer);
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
#endif #endif