Browse Source

fix(chatlog): enable dynamic view range in chatlog with history disabled

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.
reviewable/pr6050/r7
Anthony Bilinski 5 years ago
parent
commit
a7f3495956
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 8
      src/chatlog/chatlog.cpp
  2. 3
      src/chatlog/chatlog.h
  3. 2
      src/widget/form/genericchatform.cpp

8
src/chatlog/chatlog.cpp

@ -52,8 +52,8 @@ T clamp(T x, T min, T max)
return x; return x;
} }
ChatLog::ChatLog(const bool canRemove, QWidget* parent) ChatLog::ChatLog(QWidget* parent)
: QGraphicsView(parent), canRemove(canRemove) : QGraphicsView(parent)
{ {
// Create the scene // Create the scene
busyScene = new QGraphicsScene(this); busyScene = new QGraphicsScene(this);
@ -394,7 +394,7 @@ void ChatLog::insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines)
if (newLines.isEmpty()) if (newLines.isEmpty())
return; 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); removeFirsts(DEF_NUM_MSG_TO_LOAD);
} }
@ -444,7 +444,7 @@ void ChatLog::insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines)
combLines.push_back(l); 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); removeLasts(DEF_NUM_MSG_TO_LOAD);
} }

3
src/chatlog/chatlog.h

@ -41,7 +41,7 @@ class ChatLog : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ChatLog(const bool canRemove, QWidget* parent = nullptr); explicit ChatLog(QWidget* parent = nullptr);
virtual ~ChatLog(); virtual ~ChatLog();
void insertChatlineAtBottom(ChatLine::Ptr l); void insertChatlineAtBottom(ChatLine::Ptr l);
@ -188,7 +188,6 @@ private:
int numRemove{0}; int numRemove{0};
const int maxMessages{300}; const int maxMessages{300};
bool canRemove;
}; };
#endif // CHATLOG_H #endif // CHATLOG_H

2
src/widget/form/genericchatform.cpp

@ -259,7 +259,7 @@ GenericChatForm::GenericChatForm(const Contact* contact, IChatLog& chatLog,
headWidget = new ChatFormHeader(); headWidget = new ChatFormHeader();
searchForm = new SearchForm(); searchForm = new SearchForm();
dateInfo = new QLabel(this); dateInfo = new QLabel(this);
chatWidget = new ChatLog(contact->useHistory(), this); chatWidget = new ChatLog(this);
chatWidget->setBusyNotification(ChatMessage::createBusyNotification()); chatWidget->setBusyNotification(ChatMessage::createBusyNotification());
searchForm->hide(); searchForm->hide();
dateInfo->setAlignment(Qt::AlignHCenter); dateInfo->setAlignment(Qt::AlignHCenter);

Loading…
Cancel
Save