X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Finputwidget.cpp;h=f05311a7737761e5f7a4a0c97d6a1fb7911ed214;hp=4aa759236cf8183094c4db23463fc221d206637e;hb=f84e68f556579cbe861f50b94b19ae83704fc17f;hpb=b4cbf84780b345cb5a206229cc99e786749dd897 diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index 4aa75923..f05311a7 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -110,6 +110,9 @@ InputWidget::InputWidget(QWidget *parent) s.notify("ShowStyleButtons", this, SLOT(setShowStyleButtons(QVariant))); setShowStyleButtons(s.value("ShowStyleButtons", true)); + s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant))); + setEnablePerChatHistory(s.value("EnablePerChatHistory", true)); + s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant))); setMaxLines(s.value("MaxNumLines", 5)); @@ -159,6 +162,10 @@ void InputWidget::setShowStyleButtons(const QVariant &v) { ui.showStyleButton->setVisible(v.toBool()); } +void InputWidget::setEnablePerChatHistory(const QVariant &v) { + _perChatHistory = v.toBool(); +} + void InputWidget::setMaxLines(const QVariant &v) { ui.inputEdit->setMaxHeight(v.toInt()); } @@ -203,7 +210,24 @@ bool InputWidget::eventFilter(QObject *watched, QEvent *event) { } void InputWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { - Q_UNUSED(previous) + BufferId currentBufferId = current.data(NetworkModel::BufferIdRole).value(); + BufferId previousBufferId = previous.data(NetworkModel::BufferIdRole).value(); + + if (_perChatHistory) { + //backup + historyMap[previousBufferId].history = inputLine()->history(); + historyMap[previousBufferId].tempHistory = inputLine()->tempHistory(); + historyMap[previousBufferId].idx = inputLine()->idx(); + historyMap[previousBufferId].inputLine = inputLine()->html(); + + //restore + inputLine()->setHistory(historyMap[currentBufferId].history); + inputLine()->setTempHistory(historyMap[currentBufferId].tempHistory); + inputLine()->setIdx(historyMap[currentBufferId].idx); + inputLine()->setHtml(historyMap[currentBufferId].inputLine); + inputLine()->moveCursor(QTextCursor::End,QTextCursor::MoveAnchor); + } + NetworkId networkId = current.data(NetworkModel::NetworkIdRole).value(); if(networkId == _networkId) return;