Browse Source

refactor(chatform): Use IChatLog to get date in GenericChatForm

* Allows for deletion of APIs returning ChatLine::Ptr from ChatLog
* Bonus removal of unused "getFirstTime" function from GenericChatForm
reviewable/pr6294/r2
Mick Sayson 5 years ago committed by Anthony Bilinski
parent
commit
d0f4c336ba
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 21
      src/chatlog/chatlog.cpp
  2. 3
      src/chatlog/chatlog.h
  3. 8
      src/widget/form/genericchatform.cpp
  4. 1
      src/widget/form/genericchatform.h

21
src/chatlog/chatlog.cpp

@ -595,27 +595,6 @@ ChatLine::Ptr ChatLog::getTypingNotification() const @@ -595,27 +595,6 @@ ChatLine::Ptr ChatLog::getTypingNotification() const
return typingNotification;
}
QVector<ChatLine::Ptr> ChatLog::getLines()
{
return lines;
}
ChatLine::Ptr ChatLog::getLatestLine() const
{
if (!lines.empty()) {
return lines.last();
}
return nullptr;
}
ChatLine::Ptr ChatLog::getFirstLine() const
{
if (!lines.empty()) {
return lines.first();
}
return nullptr;
}
/**
* @brief Finds the chat line object at a position on screen
* @param pos Position on screen in global coordinates

3
src/chatlog/chatlog.h

@ -67,9 +67,6 @@ public: @@ -67,9 +67,6 @@ public:
bool hasTextToBeCopied() const;
ChatLine::Ptr getTypingNotification() const;
QVector<ChatLine::Ptr> getLines();
ChatLine::Ptr getLatestLine() const;
ChatLine::Ptr getFirstLine() const;
ChatLineContent* getContentFromGlobalPos(QPoint pos) const;
const uint repNameAfter = 5 * 60;

8
src/widget/form/genericchatform.cpp

@ -402,12 +402,10 @@ void GenericChatForm::hideFileMenu() @@ -402,12 +402,10 @@ void GenericChatForm::hideFileMenu()
QDateTime GenericChatForm::getLatestTime() const
{
return getTime(chatWidget->getLatestLine());
}
if (chatLog.getFirstIdx() == chatLog.getNextIdx())
return QDateTime();
QDateTime GenericChatForm::getFirstTime() const
{
return getTime(chatWidget->getFirstLine());
return chatLog.at(chatLog.getNextIdx() - 1).getTimestamp();
}
void GenericChatForm::reloadTheme()

1
src/widget/form/genericchatform.h

@ -80,7 +80,6 @@ public: @@ -80,7 +80,6 @@ public:
const QDateTime& datetime);
static QString resolveToxPk(const ToxPk& pk);
QDateTime getLatestTime() const;
QDateTime getFirstTime() const;
signals:
void messageInserted();

Loading…
Cancel
Save