Esempio n. 1
0
void SearchTab::currentDateChanged()
{
	const QModelIndex &currentIndex = TimelineView->timeline()->currentIndex();
	if (!currentIndex.isValid())
	{
		TimelineView->messagesView()->setChat(Chat::null);
		TimelineView->messagesView()->clearMessages();
		return;
	}

	const Talkable talkable = currentIndex.data(TalkableRole).value<Talkable>();
	const QDate date = currentIndex.data(DateRole).value<QDate>();

	auto chat = m_talkableConverter->toChat(talkable);
	if (!chat)
	{
		chat = m_chatStorage->create();
		chat.setDisplay("?");
	}
	TimelineView->messagesView()->setChat(chat);

	if (SearchedStorage && *SearchedStorage)
	{
		HistoryQuery query;
		query.setTalkable(talkable);
		query.setFromDate(date);
		query.setToDate(date);

		TimelineView->setFutureMessages((*SearchedStorage)->messages(query));
	}
	else
		TimelineView->setMessages(SortedMessages());
}
Esempio n. 2
0
void HistoryMessagesTab::currentDateChanged()
{
	QDate date = timelineView()->currentDate();

	if (!Storage || !date.isValid())
	{
		TimelineView->setMessages(SortedMessages());
		return;
	}

	HistoryQuery query;
	query.setTalkable(CurrentTalkable);
	query.setFromDate(date);
	query.setToDate(date);

	Chat chat = CurrentTalkable.toChat();
	// if buddy do not have any contact we have to create chat manually
	if (!chat)
		chat = BuddyChatManager::instance()->buddyChat(CurrentTalkable.toBuddy());

	timelineView()->messagesView()->setChat(chat);
	TimelineView->setFutureMessages(Storage->messages(query));
}