qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
Public Slots | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
ChatHistory Class Reference

#include <chathistory.h>

Inheritance diagram for ChatHistory:
Inheritance graph
Collaboration diagram for ChatHistory:
Collaboration graph

Public Slots

void onFileUpdated (const ToxPk &sender, const ToxFile &file)
 
void onFileTransferRemotePausedUnpaused (const ToxPk &sender, const ToxFile &file, bool paused)
 
void onFileTransferBrokenUnbroken (const ToxPk &sender, const ToxFile &file, bool broken)
 

Public Member Functions

 ChatHistory (Friend &f_, History *history_, const ICoreIdHandler &coreIdHandler, const Settings &settings, IMessageDispatcher &messageDispatcher)
 
const ChatLogItemat (ChatLogIdx idx) const override
 Returns reference to item at idx. More...
 
SearchResult searchForward (SearchPos startIdx, const QString &phrase, const ParameterSearch &parameter) const override
 searches forwards through the chat log until phrase is found according to parameter More...
 
SearchResult searchBackward (SearchPos startIdx, const QString &phrase, const ParameterSearch &parameter) const override
 searches backwards through the chat log until phrase is found according to parameter More...
 
ChatLogIdx getFirstIdx () const override
 The underlying chat log instance may not want to start at 0. More...
 
ChatLogIdx getNextIdx () const override
 
std::vector< DateChatLogIdxPairgetDateIdxs (const QDate &startDate, size_t maxDates) const override
 Gets indexes for each new date starting at startDate. More...
 
void addSystemMessage (const SystemMessage &message) override
 Inserts a system message at the end of the chat. More...
 
- Public Member Functions inherited from IChatLog
virtual ~IChatLog ()=default
 

Private Slots

void onMessageReceived (const ToxPk &sender, const Message &message)
 
void onMessageSent (DispatchedMessageId id, const Message &message)
 
void onMessageComplete (DispatchedMessageId id)
 
void onMessageBroken (DispatchedMessageId id, BrokenMessageReason reason)
 

Private Member Functions

void ensureIdxInSessionChatLog (ChatLogIdx idx) const
 Forces the given index and all future indexes to be in the chatlog. More...
 
void loadHistoryIntoSessionChatLog (ChatLogIdx start) const
 Unconditionally loads the given index and all future messages that are not in the session chat log into the session chat log. More...
 
void dispatchUnsentMessages (IMessageDispatcher &messageDispatcher)
 Sends any unsent messages in history to the underlying message dispatcher. More...
 
void handleDispatchedMessage (DispatchedMessageId dispatchId, RowId historyId)
 
void completeMessage (DispatchedMessageId id)
 
void breakMessage (DispatchedMessageId id, BrokenMessageReason reason)
 
bool canUseHistory () const
 
ChatLogIdx getInitialChatLogIdx () const
 Gets the initial chat log index for a sessionChatLog with 0 items loaded from history. Needed to keep history indexes in sync with chat log indexes. More...
 

Private Attributes

Friendf
 
Historyhistory
 
const Settingssettings
 
const ICoreIdHandlercoreIdHandler
 
SessionChatLog sessionChatLog
 
QSet< DispatchedMessageIdcompletedMessages
 
QMap< DispatchedMessageId, BrokenMessageReasonbrokenMessages
 
QMap< DispatchedMessageId, RowIddispatchedMessageRowIdMap
 

Additional Inherited Members

- Signals inherited from IChatLog
void itemUpdated (ChatLogIdx idx)
 

Detailed Description

Definition at line 31 of file chathistory.h.

Constructor & Destructor Documentation

◆ ChatHistory()

ChatHistory::ChatHistory ( Friend f_,
History history_,
const ICoreIdHandler coreIdHandler,
const Settings settings,
IMessageDispatcher messageDispatcher 
)

Definition at line 73 of file chathistory.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addSystemMessage()

void ChatHistory::addSystemMessage ( const SystemMessage message)
overridevirtual

Inserts a system message at the end of the chat.

Parameters
[in]messagesystemMessage to insert

Implements IChatLog.

Definition at line 209 of file chathistory.cpp.

Here is the call graph for this function:

◆ at()

const ChatLogItem & ChatHistory::at ( ChatLogIdx  idx) const
overridevirtual

Returns reference to item at idx.

Parameters
[in]idx
Returns
Variant type referencing either a ToxFile or Message
Precondition
idx must be between currentFirstIdx() and currentLastIdx()

Implements IChatLog.

Definition at line 113 of file chathistory.cpp.

Here is the call graph for this function:

◆ breakMessage()

void ChatHistory::breakMessage ( DispatchedMessageId  id,
BrokenMessageReason  reason 
)
private

Definition at line 497 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ canUseHistory()

bool ChatHistory::canUseHistory ( ) const
private

Definition at line 509 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ completeMessage()

void ChatHistory::completeMessage ( DispatchedMessageId  id)
private

Definition at line 485 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dispatchUnsentMessages()

void ChatHistory::dispatchUnsentMessages ( IMessageDispatcher messageDispatcher)
private

Sends any unsent messages in history to the underlying message dispatcher.

Parameters
[in]messageDispatcher

Definition at line 426 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureIdxInSessionChatLog()

void ChatHistory::ensureIdxInSessionChatLog ( ChatLogIdx  idx) const
private

Forces the given index and all future indexes to be in the chatlog.

