mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat: prohibition to remove messages in group chat
This commit is contained in:
parent
0a9e72020e
commit
5aeac56b76
|
@ -49,8 +49,8 @@ T clamp(T x, T min, T max)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatLog::ChatLog(QWidget* parent)
|
ChatLog::ChatLog(const bool canRemove, QWidget* parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent), canRemove(canRemove)
|
||||||
{
|
{
|
||||||
// Create the scene
|
// Create the scene
|
||||||
busyScene = new QGraphicsScene(this);
|
busyScene = new QGraphicsScene(this);
|
||||||
|
@ -391,7 +391,7 @@ void ChatLog::insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines)
|
||||||
if (newLines.isEmpty())
|
if (newLines.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
|
if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
|
||||||
removeFirsts(DEF_NUM_MSG_TO_LOAD);
|
removeFirsts(DEF_NUM_MSG_TO_LOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ void ChatLog::insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines)
|
||||||
combLines.push_back(l);
|
combLines.push_back(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
|
if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
|
||||||
removeLasts(DEF_NUM_MSG_TO_LOAD);
|
removeLasts(DEF_NUM_MSG_TO_LOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,7 +804,6 @@ void ChatLog::checkVisibility(bool causedWheelEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (causedWheelEvent) {
|
if (causedWheelEvent) {
|
||||||
qDebug() << "causedWheelEvent";
|
|
||||||
if (lowerBound != lines.cend() && lowerBound->get()->row == 0) {
|
if (lowerBound != lines.cend() && lowerBound->get()->row == 0) {
|
||||||
emit loadHistoryLower();
|
emit loadHistoryLower();
|
||||||
} else if (upperBound == lines.cend()) {
|
} else if (upperBound == lines.cend()) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ChatLog : public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ChatLog(QWidget* parent = nullptr);
|
explicit ChatLog(const bool canRemove, QWidget* parent = nullptr);
|
||||||
virtual ~ChatLog();
|
virtual ~ChatLog();
|
||||||
|
|
||||||
void insertChatlineAtBottom(ChatLine::Ptr l);
|
void insertChatlineAtBottom(ChatLine::Ptr l);
|
||||||
|
@ -182,6 +182,7 @@ private:
|
||||||
|
|
||||||
int numRemove{0};
|
int numRemove{0};
|
||||||
const int maxMessages{300};
|
const int maxMessages{300};
|
||||||
|
bool canRemove;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHATLOG_H
|
#endif // CHATLOG_H
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
virtual void setEventFlag(bool flag) = 0;
|
virtual void setEventFlag(bool flag) = 0;
|
||||||
virtual bool getEventFlag() const = 0;
|
virtual bool getEventFlag() const = 0;
|
||||||
|
|
||||||
|
virtual bool useHistory() const = 0; // TODO: remove after added history in group chat
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayedNameChanged(const QString& newName);
|
void displayedNameChanged(const QString& newName);
|
||||||
};
|
};
|
||||||
|
|
|
@ -166,3 +166,8 @@ bool Friend::isOnline() const
|
||||||
{
|
{
|
||||||
return friendStatus != Status::Status::Offline && friendStatus != Status::Status::Blocked;
|
return friendStatus != Status::Status::Offline && friendStatus != Status::Status::Blocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Friend::useHistory() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ public:
|
||||||
Status::Status getStatus() const;
|
Status::Status getStatus() const;
|
||||||
bool isOnline() const;
|
bool isOnline() const;
|
||||||
|
|
||||||
|
bool useHistory() const override final;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged(const ToxPk& friendId, const QString& name);
|
void nameChanged(const ToxPk& friendId, const QString& name);
|
||||||
void aliasChanged(const ToxPk& friendId, QString alias);
|
void aliasChanged(const ToxPk& friendId, QString alias);
|
||||||
|
|
|
@ -205,6 +205,11 @@ QString Group::getSelfName() const
|
||||||
return selfName;
|
return selfName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Group::useHistory() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Group::stopAudioOfDepartedPeers(const ToxPk& peerPk)
|
void Group::stopAudioOfDepartedPeers(const ToxPk& peerPk)
|
||||||
{
|
{
|
||||||
if (avGroupchat) {
|
if (avGroupchat) {
|
||||||
|
|
|
@ -61,6 +61,8 @@ public:
|
||||||
void setSelfName(const QString& name);
|
void setSelfName(const QString& name);
|
||||||
QString getSelfName() const;
|
QString getSelfName() const;
|
||||||
|
|
||||||
|
bool useHistory() const override final;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void titleChangedByUser(const QString& title);
|
void titleChangedByUser(const QString& title);
|
||||||
void titleChanged(const QString& author, const QString& title);
|
void titleChanged(const QString& author, const QString& title);
|
||||||
|
|
|
@ -261,7 +261,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(this);
|
chatWidget = new ChatLog(contact->useHistory(), this);
|
||||||
chatWidget->setBusyNotification(ChatMessage::createBusyNotification());
|
chatWidget->setBusyNotification(ChatMessage::createBusyNotification());
|
||||||
searchForm->hide();
|
searchForm->hide();
|
||||||
dateInfo->setAlignment(Qt::AlignHCenter);
|
dateInfo->setAlignment(Qt::AlignHCenter);
|
||||||
|
@ -703,7 +703,6 @@ void GenericChatForm::loadHistoryFrom(const QDateTime &time)
|
||||||
|
|
||||||
int add = DEF_NUM_MSG_TO_LOAD;
|
int add = DEF_NUM_MSG_TO_LOAD;
|
||||||
if (begin.get() + DEF_NUM_MSG_TO_LOAD > chatLog.getNextIdx().get()) {
|
if (begin.get() + DEF_NUM_MSG_TO_LOAD > chatLog.getNextIdx().get()) {
|
||||||
auto aTest = chatLog.getNextIdx().get();
|
|
||||||
add = chatLog.getNextIdx().get() - begin.get();
|
add = chatLog.getNextIdx().get() - begin.get();
|
||||||
}
|
}
|
||||||
auto end = ChatLogIdx(begin.get() + add);
|
auto end = ChatLogIdx(begin.get() + add);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user