1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

revert(chatlog): "prohibition to remove messages in group chat"

This reverts commit 5aeac56b76.
This commit is contained in:
Anthony Bilinski 2020-04-04 22:54:17 -07:00
parent 3ac6b578df
commit bd0ef5de82
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
8 changed files with 8 additions and 22 deletions

View File

@ -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);
@ -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);
}
@ -445,7 +445,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);
}
@ -815,6 +815,7 @@ void ChatLog::checkVisibility(bool causedWheelEvent)
}
if (causedWheelEvent) {
qDebug() << "causedWheelEvent";
if (lowerBound != lines.cend() && lowerBound->get()->row == 0) {
emit loadHistoryLower();
} else if (upperBound == lines.cend()) {

View File

@ -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);
@ -188,7 +188,6 @@ private:
int numRemove{0};
const int maxMessages{300};
bool canRemove;
};
#endif // CHATLOG_H

View File

@ -37,8 +37,6 @@ public:
virtual void setEventFlag(bool flag) = 0;
virtual bool getEventFlag() const = 0;
virtual bool useHistory() const = 0; // TODO: remove after added history in group chat
signals:
void displayedNameChanged(const QString& newName);
};

View File

@ -168,8 +168,3 @@ Status::Status Friend::getStatus() const
{
return friendStatus;
}
bool Friend::useHistory() const
{
return true;
}

View File

@ -53,7 +53,6 @@ public:
void setStatus(Status::Status s);
Status::Status getStatus() const;
bool useHistory() const override final;
signals:
void nameChanged(const ToxPk& friendId, const QString& name);

View File

@ -205,11 +205,6 @@ QString Group::getSelfName() const
return selfName;
}
bool Group::useHistory() const
{
return false;
}
void Group::stopAudioOfDepartedPeers(const ToxPk& peerPk)
{
if (avGroupchat) {

View File

@ -61,8 +61,6 @@ public:
void setSelfName(const QString& name);
QString getSelfName() const;
bool useHistory() const override final;
signals:
void titleChangedByUser(const QString& title);
void titleChanged(const QString& author, const QString& title);

View File

@ -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);
@ -698,6 +698,7 @@ void GenericChatForm::loadHistoryFrom(const QDateTime &time)
int add = DEF_NUM_MSG_TO_LOAD;
if (begin.get() + DEF_NUM_MSG_TO_LOAD > chatLog.getNextIdx().get()) {
auto aTest = chatLog.getNextIdx().get();
add = chatLog.getNextIdx().get() - begin.get();
}
auto end = ChatLogIdx(begin.get() + add);