Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(chatlog): enable dynamic view range in chatlog with history disabled
Browse files Browse the repository at this point in the history
Message caching is handled by SessionChatLog in memory even when history is
disabled. ChatLog doesn't need to worry about how the messages its rendering
are being stored. Dynamic loading up and down in chatlog is sitll functional.
  • Loading branch information
anthonybilinski committed Mar 22, 2020
1 parent c906cdf commit a7f3495
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/chatlog/chatlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ T clamp(T x, T min, T max)
return x;
}

ChatLog::ChatLog(const bool canRemove, QWidget* parent)
: QGraphicsView(parent), canRemove(canRemove)
ChatLog::ChatLog(QWidget* parent)
: QGraphicsView(parent)
{
// Create the scene
busyScene = new QGraphicsScene(this);
Expand Down Expand Up @@ -394,7 +394,7 @@ void ChatLog::insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines)
if (newLines.isEmpty())
return;

if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
if (lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
removeFirsts(DEF_NUM_MSG_TO_LOAD);
}

Expand Down Expand Up @@ -444,7 +444,7 @@ void ChatLog::insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines)
combLines.push_back(l);
}

if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
if (lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
removeLasts(DEF_NUM_MSG_TO_LOAD);
}

Expand Down
3 changes: 1 addition & 2 deletions src/chatlog/chatlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ChatLog : public QGraphicsView
{
Q_OBJECT
public:
explicit ChatLog(const bool canRemove, QWidget* parent = nullptr);
explicit ChatLog(QWidget* parent = nullptr);
virtual ~ChatLog();

void insertChatlineAtBottom(ChatLine::Ptr l);
Expand Down Expand Up @@ -188,7 +188,6 @@ private slots:

int numRemove{0};
const int maxMessages{300};
bool canRemove;
};

#endif // CHATLOG_H
2 changes: 1 addition & 1 deletion src/widget/form/genericchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ GenericChatForm::GenericChatForm(const Contact* contact, IChatLog& chatLog,
headWidget = new ChatFormHeader();
searchForm = new SearchForm();
dateInfo = new QLabel(this);
chatWidget = new ChatLog(contact->useHistory(), this);
chatWidget = new ChatLog(this);
chatWidget->setBusyNotification(ChatMessage::createBusyNotification());
searchForm->hide();
dateInfo->setAlignment(Qt::AlignHCenter);
Expand Down

0 comments on commit a7f3495

Please sign in to comment.