Parameters
[in]idx
Note
Marked const since this doesn't change external state of the class. We still have all the same items at all the same indexes, we've just stuckem in ram

Definition at line 328 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDateIdxs()

std::vector< IChatLog::DateChatLogIdxPair > ChatHistory::getDateIdxs ( const QDate &  startDate,
size_t  maxDates 
) const
overridevirtual

Gets indexes for each new date starting at startDate.

Parameters
[in]startDatedate to start searching from
[in]maxDatesmaximum number of dates to be returned

Implements IChatLog.

Definition at line 186 of file chathistory.cpp.

Here is the call graph for this function:

◆ getFirstIdx()

ChatLogIdx ChatHistory::getFirstIdx ( ) const
overridevirtual

The underlying chat log instance may not want to start at 0.

Returns
Current first valid index to call at() with

Implements IChatLog.

Definition at line 172 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInitialChatLogIdx()

ChatLogIdx ChatHistory::getInitialChatLogIdx ( ) const
private

Gets the initial chat log index for a sessionChatLog with 0 items loaded from history. Needed to keep history indexes in sync with chat log indexes.

Parameters
[in]history
[in]f
Returns
Initial chat log index

Definition at line 521 of file chathistory.cpp.

Here is the call graph for this function:

◆ getNextIdx()

ChatLogIdx ChatHistory::getNextIdx ( ) const
overridevirtual
Returns
current last valid index to call at() with

Implements IChatLog.

Definition at line 181 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleDispatchedMessage()

void ChatHistory::handleDispatchedMessage ( DispatchedMessageId  dispatchId,
RowId  historyId 
)
private

Definition at line 465 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadHistoryIntoSessionChatLog()

void ChatHistory::loadHistoryIntoSessionChatLog ( ChatLogIdx  start) const
private

Unconditionally loads the given index and all future messages that are not in the session chat log into the session chat log.

Parameters
[in]idx
Note
Marked const since this doesn't change external state of the class. We still have all the same items at all the same indexes, we've just stuckem in ram
no end idx as we always load from start -> latest. In the future we could have a less contiguous history

Definition at line 344 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onFileTransferBrokenUnbroken

void ChatHistory::onFileTransferBrokenUnbroken ( const ToxPk sender,
const ToxFile file,
bool  broken 
)
slot

Definition at line 260 of file chathistory.cpp.

Here is the call graph for this function:

◆ onFileTransferRemotePausedUnpaused

void ChatHistory::onFileTransferRemotePausedUnpaused ( const ToxPk sender,
const ToxFile file,
bool  paused 
)
slot

Definition at line 254 of file chathistory.cpp.

Here is the call graph for this function:

◆ onFileUpdated

void ChatHistory::onFileUpdated ( const ToxPk sender,
const ToxFile file 
)
slot

Definition at line 219 of file chathistory.cpp.

Here is the call graph for this function:

◆ onMessageBroken

void ChatHistory::onMessageBroken ( DispatchedMessageId  id,
BrokenMessageReason  reason 
)
privateslot

Definition at line 312 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onMessageComplete

void ChatHistory::onMessageComplete ( DispatchedMessageId  id)
privateslot

Definition at line 303 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onMessageReceived

void ChatHistory::onMessageReceived ( const ToxPk sender,
const Message message 
)
privateslot

Definition at line 265 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onMessageSent

void ChatHistory::onMessageSent ( DispatchedMessageId  id,
const Message message 
)
privateslot

Definition at line 281 of file chathistory.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ searchBackward()

SearchResult ChatHistory::searchBackward ( SearchPos  startIdx,
const QString &  phrase,
const ParameterSearch parameter 
) const
overridevirtual

searches backwards through the chat log until phrase is found according to parameter

Parameters
[in]startIdxinclusive start idx
[in]phrasephrase to find (may be modified by parameter)
[in]parametersearch parameters

Implements IChatLog.

Definition at line 138 of file chathistory.cpp.

Here is the call graph for this function:

◆ searchForward()

SearchResult ChatHistory::searchForward ( SearchPos  startIdx,
const QString &  phrase,
const ParameterSearch parameter 
) const
overridevirtual

searches forwards through the chat log until phrase is found according to parameter

Parameters
[in]startIdxinclusive start idx
[in]phrasephrase to find (may be modified by parameter)
[in]parametersearch parameters

Implements IChatLog.

Definition at line 122 of file chathistory.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ brokenMessages

QMap<DispatchedMessageId, BrokenMessageReason> ChatHistory::brokenMessages
private

Definition at line 80 of file chathistory.h.

◆ completedMessages

QSet<DispatchedMessageId> ChatHistory::completedMessages
private

Definition at line 77 of file chathistory.h.

◆ coreIdHandler

const ICoreIdHandler& ChatHistory::coreIdHandler
private

Definition at line 72 of file chathistory.h.

◆ dispatchedMessageRowIdMap

QMap<DispatchedMessageId, RowId> ChatHistory::dispatchedMessageRowIdMap
private

Definition at line 84 of file chathistory.h.

◆ f

Friend& ChatHistory::f
private

Definition at line 69 of file chathistory.h.

◆ history

History* ChatHistory::history
private

Definition at line 70 of file chathistory.h.

◆ sessionChatLog

SessionChatLog ChatHistory::sessionChatLog
mutableprivate

Definition at line 73 of file chathistory.h.

◆ settings

const Settings& ChatHistory::settings
private

Definition at line 71 of file chathistory.h.


The documentation for this class was generated from the following files: